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

Peter Lundh simran at teleline.es
Mon Mar 3 04:35:00 EST 2003


I put Rob's two scripts into a field and banged away on the returnKey and it
works well:

=============
--I put this script in a field
on focusIn
   set the backgroundColor of me to "0,0,0"
   setBackgroundColor true
end focusIn

on returnInField
   setBackgroundColor false
end returnInField

local secondPass

on setBackgroundColor initLocal
    if initLocal then
      get "0,0,0"
      put false into secondPass
    else
      get the backgroundColor of the target
     
      if it is "255,255,255" then
        get "0,0,0"
        put not secondPass into secondPass
      else
        put item 1 of it into rValue
        put item 2 of it into gValue
        put item 3 of it into bValue
        if secondPass then
           put rValue+15 into item 1 of it
           put gValue+15 into item 2 of it
           put bValue+15 into item 3 of it
       
        else
           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
     
      end if
    end if
    set the backgroundColor of the target to it
end setBackgroundColor
=============

I would like to make two modifications to the script above and would
appreciate some help:

At the moment it cycles through the red color and then moves on to the green
and the blue color and finally scales through the neutral colors (R=G=B).

(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).

I have tried to fiddle around with the else...if arguments, but get lost...

===

(2) I would like the finished build not to be displayed in a window, or
there to be a menu at the top of the screen. Just neutral grey background on
which the colored square is placed. How can I achieve that?

Many thanks in advance.

-Peter
-- 
Peter Lundh von Leithner
E: simran at teleline.es
UK




More information about the use-livecode mailing list