Sorry, it seems YahooMail mangled the spaces: here's the script again...

##
on mouseUp
   CreateTwoColorGraphic "Peter", "10,50,110,85", "255,0,0", "0,0,255"
   answer"Created:"&& the result
end mouseUp

private command CreateTwoColorGraphic pName, pRectangle, pTopColor, pBottomColor
   --> prepare the fillGradient array
   local tFillGradientA
   put "linear" into tFillGradientA["type"]
   put (item 1 of pRectangle),(item 2 of pRectangle) into tFillGradientA["from"]
   put (item 1 of pRectangle),(item 4 of pRectangle) into tFillGradientA["to"]
   put (item 3 of pRectangle),(item 2 of pRectangle) into tFillGradientA["via"]
   put   0.00000,pTopColor & return & \
         0.49999,pTopColor & return & \
         0.50000,pBottomColor & return & \
         1.00000,pBottomColor \
         into tFillGradientA["ramp"]
   --> now create the graphic
   local tGraphicLongId
   reset the templateGraphic
   set the rectangle of the templateGraphic to pRectangle
   set the opaque of the templateGraphic to true
   set the fillGradient of the templateGraphic to tFillGradientA
   create graphic pName
   put it into tGraphicLongId
   --> and cleanup before returning the long id of the graphic
   reset the templateGraphic
   return tGraphicLongId
end CreateTwoColorGraphic
##

Jan.
 
=====
Quartam Reports & PDF Library for LiveCode
www.quartam.com


=====
"As we grow older, we grow both wiser and more foolish at the same time."  (La 
Rochefoucauld)


----- Original Message -----
From: Jan Schenkel <janschen...@yahoo.com>
To: How to use LiveCode <use-livecode@lists.runrev.com>
Cc: 
Sent: Tuesday, June 26, 2012 10:57 PM
Subject: Re: Gradients (was "Re: Table field")

Hi Peter,

You can do it all from code if you like. Create a new stack, drop a button onto 
it, and set its script to:

##
...
##

Then click the button, and you'll get a graphic named "Peter" in the specified 
rectangle, with the two colors each taking up half of the height of the 
graphic, even when you resize it.

HTH,

Jan Schenkel.
 
=====
Quartam Reports & PDF Library for LiveCode
www.quartam.com


=====
"As we grow older, we grow both wiser and more foolish at the same time."  (La 
Rochefoucauld)


----- Original Message -----
From: Peter Haworth <p...@lcsql.com>
To: How to use LiveCode <use-livecode@lists.runrev.com>
Cc: 
Sent: Tuesday, June 26, 2012 10:08 PM
Subject: Re: Gradients (was "Re: Table field")

Thanks Scott.  As usual, a very useful learning tool.

Here's what I can't figure out though.  Your stack fades in the colors from
top to bottom. How can I get the graphic to contain two separate colors,
one that fills the top half of the graphic and another that fills in the
bottom half, with no fading just a clean horizontal break between them.

Maybe gradients are not the way to do this, although Bern'ds table stack
uses them for the graphic involved in coloring alternate lines - I just
can't figure out all the values for the different gradient array keys.

Pete
lcSQL Software <http://www.lcsql.com>


_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Reply via email to