Last active
August 29, 2015 14:26
-
-
Save leigh-johnson/036431a26738c071020e to your computer and use it in GitHub Desktop.
photoshop-toggle-blendmode.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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