Converting colour names: Hex & RGB colour values...

David Bovill david.bovill at opn-technologies.com
Mon Jan 7 08:17:05 EST 2002


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




More information about the use-livecode mailing list