Scripting shades of colors?

Dan Friedman dan at clearvisiontech.com
Tue Oct 30 12:02:21 EDT 2012


Michael,

Here is a function that I use to lighten a color.  You could modify this to get a darker color as well.  Hope it helps.

function lightenColor origColor
  try
    repeat with i = 1 to 3
      add 50 to item i of origColor
      if item i of origColor > 255 then put 255 into item i of origColor
      if item i of origColor < 0 then put 0 into item i of origColor
    end repeat
    return origColor
  catch tSomeErr
    return origColor
  end try
end lightenColor

-Dan


> Hi there
> 
> Lets say I have a color a,b,c
> 
> Now I want the same color but fx 10% darker and 10 % lighter.
> 
> (As if you in the colorwheel palette dragged the scrollbar-thumb a little down and a little up)
> 
> How could one script this?
> 
> Thanks
> Michael




More information about the use-livecode mailing list