Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Get color picker selected color values

Enthusiast ,
May 15, 2018 May 15, 2018

Hello, there.

There is a way to get colorValue for the color picker selected color?

TOPICS
Scripting
785
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , May 16, 2018 May 16, 2018

Oh, there is a way as well. It should be the last color added in the colors array you get with:

var colors = app.documents[0].colors.everyItem().getElements();

var lastColorAdded = colors[colors.length-1];

FWIW: This color has no name.

Regards,
Uwe

Translate
People's Champ ,
May 16, 2018 May 16, 2018

var color = "#"+($.colorPicker ().toString(16) );

function hexToRgb(hex) {

    var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);

    return result ? {

        r: parseInt(result[1], 16),

        g: parseInt(result[2], 16),

        b: parseInt(result[3], 16)

    } : null;

}

alert( hexToRgb(color).toSource() );

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
May 16, 2018 May 16, 2018

Doesn't worked for what I need.

Maybe I'm not clear in my original post.

When the user uses the "eyedropper tool" to select a color, this color fills the swatch panel selected fill or stroke color.

I need to get the value of that color. The one that fills, for example, the "fill square" in swatches panel.

I'm sorry to not be clear enought.

And thanks for your help, Löic.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 16, 2018 May 16, 2018

Hi,

one could add a rectangle to the page and check fillColor or strokeColor properties:

colorValue, model and space .

Regards,
Uwe

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
May 16, 2018 May 16, 2018

Thank you guys!

That's my fear. No way to get directly from fill square from swatches panel.

Thanks, Löic and Uwe!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 16, 2018 May 16, 2018

Oh, there is a way as well. It should be the last color added in the colors array you get with:

var colors = app.documents[0].colors.everyItem().getElements();

var lastColorAdded = colors[colors.length-1];

FWIW: This color has no name.

Regards,
Uwe

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
May 16, 2018 May 16, 2018
LATEST

Awesome. That's exactly what I need. Thank you so much, Uwe!

Kind regards from Brazil.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
May 16, 2018 May 16, 2018

lf.corullon  a écrit

Doesn't worked for what I need.

Maybe I'm not clear in my original post.

My bad, I saw a post dealing with colorPicker and my brain made a connection

I think Laubender​ said it all.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines