Color names vs hex codes

Howard Bornstein bornstein at designeq.com
Wed Jan 9 17:24:10 EST 2013


Lol, thanks for reminding me of the source of this, Jacque. I knew I nabbed
it from someone. I just couldn't remember whom.

On Tue, Jan 8, 2013 at 10:26 PM, J. Landman Gay <jacque at hyperactivesw.com>wrote:

> That's what I use too. Credit to Ken Ray. :) Howard Bornstein <
> bornstein at designeq.com> wrote:This is what I use:
>
> *function* RGBFromColorName theColor
>
>   *if* theColor is not a color *then* *return* "Error: not a color"
>
>   *-- create a temporary object for the color transformation:*
>
>   *create* invisible button
>
>   *if* the result is not empty *then* *return* "Error"
>
>   *set* the backgroundColor of last button to theColor
>
>   *-- transform the color using the backgroundPixel trick:*
>
>   *set* the backgroundPixel of last button to the backgroundPixel of last
> button
>
>   *-- the button's backgroundColor is now RGB:*
>
>   *get* the backgroundColor of last button
>
>   *delete* last button *-- don't need the temp object any more*
>
>   *-- the create command automatically chose the pointer*
>
>   *-- tool, so change it back:*
>
>   *send* "choose browse tool" to me in 10 milliseconds
>
>   *return* it
>
> *end* RGBFromColorName
>
> --
> Regards,
>
> Howard Bornstein
> -----------------------
> www.designeq.com
> On Tue, Jan 8, 2013 at 5:24 PM, Peter Haworth <pete at lcsql.com> wrote:
>
> > I have a need to convert a color name form LC's colornames property to
> its
> > equivalent hex value, or rgb value.  Can that be done in LC?
> > Pete
> > lcSQL Software <http://www.lcsql.com>
>



More information about the use-livecode mailing list