What's new

Scripting modify active color without going through any menu (via shortcuts / scripts)

#1
hi

how can I modify the current color via keystrokes (either with a shortcut or a script) ? like adding or substracting 1 to the R G B values


thanks in advance, cheers
 

revnart

Power User
#2
Here is the script that gets actual foreground Color and ads + 1 to each until 255 (just paste it into notepad and save as jsx file):
JavaScript:
#target photoshop 

var Color = app.foregroundColor;

var newR = Math.round(foregroundColor.rgb.red) + 1;
var newG = Math.round(foregroundColor.rgb.green) + 1;
var newB = Math.round(foregroundColor.rgb.blue) + 1;

if(newR > 255){
    newR = 255;
}

if(newG > 255){
    newG = 255;
}

if(newB > 255){
    newB = 255;
}


Color.rgb.red = newR;
Color.rgb.green = newG;
Color.rgb.blue = newB;

app.foregroundColor = Color;
and here is version for subtracting by 1 until 0:

JavaScript:
#target photoshop 

var Color = app.foregroundColor;

var newR = Math.round(foregroundColor.rgb.red) - 1;
var newG = Math.round(foregroundColor.rgb.green) - 1;
var newB = Math.round(foregroundColor.rgb.blue) - 1;

if(newR < 0){
    newR = 0;
}

if(newG < 0){
    newG = 0;
}

if(newB < 0){
    newB = 0;
}


Color.rgb.red = newR;
Color.rgb.green = newG;
Color.rgb.blue = newB;

app.foregroundColor = Color;
hope that helps ;)
 
#4
Hope that this is what you need ;) Just remember - It will work in LAB or CMYK mode but it will still increase RGB values by 1 not C,M,Y or K for example ;)
 

Top