Skip to main content
This topic has been closed for replies.
Correct answer Laubender

Thank you guys!

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

Thanks, Löic and Uwe!


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

1 reply

Loic.Aigon
Legend
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() );

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

Community Expert
May 16, 2018

Hi,

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

colorValue, model and space .

Regards,
Uwe