RGB colours

Sarah Reichelt sarah.reichelt at gmail.com
Tue Dec 18 16:31:10 EST 2007


On Dec 19, 2007 5:47 AM, David Bovill <david at openpartnership.net> wrote:
> I want to be able to translate between colorname and rgb tripplets. AFAIK
> there is still no built in way to do this. In the past I created a lookup
> array by setting the bgcolor of an object to  each of the colornames and
> retrieving the bgcolor (which used to be an rgb tripplet) - now however I
> get back the colorname? This seems to have changed from earlier versions?

Here is a function I gleaned from the list a long time ago.

function translateColorName pColorName
   lock screen
   lock messages
   create btn "ColorTest"
   put it into tButtonID
   set the backcolor of tButtonID to pColorName
   get the effective backpixel of tButtonID
   set the backcolor of tButtonID to empty
   set the backpixel of tButtonID to it
   put the backcolor of tButtonID into tRGB
   delete tButtonID

   return tRGB
end translateColorName


HTH,
Sarah



More information about the use-livecode mailing list