change opacity levels individually
Good year
I'm new to scripting and speak little English I hope to be clear.
I would like to create a panel that I change the opacity levels individually
as in this example
second and you can make it happen?

Good year
I'm new to scripting and speak little English I hope to be clear.
I would like to create a panel that I change the opacity levels individually
as in this example
second and you can make it happen?

// change layers’ opacity via scrollbars;
// 2015, use it at your own risk;
#target photoshop
if (app.documents.length > 0) {
app.activeDocument.suspendHistory("opacity", "theDialog ()");
};
function theDialog () {
//////////////////////////////////////////
var theLayers = theLayerNames ();
////// create dialog for user-entry //////
var dlg = new Window('dialog', "layeropacity", undefined);
//////////////////////////////
dlg.layer = dlg.add('panel', undefined, "opacity");
dlg.layer.orientation = "column";
dlg.layer.preferredSize = [300, 50];
// populate panel;
for (var m = 0; m < theLayers.length; m++) {
dlg.layer.add('statictext', undefined, theLayers
dlg.layer.add('scrollbar', undefined, theLayers
dlg.layer.children[m*2+1].preferredSize = [255,20];
//////////////////////////////
// if scrolled;
dlg.layer.children[m*2+1].onChange = function () {
var theCh = dlg.layer.children.length;
for (var n = 0; n < theCh; n++) {
if (dlg.layer.children
};
setOpacityByID (theLayers[(theNumber-1)/2][1], Math.round(this.value));
app.refresh();
};
};
//////////////////////////////
// build- and cancel-button;
dlg.cancelOk = dlg.add('panel', [12,495,308,550], "");
dlg.cancelOk.buildBtn = dlg.cancelOk.add('button', [10,10,141,40], 'OK', {name:'ok'});
dlg.cancelOk.cancelBtn = dlg.cancelOk.add('button', [149,10,280,40], 'Cancel', {name:'cancel'});
dlg.center();
var myReturn = dlg.show ();
//////////////////////////////
// reset if canceled;
if (myReturn != 1) {
for (var a = 0; a < theLayers.length; a++) {
setOpacityByID (theLayers[1], theLayers[2])
}
};
$.gc();
};
////////////////////////////////////
function theLayerNames () {
// the file;
var myDocument = app.activeDocument;
// get number of layers;
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID("Dcmn"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
var applicationDesc = executeActionGet(ref);
var theNumber = applicationDesc.getInteger(stringIDToTypeID("numberOfLayers"));
// process the layers;
var theLayers = new Array;
for (var m = 0; m <= theNumber; m++) {
try {
var ref = new ActionReference();
ref.putIndex( charIDToTypeID( "Lyr " ), m);
var layerDesc = executeActionGet(ref);
var layerSet = typeIDToStringID(layerDesc.getEnumerationValue(stringIDToTypeID("layerSection")));
var isBackground = layerDesc.getBoolean(stringIDToTypeID("background"));
// if not layer group collect values;
if (layerSet != "layerSectionEnd" && layerSet != "layerSectionStart" && isBackground != true) {
var theName = layerDesc.getString(stringIDToTypeID('name'));
var theID = layerDesc.getInteger(stringIDToTypeID('layerID'));
var theOpacity = layerDesc.getInteger(stringIDToTypeID('opacity'));
theLayers.push([theName, theID, theOpacity])
};
}
catch (e) {};
};
return theLayers
};
////// set opacity //////
function setOpacityByID (theID, theOpacity) {
// =======================================================
var idsetd = charIDToTypeID( "setd" );
var desc2 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var idLyr = charIDToTypeID( "Lyr " );
var ref1 = new ActionReference();
ref1.putIdentifier( idLyr, theID );
desc2.putReference( idnull, ref1 );
var idT = charIDToTypeID( "T " );
var desc3 = new ActionDescriptor();
desc3.putUnitDouble( charIDToTypeID( "Opct" ), charIDToTypeID( "#Prc" ), Math.round(theOpacity/2.55) );
desc2.putObject( idT, idLyr, desc3 );
executeAction( idsetd, desc2, DialogModes.NO );
};
Already have an account? Login
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.