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

Peter Haworth pete at lcsql.com
Tue Dec 10 17:25:46 EST 2013


Whoops, really?  I read it the other way round.  Which was it Jim?

Pete
lcSQL Software <http://www.lcsql.com>


On Tue, Dec 10, 2013 at 1:42 PM, J. Landman Gay <jacque at hyperactivesw.com>wrote:

> 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
>
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>



More information about the use-livecode mailing list