Gradients (was "Re: Table field")

Peter Haworth pete at lcsql.com
Tue Jun 26 18:03:44 EDT 2012


Great, Thanks Jan.  I see it's ramp that determines how the colors are
displayed.  Finally beginning to uderstand this!

What I'm aiming for is to allow the user to select the background color of
the alternate lines in the table and I think I can do that by getting the
gradient array and changing the color in the ramp.  Also sounds like thew
graphic can be adjusted to the height of the lines
Pete
lcSQL Software <http://www.lcsql.com>



On Tue, Jun 26, 2012 at 1:57 PM, Jan Schenkel <janschenkel at yahoo.com> wrote:

> 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:
>
> ##
> on mouseUp
>    CreateTwoColorGraphic "Peter", "10,50,110,85", "255,0,0", "0,0,255"
>    answer"Created:"&& theresult
> 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
>    resetthetemplateGraphic
>    settherectangleofthetemplateGraphictopRectangle
>    settheopaqueofthetemplateGraphictotrue
>    setthefillGradientofthetemplateGraphictotFillGradientA
>    create graphic pName
>    put it into tGraphicLongId
>    --> and cleanup before returning the long id of the graphic
>    resetthetemplateGraphic
>    return tGraphicLongId
> end CreateTwoColorGraphic
> ##
>
> 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 <pete at lcsql.com>
> To: How to use LiveCode <use-livecode at 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 at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>



More information about the Use-livecode mailing list