How do I find the rgb values for colors defined by their name: e.g. blue, green, yellow etc.

Richard Gaskin ambassador at fourthworld.com
Mon Dec 9 20:21:36 EST 2013


Peter Haworth wrote:

> Hi Jim,
> Sent this earlier but it didn't make it for some reason.  This is a
> function that some kind person on the list gave me a while back:
>
> *function* RGBFromColorName theColor
> *   if* theColor is not a color *then* *return* "Error: not a color"
>
>    *create* invisible button
>
>    *if* the result is not empty *then* *return* "Error"
>
>    *set* the backgroundColor of last button to theColor
>
>    *set* the backgroundPixel of last button to the backgroundPixel of last
> button
>
>    *get* the backgroundColor of last button
>
>    *delete* last button
>
>    *return* it
>
>    *end* RGBFromColorName

For greater robustness and a modest performance boost you could use the 
templateButton rather than creating a new physical button.

--
  Richard Gaskin
  Fourth World
  LiveCode training and consulting: http://www.fourthworld.com
  Webzine for LiveCode developers: http://www.LiveCodeJournal.com
  Follow me on Twitter:  http://twitter.com/FourthWorldSys




More information about the Use-livecode mailing list