Converting colour names: Hex & RGB colour values...
Sarah Reichelt
sarahr at genesearch.com.au
Fri Jan 11 00:45:01 EST 2002
David,
I was struggling with a way to do this also, but when I checked the Color
palette, it just uses a custom property as a lookup table.
Here's how to get the list:
put the cREVColorTranslation of cd 1 of stack "revColors" into fld 1
This gives a list with each line having the following format:
name,r,g,b
I would like to be able to set a color using the name but then be able to
read it as RGB.
Cheers,
Sarah
> Thanks Chip, this (I think) works for the mouseColor (which seems to always
> return RGB triplets), but if you have a button which has the background
> colour set to "red" - then (unfortunately) the backgroundcolor of that
> button is "red" - not "255,0,0"
>
> Baseconvert does not like "red"... so how do you force a function to return
> an RGB triplet? Or better still given MC can understand RGB, HTML/Hex and
> "red" - how do you convert between them without writing your own lookup
> table for all those MC colour names?
>
>> From: "Chipp Walters" <chipp at chipp.com>
>> Subject: RE: Converting colour names: Hex & RGB colour values...
>>
>>
>> on mouseDown
>> put the mouseColor into thecolor
>>
>> set the numberFormat to "##"
>>
>> put formathex(baseConvert(item 1 of thecolor,10,16)) into R
>> put formathex(baseConvert(item 2 of thecolor,10,16)) into G
>> put formathex(baseConvert(item 3 of thecolor,10,16)) into B
>>
>>
>> put thecolor into cd fld "rgb" of cd "stageLg" of stack "HemTools"
>> put "#" & R & G & B into cd fld "hex" of cd "stageLg" of stack "HemTools"
>> go to cd "stage" of stack "Hemtools"
>> click at the loc of btn "Open Button"
>> set the menuHistory of button "tabs" to 2
>>
>> end mouseDown
>>
>> function formathex thevalue
>> if the length of thevalue is 1
>> then put "0" before thevalue
>> return thevalue
>> end formathex
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/use-revolution
>
More information about the use-livecode
mailing list