I forgot to delete the line
executeAction( stringIDToTypeID( "revert" ), undefined, DialogModes.NO );
that I use for testing.
By @c.pfaffenbichler
wowwww - wonderful
tnq very much
Actually, in my fascination for paths, I overlooked that the Selection to determine the leftmost side of the colorful bars itself has bounds and the first Work Path is not necessary.
Please try this instead:
// selectTextsLeftOfBarGraphs
// create rectangular selection for texts left of bars;
// 2023, use it at your own risk;
executeAction( stringIDToTypeID( "revert" ), undefined, DialogModes.NO );
var time1 = Number(timeString());
moveNumbersLeftOfBarGraphs ();
var time2 = Number(timeString());
alert("\nthe script took: "+((time2-time1)/1000)+" seconds\nstart "+time1+"\nend "+time2+"\n\n");
////// move numbers to left of bar graphs //////
function moveNumbersLeftOfBarGraphs () {
if (app.documents.length > 0) {
// the number of pixels;
var theScale = 2;
var originalRulerUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PIXELS;
app.togglePalettes();
var myDocument = app.activeDocument;
if (myDocument.mode != "DocumentMode.RGB") {myDocument.convertProfile ("sRGB IEC61966-2.1", Intent.RELATIVECOLORIMETRIC, true, true)};
var theLayer = myDocument.activeLayer;
// resize image;
myDocument.resizeImage (undefined, undefined, 72, ResampleMethod.NONE);
myDocument.resizeImage (new UnitValue (theScale*100, "%"), new UnitValue (theScale*100, "%"), undefined, ResampleMethod.NEARESTNEIGHBOR);
// create path;
createSelectiveColorAdjustmentLayerAndThresholdAdjustmentLayer();
loadChannelAsSelection("red", true, false);
var lineStartLeft = myDocument.selection.bounds[0];
deselect();
////////////////////////////////////
myDocument.layers[0].remove();
myDocument.layers[0].remove();
deselect ();
////////////////////////////////////
loadChannelAsSelection("red", true, false);
rectangularSelection (0, 0, lineStartLeft-4, myDocument.height, false, true);
myDocument.quickMaskMode = true;
useMagicWand2022 ([1,1]);
expandSelection(12);
invertSelection ();
fillWithBlack ("white");
deselect ();
applyThreshold(90);
myDocument.quickMaskMode = false;
var thePathIndex = makeWorkPath2 (0.5);
var thePath = collectPathInfoFromDesc2023 (myDocument, thePathIndex[0]);
deletePath (thePathIndex[0]);
////////////////////////////////////
var lineStartExtremes = getSubPathItemExtremes(thePath[0]);
var theNamesPath = [lineStartExtremes];
// process subpathitems;
for (var m = 1; m < thePath.length; m++) {
var theExtremes = getSubPathItemExtremes(thePath[m]);
// add subpathitem if within the vertical dimensions;
if (theExtremes[1] >= lineStartExtremes[1] && theExtremes[1] <= lineStartExtremes[3]) {
// if (theExtremes[1] >= lineStartExtremes[1] && theExtremes[3] <= lineStartExtremes[3]) {
theNamesPath[theNamesPath.length - 1][0] = Math.min(theNamesPath[theNamesPath.length - 1][0], theExtremes[0]);
theNamesPath[theNamesPath.length - 1][1] = Math.min(theNamesPath[theNamesPath.length - 1][1], theExtremes[1]);
theNamesPath[theNamesPath.length - 1][2] = Math.max(theNamesPath[theNamesPath.length - 1][2], theExtremes[2]);
theNamesPath[theNamesPath.length - 1][3] = Math.max(theNamesPath[theNamesPath.length - 1][3], theExtremes[3]);
} else {
// new rectangle;
if (theExtremes[1] > lineStartExtremes[3] && theExtremes[3] > lineStartExtremes[3]) {
lineStartExtremes = theExtremes;
theNamesPath.push(theExtremes)
}
};
};
////////////////////////////////////
myDocument.resizeImage (new UnitValue (100/theScale, "%"), new UnitValue (100/theScale, "%"), undefined, ResampleMethod.NEARESTNEIGHBOR);
//alert (theNamesPath.join("\n\n"));
rectangularSelection (theNamesPath[0][0]/theScale, theNamesPath[0][1]/theScale, theNamesPath[0][2]/theScale, theNamesPath[0][3]/theScale, false, false);
for (var n = 0; n < theNamesPath.length; n++) {
rectangularSelection (theNamesPath[n][0]/theScale, theNamesPath[n][1]/theScale, theNamesPath[n][2]/theScale, theNamesPath[n][3]/theScale, true, false)
};
////////////////////////////////////
// reset;
app.preferences.rulerUnits = originalRulerUnits;
app.togglePalettes();
}
};
////// collect path info from actiondescriptor, indices start at 1, not 0 //////
function collectPathInfoFromDesc2023 (myDocument, thePath) {
var originalRulerUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.POINTS;
// based of functions from xbytor’s stdlib;
var idPath = charIDToTypeID( "Path" );
var ref = new ActionReference();
// check if thePath is an index or a dom-path;
if (thePath.constructor == Number) {
ref.putIndex(idPath, thePath)
}
else {
thePath.select();
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID( "Path" ), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
};
// get stuff;
var desc = app.executeActionGet(ref);
var pname = desc.getString(cTID('PthN'));
// create new array;
var theArray = new Array;
var pathComponents = desc.getObjectValue(cTID("PthC")).getList(sTID('pathComponents'));
// for subpathitems;
for (var m = 0; m < pathComponents.count; m++) {
var listKey = pathComponents.getObjectValue(m).getList(sTID("subpathListKey"));
var operation1 = pathComponents.getObjectValue(m).getEnumerationValue(sTID("shapeOperation"));
switch (operation1) {
case 1097098272:
var operation = 1097098272 //cTID('Add ');
break;
case 1398961266:
var operation = 1398961266 //cTID('Sbtr');
break;
case 1231975538:
var operation = 1231975538 //cTID('Intr');
break;
default:
// case 1102:
var operation = sTID('xor') //ShapeOperation.SHAPEXOR;
break;
};
// for subpathitem’s count;
for (var n = 0; n < listKey.count; n++) {
theArray.push(new Array);
var points = listKey.getObjectValue(n).getList(sTID('points'));
try {var closed = listKey.getObjectValue(n).getBoolean(sTID("closedSubpath"))}
catch (e) {var closed = false};
// for subpathitem’s segment’s number of points;
for (var o = 0; o < points.count; o++) {
var anchorObj = points.getObjectValue(o).getObjectValue(sTID("anchor"));
var anchor = [anchorObj.getUnitDoubleValue(sTID('horizontal')), anchorObj.getUnitDoubleValue(sTID('vertical'))];
var thisPoint = [anchor];
try {
var left = points.getObjectValue(o).getObjectValue(cTID("Fwd "));
var leftDirection = [left.getUnitDoubleValue(sTID('horizontal')), left.getUnitDoubleValue(sTID('vertical'))];
thisPoint.push(leftDirection)
}
catch (e) {
thisPoint.push(anchor)
};
try {
var right = points.getObjectValue(o).getObjectValue(cTID("Bwd "));
var rightDirection = [right.getUnitDoubleValue(sTID('horizontal')), right.getUnitDoubleValue(sTID('vertical'))];
thisPoint.push(rightDirection)
}
catch (e) {
thisPoint.push(anchor)
};
try {
var smoothOr = points.getObjectValue(o).getBoolean(cTID("Smoo"));
thisPoint.push(smoothOr)
}
catch (e) {thisPoint.push(false)};
theArray[theArray.length - 1].push(thisPoint);
};
theArray[theArray.length - 1].push(closed);
theArray[theArray.length - 1].push(operation);
};
};
// by xbytor, thanks to him;
function cTID (s) { return cTID[s] || cTID[s] = app.charIDToTypeID(s); };
function sTID (s) { return sTID[s] || sTID[s] = app.stringIDToTypeID(s); };
// reset;
app.preferences.rulerUnits = originalRulerUnits;
return theArray;
};
////// delete path by id //////
function deletePath (theID) {
var desc32 = new ActionDescriptor();
var ref9 = new ActionReference();
ref9.putIndex ( stringIDToTypeID( "path" ), theID );
desc32.putReference( stringIDToTypeID( "null" ), ref9 );
executeAction( stringIDToTypeID( "delete" ), desc32, DialogModes.NO );
};
////// load path as selection //////
function loadPathAsSelection (theIndex) {
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putProperty( charIDToTypeID( "Chnl" ), charIDToTypeID( "fsel" ) );
desc1.putReference( charIDToTypeID( "null" ), ref1 );
var ref2 = new ActionReference();
ref2.putIndex( charIDToTypeID( "Path" ), theIndex );
desc1.putReference( charIDToTypeID( "T " ), ref2 );
desc1.putInteger( charIDToTypeID( "Vrsn" ), 1 );
desc1.putBoolean( stringIDToTypeID( "vectorMaskParams" ), true );
executeAction( charIDToTypeID( "setd" ), desc1, DialogModes.NO );
};
////// determine selected path //////
function selectedPath2020 () {
try {
var ref = new ActionReference();
ref.putProperty (stringIDToTypeID("property"), stringIDToTypeID("targetPathIndex"));
ref.putEnumerated( charIDToTypeID("Dcmn"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
var docDesc = executeActionGet(ref);
var theIndex = docDesc.getInteger(stringIDToTypeID("targetPathIndex"))+1;
//
var ref = new ActionReference();
ref.putIndex( charIDToTypeID("Path"), theIndex);
var pathDesc = executeActionGet(ref);
var theKind = pathDesc.getEnumerationValue(stringIDToTypeID("kind"));
var theName = pathDesc.getString(stringIDToTypeID("pathName"));
//
return [theIndex, theKind, theName];
}
catch (e) {return undefined}
};
////// make work path from selection //////
function makeWorkPath2 (theTolerance) {
var idPath = charIDToTypeID( "Path" );
var idmake = stringIDToTypeID( "make" );
var idFrom = charIDToTypeID( "From" );
var idnull = stringIDToTypeID( "null" );
// =======================================================
var desc5 = new ActionDescriptor();
var ref3 = new ActionReference();
ref3.putClass( idPath );
desc5.putReference( idnull, ref3 );
var ref4 = new ActionReference();
ref4.putProperty( charIDToTypeID( "csel" ), charIDToTypeID( "fsel" ) );
desc5.putReference( idFrom, ref4 );
desc5.putUnitDouble( charIDToTypeID( "Tlrn" ), charIDToTypeID( "#Pxl" ), theTolerance );
executeAction( idmake, desc5, DialogModes.NO );
// =======================================================
var desc7 = new ActionDescriptor();
var ref3 = new ActionReference();
ref3.putClass( idPath );
desc7.putReference( idnull, ref3 );
var idfrom = stringIDToTypeID( "from" );
var ref4 = new ActionReference();
ref4.putProperty( idPath, stringIDToTypeID( "workPath" ) );
desc7.putReference( idFrom, ref4 );
desc7.putString( stringIDToTypeID( "name" ), Math.random() );
executeAction( idmake, desc7, DialogModes.NO );
try {
var ref = new ActionReference();
ref.putProperty (stringIDToTypeID("property"), stringIDToTypeID("targetPathIndex"));
ref.putEnumerated( charIDToTypeID("Dcmn"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
var docDesc = executeActionGet(ref);
var theIndex = docDesc.getInteger(stringIDToTypeID("targetPathIndex"))+1;
return [theIndex/*, theKind, theName*/];
}
catch (e) {return undefined}
};
////// function to get the date //////
function timeString () {
var now = new Date();
return now.getTime()
};
//////
function deselect () {
var desc5 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putProperty( stringIDToTypeID( "channel" ), stringIDToTypeID( "selection" ) );
desc5.putReference( stringIDToTypeID( "null" ), ref1 );
desc5.putEnumerated( stringIDToTypeID( "to" ), stringIDToTypeID( "ordinal" ), stringIDToTypeID( "none" ) );
executeAction( stringIDToTypeID( "set" ), desc5, DialogModes.NO );
};
////// x //////
function getSubPathItemExtremes (theArray) {
var theX1 = theArray[0][0][0];
var theX2 = theArray[0][0][0];
var theY1 = theArray[0][0][1];
var theY2 = theArray[0][0][1];
for (var m = 1; m < theArray.length - 2; m++) {
var theX1 = Math.min(theX1, theArray[m][0][0]);
var theX2 = Math.max(theX2, theArray[m][0][0]);
var theY1 = Math.min(theY1, theArray[m][0][1]);
var theY2 = Math.max(theY2, theArray[m][0][1]);
var theWidth = theX2 - theX1;
var theHeight = theY2 - theY1;
//alert ("number "+m+"\n"+theValue+"\n"+theWidth+"___"+theHeight)
};
return [theX1, theY1, theX2, theY2, theWidth, theHeight]
};
////// apply threshold //////
function applyThreshold (theValue) {
var desc232 = new ActionDescriptor();
desc232.putInteger( stringIDToTypeID( "level" ), theValue );
executeAction( stringIDToTypeID( "thresholdClassEvent" ), desc232, DialogModes.NO );
};
////// load channel as selection //////
function loadChannelAsSelection(theName, theInvert, theAdd) {
try {
var idchannel = stringIDToTypeID( "channel" );
if (theAdd == false || theAdd == undefined) {
var desc70 = new ActionDescriptor();
var ref9 = new ActionReference();
ref9.putProperty( idchannel, stringIDToTypeID( "selection" ) );
desc70.putReference( stringIDToTypeID( "null" ), ref9 );
var ref10 = new ActionReference();
ref10.putEnumerated( idchannel, idchannel, stringIDToTypeID( theName ) );
desc70.putReference( stringIDToTypeID( "to" ), ref10 );
desc70.putBoolean(charIDToTypeID("Invr"), theInvert);
executeAction( stringIDToTypeID( "set" ), desc70, DialogModes.NO );
} else {
var desc221 = new ActionDescriptor();
var ref5 = new ActionReference();
ref5.putEnumerated( idchannel, idchannel, stringIDToTypeID(theName) );
desc221.putReference( stringIDToTypeID( "null" ), ref5 );
desc221.putBoolean(charIDToTypeID("Invr"), theInvert);
var ref6 = new ActionReference();
ref6.putProperty( idchannel, stringIDToTypeID( "selection" ) );
desc221.putReference( stringIDToTypeID( "to" ), ref6 );
executeAction( stringIDToTypeID( "add" ), desc221, DialogModes.NO );
}
} catch (_error) {alert (_error)}
};
////// make a rectangular selection //////
function rectangularSelection (x1, y1, x2, y2, theAdd, theIntersect) {
if (theAdd == false || theAdd == undefined) {var idset = stringIDToTypeID( "set" )}
else {var idset = stringIDToTypeID( "addTo" )};
if (theIntersect == true) {var idset = stringIDToTypeID( "interfaceWhite" );};
var idpixelsUnit = stringIDToTypeID( "pixelsUnit" );
var desc16 = new ActionDescriptor();
var ref2 = new ActionReference();
ref2.putProperty( stringIDToTypeID( "channel" ), stringIDToTypeID( "selection" ) );
desc16.putReference( stringIDToTypeID( "null" ), ref2 );
var desc17 = new ActionDescriptor();
desc17.putUnitDouble( stringIDToTypeID( "top" ), idpixelsUnit, y1 );
desc17.putUnitDouble( stringIDToTypeID( "left" ), idpixelsUnit, x1 );
desc17.putUnitDouble( stringIDToTypeID( "bottom" ), idpixelsUnit, y2 );
desc17.putUnitDouble( stringIDToTypeID( "right" ), idpixelsUnit, x2 );
desc16.putObject( stringIDToTypeID( "to" ), stringIDToTypeID( "rectangle" ), desc17 );
if(theAdd == true) desc16.putEnumerated( stringIDToTypeID( "selectionModifier" ), stringIDToTypeID( "selectionModifierType" ), stringIDToTypeID( "addToSelection" ) );
executeAction( idset, desc16, DialogModes.NO );
};
////// polygonal lasso tool //////
function polygonalLassoTool (theArray, theSubtract, theAdd) {
if (theSubtract == false || theSubtract == undefined) {var idset = stringIDToTypeID( "set" )}
else {var idset = stringIDToTypeID( "subtractFrom" )};
if (theAdd == true) {var idset = stringIDToTypeID( "addTo" )};
var desc15 = new ActionDescriptor();
var ref2 = new ActionReference();
ref2.putProperty( stringIDToTypeID( "channel" ), stringIDToTypeID( "selection" ) );
desc15.putReference( stringIDToTypeID( "null" ), ref2 );
var desc16 = new ActionDescriptor();
var list2 = new ActionList();
for (var m = 0; m < theArray.length; m++) {
var desc17 = new ActionDescriptor();
var idpixelsUnit = stringIDToTypeID( "pixelsUnit" );
desc17.putUnitDouble( stringIDToTypeID( "horizontal" ), idpixelsUnit, theArray[m][0] );
desc17.putUnitDouble( stringIDToTypeID( "vertical" ), idpixelsUnit, theArray[m][1] );
list2.putObject( stringIDToTypeID( "paint" ), desc17 );
};
desc16.putList( stringIDToTypeID( "points" ), list2 );
desc15.putObject( stringIDToTypeID( "to" ), stringIDToTypeID( "polygon" ), desc16 );
var idantiAlias = stringIDToTypeID( "antiAlias" );
desc15.putBoolean( idantiAlias, false );
executeAction( idset, desc15, DialogModes.NO );
};
////// expand selection //////
function expandSelection (theValue) {
var idExpn = charIDToTypeID( "Expn" );
var desc5 = new ActionDescriptor();
var idBy = charIDToTypeID( "By " );
var idPxl = charIDToTypeID( "#Pxl" );
desc5.putUnitDouble( idBy, idPxl, theValue );
executeAction( idExpn, desc5, DialogModes.NO );
};
//////
function createSelectiveColorAdjustmentLayerAndThresholdAdjustmentLayer() {
// =======================================================
var desc7 = new ActionDescriptor();
var ref2 = new ActionReference();
ref2.putProperty( charIDToTypeID( "Clr " ), charIDToTypeID( "Clrs" ) );
desc7.putReference( charIDToTypeID( "null" ), ref2 );
executeAction( charIDToTypeID( "Rset" ), desc7, DialogModes.NO );
// =======================================================
var desc7 = new ActionDescriptor();
var ref5 = new ActionReference();
ref5.putEnumerated( charIDToTypeID( "Lyr " ), charIDToTypeID( "Ordn" ), charIDToTypeID( "Frwr" ) );
desc7.putReference( charIDToTypeID( "null" ), ref5 );
desc7.putBoolean( charIDToTypeID( "MkVs" ), false );
executeAction( charIDToTypeID( "slct" ), desc7, DialogModes.NO );
// =======================================================
var desc19 = new ActionDescriptor();
var ref6 = new ActionReference();
ref6.putClass( stringIDToTypeID( "adjustmentLayer" ) );
desc19.putReference( stringIDToTypeID( "null" ), ref6 );
var desc20 = new ActionDescriptor();
var desc21 = new ActionDescriptor();
desc21.putEnumerated( stringIDToTypeID( "presetKind" ), stringIDToTypeID( "presetKindType" ), stringIDToTypeID( "presetKindDefault" ) );
var idselectiveColor = stringIDToTypeID( "selectiveColor" );
desc20.putObject( stringIDToTypeID( "type" ), idselectiveColor, desc21 );
var idadjustmentLayer = stringIDToTypeID( "adjustmentLayer" );
desc19.putObject( stringIDToTypeID( "using" ), stringIDToTypeID( "adjustmentLayer" ), desc20 );
executeAction( stringIDToTypeID( "make" ), desc19, DialogModes.NO );
// =======================================================
var idcolors = stringIDToTypeID( "colors" );
var idcolorCorrection = stringIDToTypeID( "colorCorrection" );
var desc137 = new ActionDescriptor();
var ref18 = new ActionReference();
ref18.putEnumerated( stringIDToTypeID( "adjustmentLayer" ), stringIDToTypeID( "ordinal" ), stringIDToTypeID( "targetEnum" ) );
desc137.putReference( stringIDToTypeID( "null" ), ref18 );
var desc138 = new ActionDescriptor();
var list12 = new ActionList();
var desc139 = new ActionDescriptor();
desc139.putEnumerated( idcolors, idcolors, stringIDToTypeID( "magenta" ) );
desc139.putUnitDouble( stringIDToTypeID( "black" ), stringIDToTypeID( "percentUnit" ), 100.000000 );
list12.putObject( idcolorCorrection, desc139 );
var desc139 = new ActionDescriptor();
desc139.putEnumerated( idcolors, idcolors, stringIDToTypeID( "reds" ) );
desc139.putUnitDouble( stringIDToTypeID( "black" ), stringIDToTypeID( "percentUnit" ), 100.000000 );
list12.putObject( idcolorCorrection, desc139 );
var desc139 = new ActionDescriptor();
desc139.putEnumerated( idcolors, idcolors, stringIDToTypeID( "yellows" ) );
desc139.putUnitDouble( stringIDToTypeID( "black" ), stringIDToTypeID( "percentUnit" ), 100.000000 );
list12.putObject( idcolorCorrection, desc139 );
var desc139 = new ActionDescriptor();
desc139.putEnumerated( idcolors, idcolors, stringIDToTypeID( "greens" ) );
desc139.putUnitDouble( stringIDToTypeID( "black" ), stringIDToTypeID( "percentUnit" ), 100.000000 );
list12.putObject( idcolorCorrection, desc139 );
var desc139 = new ActionDescriptor();
desc139.putEnumerated( idcolors, idcolors, stringIDToTypeID( "blues" ) );
desc139.putUnitDouble( stringIDToTypeID( "black" ), stringIDToTypeID( "percentUnit" ), 100.000000 );
list12.putObject( idcolorCorrection, desc139 );
var desc139 = new ActionDescriptor();
desc139.putEnumerated( idcolors, idcolors, stringIDToTypeID( "cyans" ) );
desc139.putUnitDouble( stringIDToTypeID( "black" ), stringIDToTypeID( "percentUnit" ), 100.000000 );
list12.putObject( idcolorCorrection, desc139 );
var desc139 = new ActionDescriptor();
desc139.putEnumerated( idcolors, idcolors, stringIDToTypeID( "whites" ) );
desc139.putUnitDouble( stringIDToTypeID( "black" ), stringIDToTypeID( "percentUnit" ), -100.000000 );
list12.putObject( idcolorCorrection, desc139 );
var desc139 = new ActionDescriptor();
desc139.putEnumerated( idcolors, idcolors, stringIDToTypeID( "neutrals" ) );
desc139.putUnitDouble( stringIDToTypeID( "black" ), stringIDToTypeID( "percentUnit" ), -100.000000 );
list12.putObject( idcolorCorrection, desc139 );
var desc139 = new ActionDescriptor();
desc139.putEnumerated( idcolors, idcolors, stringIDToTypeID( "blacks" ) );
desc139.putUnitDouble( stringIDToTypeID( "black" ), stringIDToTypeID( "percentUnit" ), -100.000000 );
list12.putObject( idcolorCorrection, desc139 );
desc138.putList( idcolorCorrection, list12 );
desc138.putEnumerated( stringIDToTypeID( "method" ), stringIDToTypeID( "correctionMethod" ), stringIDToTypeID( "absolute" ) );
var idselectiveColor = stringIDToTypeID( "selectiveColor" );
desc137.putObject( stringIDToTypeID( "to" ), idselectiveColor, desc138 );
executeAction( stringIDToTypeID( "set" ), desc137, DialogModes.NO );
// =======================================================
var desc211 = new ActionDescriptor();
var ref25 = new ActionReference();
ref25.putClass( stringIDToTypeID( "adjustmentLayer" ) );
desc211.putReference( stringIDToTypeID( "null" ), ref25 );
var desc212 = new ActionDescriptor();
var desc213 = new ActionDescriptor();
desc213.putInteger( stringIDToTypeID( "level" ), 220 );
var idthresholdClassEvent = stringIDToTypeID( "thresholdClassEvent" );
desc212.putObject( stringIDToTypeID( "type" ), idthresholdClassEvent, desc213 );
var idadjustmentLayer = stringIDToTypeID( "adjustmentLayer" );
desc211.putObject( stringIDToTypeID( "using" ), idadjustmentLayer, desc212 );
executeAction( stringIDToTypeID( "make" ), desc211, DialogModes.NO );
};
////// x //////
function polygonalLassoToolFromPathArray (theArray, theSubtract, theAdd) {
for (var a = 0; a < theArray.length; a++) {
var thisOne = theArray[a];
var thisArray = new Array;
for (var k = 0; k < thisOne.length-2; k++){
thisArray.push(thisOne[k][0])
};
polygonalLassoTool(thisArray, theSubtract, theAdd);
};
};
////// use magic wand tool //////
function useMagicWand2022 (theCoord) {
var idnull = charIDToTypeID( "null" );
var idPxl = charIDToTypeID( "#Pxl" );
// select tool;
var desc2 = new ActionDescriptor();
var ref2 = new ActionReference();
ref2.putClass( stringIDToTypeID( "magicWandTool" ) );
desc2.putReference( idnull, ref2 );
desc2.putBoolean( stringIDToTypeID( "dontRecord" ), true );
desc2.putBoolean( stringIDToTypeID( "forceNotify" ), true );
executeAction( charIDToTypeID( "slct" ), desc2, DialogModes.NO );
// apply tool;
var desc2 = new ActionDescriptor();
var ref2 = new ActionReference();
ref2.putProperty( charIDToTypeID( "Chnl" ), charIDToTypeID( "fsel" ) );
desc2.putReference( idnull, ref2 );
var desc3 = new ActionDescriptor();
desc3.putUnitDouble( charIDToTypeID( "Hrzn" ), idPxl, theCoord[0] );
desc3.putUnitDouble( charIDToTypeID( "Vrtc" ), idPxl, theCoord[1] );
desc2.putObject( charIDToTypeID( "T " ), charIDToTypeID( "Pnt " ), desc3 );
desc2.putInteger( charIDToTypeID( "Tlrn" ), 30 );
desc2.putBoolean( charIDToTypeID( "AntA" ), true );
desc2.putBoolean( stringIDToTypeID("merged"), true);
executeAction( charIDToTypeID( "setd" ), desc2, DialogModes.NO );
};
////// fill black //////
function fillWithBlack (theColor) {
try {
var desc20 = new ActionDescriptor();
desc20.putEnumerated( stringIDToTypeID( "using" ), stringIDToTypeID( "fillContents" ), stringIDToTypeID( theColor ) );
desc20.putUnitDouble( stringIDToTypeID( "opacity" ), stringIDToTypeID( "percentUnit" ), 100.000000 );
desc20.putEnumerated( stringIDToTypeID( "mode" ), stringIDToTypeID( "blendMode" ), stringIDToTypeID( "normal" ) );
executeAction( stringIDToTypeID( "fill" ), desc20, DialogModes.NO );
} catch (e) {}
};
////// invert selection //////
function invertSelection () {
// =======================================================
executeAction( charIDToTypeID( "Invs" ), undefined, DialogModes.NO );
};