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

Get color picker selected color values

Enthusiast ,
May 15, 2018 May 15, 2018

Copy link to clipboard

Copied

Hello, there.

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

TOPICS
Scripting

Views

592

Translate

Translate

Report

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

Votes

Translate

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

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

Hi,

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

colorValue, model and space .

Regards,
Uwe

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

Thank you guys!

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

Thanks, Löic and Uwe!

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

LATEST

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

Kind regards from Brazil.

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

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