4 Replies Latest reply on Mar 21, 2011 8:37 AM by Muppet Mark-QAl63s

    Converting color values

    xbytor2 Level 4

      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...

        • 1. Re: Converting color values
          Muppet Mark-QAl63s Level 4

          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);
          

          • 2. Re: Converting color values
            xbytor2 Level 4

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

             

            thanks...

            • 3. Re: Converting color values
              Michael L Hale Level 5

              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);
              
              • 4. Re: Converting color values
                Muppet Mark-QAl63s Level 4

                Mike, Im convinced I tried that and it didn't work like I expected. I too will have to check on my typing…