Copy link to clipboard
Copied
Hello, there.
There is a way to get colorValue for the color picker selected color?
1 Correct answer
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
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() );
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.
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
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!
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
Copy link to clipboard
Copied
Awesome. That's exactly what I need. Thank you so much, Uwe!
Kind regards from Brazil.
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.

