Skip to main content
Geppetto Luis
Brainiac
November 24, 2018
Question

Create gradient map from swatches

  • November 24, 2018
  • 3 replies
  • 3864 views

I have a need and I do not know if it's possible

I would like to create a gradient map from swatches

This topic has been closed for replies.

3 replies

Brainiac
November 26, 2018

I accidentally found a way to get color from color swatches.

But I do not think that this will help in this incomprehensible task.

Do not press Ctrl-key before and during the execution of the script.

var c1 = app.foregroundColor;

for (var i = 1;;i++)

    {

    var d = new ActionDescriptor();

    var r = new ActionReference();

    r.putIndex(stringIDToTypeID("colors"), i);

    d.putReference(stringIDToTypeID("null"), r);

    try { executeAction(stringIDToTypeID("select"), d, DialogModes.NO); } catch(e) { break; }

    var c = app.foregroundColor;

    app.foregroundColor = c1;

    alert("Swatch " + i+ "\n\n#" + c.rgb.hexValue);

    }

   

alert(i + " Done!")

pixxxelschubser
Community Expert
November 26, 2018

Interesting!

works properly in CC 2019 but change only the background color (and give always back the same value for the foreground color) in CC 2017

Brainiac
November 26, 2018

It depends which color is set on the Color panel to be active, foreground or background.
Pressing Ctrl changes the inactive color with the "select" command.

In general, the method is a bit dumb.

Geppetto Luis
Brainiac
November 24, 2018

If I can choose and better.

pixxxelschubser
Community Expert
November 24, 2018

probably minimum and possible maximum?

Geppetto Luis
Brainiac
November 24, 2018

minimum 3 maximum 10,

pixxxelschubser
Community Expert
November 24, 2018

from two, three, four, five … swatches - or from all swatches?

Can you show/give an example file?