[ANN] Color Converter utility
Wilhelm Sanke
sanke at hrz.uni-kassel.de
Mon Jul 5 15:41:44 EDT 2004
On Sun Jul 4 Hugh Senior wrote:
> ColorConverter
>
> Thanks to ideas on this list, a utility is now available at the link
> below
> that takes any color description in RGB, Web Code, Color Name or
> Blend format
> and converts it to the RGB, WebCode or Blend format equivalent...
>
> _http://www.FlexibleLearning.com/xtalk_
> (http://www.FlexibleLearning.com/xtalk)
>
> Not locked, so explore and use as you wish.
>
> /H
A perfect little utility with a lot of possibilities!
Some remarks to previous posts of thread "Equivalence of Color names to RGB"
MisterX b.xavier at internet.lu wrote (from his sample script):
> put the colornames into colorslist
> repeat for each line c in colorslist
> set the backcolor of btn 1 to c
> get the backcolor of btn 1
> etc.
This cannot work. When you set the backcolor of an object to a
colorname, backcolor then is somehow treated like a custom property and
will return the very color name.
This is where the backpixel property is needed to get the RGB values of
a color name.
Jeanne A. E. DeVoto revolution at jaedworks.com wrote:
> At 9:41 PM -0600 7/3/2004, Dar Scott wrote:
> >Idea 4: There is a color names palette in the docs and it shows the
> >RBG value. Maybe you can figure out how RunRev does it.
>
> It's hard-coded. There's an example for this in the Transcript
> cookbook, though: "Recipe for translating a color name to an RGB
> numeric triplet".
> --
> jeanne a. e. devoto
The hard-coded one is stack "revcolornames" (alias "revdocscolor names
reference") in folder "components/help/appendixes". Its 555 graphics
contain the RGB values as custom properties.
The hard-coding here is not really needed, as the color names are
already hard-coded in the engine.
Another stack, "revExample: translating a color name to an RGB numeric
triplet", a substack of "revdocscookbook", then uses the backpixel
property in a somewhat circumstantial way; compare the function
"RGBFromColorName theColor" (script of btn "color name" of group "example").
And there is still another stack, the very old and venerable "color
chooser" (a substack of stack "license.rev" alias "home), which is
identical to the "color chooser" of the Metacard IDE and was coded by
Scott Raney:
- open the "color chooser"
- click on the "name" tab
- choose a color name
- go to tab "RGB" and there the corresponding RGB triplet is displayed
The relevant code lines of function "getcolor nameOK" in the card script
of stack "color chooser" are
"get the effective backPixel of button cindex
set the backColor of button cindex to empty
set the backPixel of button cindex to it
return the effective backColor of button cindex"
of which line "set the backColor of button cindex to empty" is redundant.
In Hugh Senior's function "colorName2RGB which" of his "Color Converter"
the corresponding lines are
"get the effective backPixel of fld "sample"
set the backPixel of field "sample" to it
return the backcolor of fld "sample""
Translated into a simple button script these lines could look like this:
on mouseUp
ask "Choose a color"
if it is among the lines of the colornames then
set the backcolor of field "Test" to it
get the effective backpixel of fld "Test"
set the backpixel of fld "Test" to it
put the backcolor of fld "Test" into fld "Test"
end if
end mouseUp
When you set the colors of objects in the object inspector, apparently
none of these stacks is involved (Rev 2.2.1, Windows XP).
Instead the Windows in-built color dialog comes up.
Regards,
Wilhelm Sanke
More information about the use-livecode
mailing list