Skip to content

Instantly share code, notes, and snippets.

@leigh-johnson
Last active August 29, 2015 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leigh-johnson/036431a26738c071020e to your computer and use it in GitHub Desktop.
Save leigh-johnson/036431a26738c071020e to your computer and use it in GitHub Desktop.
photoshop-toggle-blendmode.js
// store current layer of active document
var activeLayer = app.activeDocument.activeLayer;
function toggleAll(layer) {
// determine state
split = (layer.name).split(' ');
if ('*working*' in split){
// recover the mode from *working* layer name
layer.blendMode = BlendMode[split[-1]];
// reset name
layer.name = split.slice(0,-3);
toggleIsolate(layer);
}
else{
// write blend mode (and other relevant data, you can extend this) to layer name
mode = layer.blendMode
layer.name += '*working* Prev: ' + mode;
// set current blend mode to normal
layer.blendMode = 'NORMAL';
toggleIsolate(layer);
}
};
function toggleIsolate(layer) {
var desc = new ActionDescriptor();
var list = new ActionList();
var ref = new ActionReference();
var idNull = charIDToTypeID( "null" );
var idTglO = charIDToTypeID( "TglO" );
var idLyr = charIDToTypeID( "Lyr " );
var idShw = charIDToTypeID( "Shw " );
ref.putName( idLyr, layer.name);
list.putReference( ref);
desc.putList(idNull, list );
desc.putBoolean( idTglO, true );
executeAction( idShw, desc, DialogModes.NO );
};
toggleAll(activeLayer);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment