Skip to main content
Inspiring
March 21, 2011
Answered

Converting color values

  • March 21, 2011
  • 1 reply
  • 729 views

Is there any simple way to convert an RGB color to and from other colors (e.g. HSL, Lab)?

I thought I had  a way to have SolidColor do the conversion, but I can't seem to get it to work...

This topic has been closed for replies.
Correct answer Muppet_Mark-QAl63s

Does putting the solid color in the app's foreground then pulling back the other values not get you what you need? I don't do much of this so I could be a mile off…

var rgbSC = new SolidColor() rgbSC.rgb.red=0; rgbSC.rgb.green=204; rgbSC.rgb.blue=100; app.foregroundColor = rgbSC; $.writeln(app.foregroundColor.cmyk.cyan); $.writeln(app.foregroundColor.cmyk.magenta); $.writeln(app.foregroundColor.cmyk.yellow); $.writeln(app.foregroundColor.cmyk.black); $.writeln(app.foregroundColor.hsb.brightness); $.writeln(app.foregroundColor.hsb.hue); $.writeln(app.foregroundColor.hsb.saturation);

1 reply

Muppet_Mark-QAl63s
Muppet_Mark-QAl63sCorrect answer
Inspiring
March 21, 2011

Does putting the solid color in the app's foreground then pulling back the other values not get you what you need? I don't do much of this so I could be a mile off…

var rgbSC = new SolidColor() rgbSC.rgb.red=0; rgbSC.rgb.green=204; rgbSC.rgb.blue=100; app.foregroundColor = rgbSC; $.writeln(app.foregroundColor.cmyk.cyan); $.writeln(app.foregroundColor.cmyk.magenta); $.writeln(app.foregroundColor.cmyk.yellow); $.writeln(app.foregroundColor.cmyk.black); $.writeln(app.foregroundColor.hsb.brightness); $.writeln(app.foregroundColor.hsb.hue); $.writeln(app.foregroundColor.hsb.saturation);

xbytor2Author
Inspiring
March 21, 2011

That's what I was doing. I was just doing it with typos....

thanks...

Inspiring
March 21, 2011

You don't need to set the foreground color

var sc = new SolidColor;
sc.rgb.red = 200;
sc.rgb.green = 145;
sc.rgb.blue = 96;
$.writeln('RGB '+sc.rgb.red+':'+sc.rgb.green+':'+sc.rgb.blue);
$.writeln('Lab '+sc.lab.l+':'+sc.lab.a+':'+sc.lab.b);
$.writeln('HSB '+sc.hsb.hue+':'+sc.hsb.saturation+':'+sc.hsb.brightness);
$.writeln('CMYK '+sc.cmyk.cyan+':'+sc.cmyk.yellow+':'+sc.cmyk.magenta+':'+sc.cmyk.black);