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

J. Landman Gay jacque at hyperactivesw.com
Tue Dec 10 16:42:22 EST 2013


On 12/10/13 3:09 PM, Jan Schenkel wrote:
>
> There's an even faster method, based on the fact that the graphic effects always convert colour names to rob triplets.
> See: <http://quality.runrev.com/show_bug.cgi?id=10253>
>
> Here's a script to compare the average speed of the colorOverlay["color"] method versus the effective backPixel method:
> ##
> on mouseUp
>     local tColorName, tColorRGB1, tColorRGB2, tStart, tTime1, tTime2
>     repeat for each line tColorName in the colorNames
>        put the milliseconds into tStart
>        set the colorOverlay["color"] of the templateGraphic to tColorName
>        put the colorOverlay["color"] of the templateGraphic into tColorRGB1
>        put the milliseconds - tStart & comma after tTime1
>        put the milliseconds into tStart
>        set the backgroundColor of the templateGraphic to tColorName
>        set the backgroundPixel of the templateGraphic to the effective backgroundPixel of the templateGraphic
>        put the backgroundColor of the templateGraphic into tColorRGB2
>        put the milliseconds - tStart & comma after tTime2
>     end repeat
>     delete char -1 of tTime1
>     delete char -1 of tTime2
>     --
>     answer "colorOverlay[color]" && average(tTime1) & return & \
>           "backgroundPixel" && average(tTime2)
> end mouseUp
> ##

These are great scripts, they're going into my scrapbook.

The original question though was how to convert an RGB value to the 
nearest colorname. I don't think you can.

-- 
Jacqueline Landman Gay         |     jacque at hyperactivesw.com
HyperActive Software           |     http://www.hyperactivesw.com




More information about the use-livecode mailing list