Gradients (was "Re: Table field")
janschenkel at yahoo.com
Tue Jun 26 15:57:52 CDT 2012
You can do it all from code if you like. Create a new stack, drop a button onto it, and set its script to:
CreateTwoColorGraphic "Peter", "10,50,110,85", "255,0,0", "0,0,255"
private command CreateTwoColorGraphic pName, pRectangle, pTopColor, pBottomColor
--> prepare the fillGradient array
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 & \
--> now create the graphic
create graphic pName
put it into tGraphicLongId
--> and cleanup before returning the long id of the graphic
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.
Quartam Reports & PDF Library for LiveCode
"As we grow older, we grow both wiser and more foolish at the same time." (La Rochefoucauld)
----- Original Message -----
From: Peter Haworth <pete at lcsql.com>
To: How to use LiveCode <use-livecode at lists.runrev.com>
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.
lcSQL Software <http://www.lcsql.com>
More information about the use-livecode