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

Looking for javascript to automate for project. Grab layer change color by 10 RGB points

New Here ,
Sep 12, 2021 Sep 12, 2021

Copy link to clipboard

Copied

Hey looking for base code for a large project. Theres 16mil variations of RGB colors. We need to select BG layer and change it by 10 RGB points, starting with Red, then Green, then Blue. Essentially working on exporting all 16 mil colors. Save file as HEX code name. Im sure we can figure out how to get what we need we just need the base of it to start. Please and Thank you! in advanced! 

TOPICS
Actions and scripting

Views

103

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
Adobe
Community Expert ,
Sep 13, 2021 Sep 13, 2021

Copy link to clipboard

Copied

An iteration of changes by 10 values would not seem to result in 16mio colors, so please explain what you are actually trying to do in more detail. 

 

Why hex-color-names? 

What output do you actually want – images or a txt-file or …? 

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
New Here ,
Sep 13, 2021 Sep 13, 2021

Copy link to clipboard

Copied

Sorry if that didnt make too much sense. Eventually We want every color possible but we want to start off with incriments of 10.

start with RGB (255, 255, 255) export and save as ffffff. Then (245, 255, 255) export as f5ffff. Then (235, 255, 255) export as ebffff so on and so on. 

Then Green (255, 245, 255) save as fff5ff and so on so on

Then Blue 

 

Looking to save them as JPEG i can have the image processor resize them to what ever needed but just getting all the colors and have them labeled as their appopriate HEX code is the ulitmate goal. 

 

I figured it might be best to do inciments of 10 that way the computer doesnt get stuck creating 16mil colors at once? idk if that would be an issue. 

 

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 ,
Sep 13, 2021 Sep 13, 2021

Copy link to clipboard

Copied

LATEST

Here’s a start, this increments the red channel (Edit: Save As PNG will keep the fill colors accurate on a reopen):

 

 

app.preferences.rulerUnits = Units.INCHES;

var f = Folder.selectDialog("Select a folder for the Saved JPEGs");
var so = new PNGSaveOptions();
var sc = [255,255,255];
var n = 10
var doc, fc, hx;
doc = app.documents.add(10, 10, 72, hx);


//increments the red channel
for (var i = 255; i >= 0; i -= n) {
    sc[0]=i;
    fc = makeRGB(sc);
    hx = fc.rgb.hexValue;  
    doc.selection.fill(fc);
    doc.saveAs(new File(f + "/" + hx + ".png"), so);   
}

doc.close();

/**
* Makes and returns an RGB color 
* @Param a an array of RGB values
* @Returns a SolidColor 
* 
*/	

function makeRGB(a){
    colorobj = new SolidColor()
    colorobj.rgb.red = a[0];
    colorobj.rgb.green = a[1];
    colorobj.rgb.blue = a[2]; 
    return colorobj;
};

 

 

Screen Shot 18.png

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