Here's an easy one: Loop to change bkgcolor

Rob Cozens rcozens at pon.net
Sun Mar 2 12:30:01 EST 2003


>I have to measure the light emitted by the display with a spectrophotometer.
>Against a grey background (128,128,128) I have to measure the light from a
>300x300 px rectangle. I want to make several measurements at increments of
>15 (0,0,0  15,0,0  30,0,0 etc) of each colour. Since the spectrophotometer
>is at some distance away from the from the display I want to make the
>process of changing the colour as automatic as possible. That is, each time
>I hit the return key, or pageDown key the value 15 is added to the
>backgroundColor until it's value reaches 255, after which it starts adding
>15 to the second (green) value - 0,15,0  0,30,0  0,45,0 etc. I would like it
>to loop through the R, G and B channels after which it does the grey levels
>(15,15,15  30,30,30  45,45,45 etc).

Hi Peter,

Here's a starter:

In field script:

on focusIn
   set the backgroundColor of me to "0,0,0"
   setBackgroundColor true
end focusIn

on returnInField
   setBackgroundColor false
end returnInField

In some script:

local secondPass

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

If this does basically what you want, I leave it to you to determine 
how to trap for the pageDown key.
-- 

Rob Cozens
CCW, Serendipity Software Company
http://www.oenolog.com/who.htm

"And I, which was two fooles, do so grow three;
Who are a little wise, the best fooles bee."

from "The Triple Foole" by John Donne (1572-1631)



More information about the use-livecode mailing list