Here's an easy one: Loop to change bkgcolor - follow-up (2)

Sarah sarahr at genesearch.com.au
Mon Mar 3 21:07:01 EST 2003


Hi Peter,

I don't know about your second query - you can do without menus but I 
think you can't display a field without a window.

For resetting the red & green values back to 0 after their loops, try 
these script alterations:

Set up 2 more local variables to tell you whether red & green have been 
done yet.
	local secondPass, redDone, greenDone
In your setBackGroundColor handler, if initLocal is true then set both 
these new variables to false.

Now edit the script as shown below:

if rValue >= 255 then put true into redDone
if gValue >= 255 then put true into greenDone

if redDone = false then
	put rValue+15 into item 1 of it
else if greenDone = false then
	put 0 into item 1 of it           -- reset red to 0
	put gValue+15 into item 2 of it
else
	put 0 into item 2 of it           -- reset green to 0
	put bValue+15 into item 3 of it
end if

Note: I have reformatted the if ... then .. else loop. I often find 
that this makes it easier to trace and see what is happening when.

Cheers,
Sarah

On Monday, March 3, 2003, at 07:35  pm, Peter Lundh wrote:
snip
>            if rValue < 255 then put rValue+15 into item 1 of it
>            else
>            if gValue < 255 then put gValue+15 into item 2 of it
>              else put bValue+15 into item 3 of it
>             end if
>          end if
snip
> (1) I would like to modify it a bit, but can't figure out how - 
> perhaps you
> can help: When it comes to the end of the red colors (255,0,0) it 
> should
> RESET the red color (0,0,0) before moving on to the green color (0,15,0
> 0,30,0 etc). At the moment it keeps the red values at 255 producing a
> backwards yellow scale (red+green) instead of a green one.
>
> Like ways, at the end of the second cycle (255,255,0 at the moment, but
> should be 0,255,0) it should reset the red and green colors to 0 before
> starting on the blue scale (0,0,15  0,0,30 etc). At the moment the red 
> and
> the green values are stuck at 255 making the scale go from pure yellow
> (255,255,0) to white (255,255,255) instead of from black (0,0,0) to 
> pure
> blue (0,0,255).
snip





More information about the use-livecode mailing list