文章目录
- 1.插件界面
- 2.关键代码
- 2.1 曲线
- 2.2 滤色/叠底
- 2.3 黑&白
- 3.作者寄语
PS是一款栅格图像编辑软件,具有许多强大的功能,本文演示如何通过脚本实现曲线、滤色/叠底和黑&白相关功能,展示从互联网收集而来的一个小插件,供大家学习交流,请勿用于商业用途。
1.插件界面
本文界面是一系列功能的一部分,将逐步展示,但是功能界面是共同的,如下图所示:
2.关键代码
2.1 曲线
大家可通过源代码阅读,来掌握相关技巧,源代码如下:
//
//==================== Curves ==============
//
function Curves() {
// Make
function step1(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putClass(PSClass.AdjustmentLayer);
desc1.putReference(PSString.Null, ref1);
var desc2 = new ActionDescriptor();
var desc3 = new ActionDescriptor();
desc3.putEnumerated(PSString.presetKind, PSString.presetKindType, PSString.presetKindDefault);
desc2.putObject(PSKey.Type, PSClass.Curves, desc3);
desc1.putObject(PSKey.Using, PSClass.AdjustmentLayer, desc2);
executeAction(PSEvent.Make, desc1, dialogMode);
};
// Set
function step2(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putEnumerated(PSClass.Layer, PSType.Ordinal, PSEnum.Target);
desc1.putReference(PSString.Null, ref1);
var desc2 = new ActionDescriptor();
desc2.putString(PSKey.Name, "Burn");
desc1.putObject(PSKey.To, PSClass.Layer, desc2);
executeAction(PSEvent.Set, desc1, dialogMode);
};
// Invert
function step3(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
executeAction(PSEvent.Invert, undefined, dialogMode);
};
// Select
function step4(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putEnumerated(PSClass.Channel, PSClass.Channel, PSEnum.RGB);
desc1.putReference(PSString.Null, ref1);
desc1.putBoolean(PSKey.MakeVisible, false);
executeAction(PSEvent.Select, desc1, dialogMode);
};
// Set
function step5(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putEnumerated(PSClass.AdjustmentLayer, PSType.Ordinal, PSEnum.Target);
desc1.putReference(PSString.Null, ref1);
var desc2 = new ActionDescriptor();
desc2.putEnumerated(PSString.presetKind, PSString.presetKindType, PSString.presetKindCustom);
var list1 = new ActionList();
var desc3 = new ActionDescriptor();
var ref2 = new ActionReference();
ref2.putEnumerated(PSClass.Channel, PSClass.Channel, PSEnum.Composite);
desc3.putReference(PSClass.Channel, ref2);
var list2 = new ActionList();
var desc4 = new ActionDescriptor();
desc4.putDouble(PSKey.Horizontal, 0);
desc4.putDouble(PSKey.Vertical, 0);
list2.putObject(PSClass.Point, desc4);
var desc5 = new ActionDescriptor();
desc5.putDouble(PSKey.Horizontal, 165);
desc5.putDouble(PSKey.Vertical, 125);
list2.putObject(PSClass.Point, desc5);
var desc6 = new ActionDescriptor();
desc6.putDouble(PSKey.Horizontal, 255);
desc6.putDouble(PSKey.Vertical, 255);
list2.putObject(PSClass.Point, desc6);
desc3.putList(PSKey.Curve, list2);
list1.putObject(PSClass.CurvesAdjustment, desc3);
desc2.putList(PSKey.Adjustment, list1);
desc1.putObject(PSKey.To, PSClass.Curves, desc2);
executeAction(PSEvent.Set, desc1, dialogMode);
};
// Make
function step6(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putClass(PSClass.AdjustmentLayer);
desc1.putReference(PSString.Null, ref1);
var desc2 = new ActionDescriptor();
var desc3 = new ActionDescriptor();
desc3.putEnumerated(PSString.presetKind, PSString.presetKindType, PSString.presetKindDefault);
desc3.putBoolean(PSKey.Colorize, false);
desc2.putObject(PSKey.Type, PSClass.HueSaturation, desc3);
desc1.putObject(PSKey.Using, PSClass.AdjustmentLayer, desc2);
executeAction(PSEvent.Make, desc1, dialogMode);
};
// Create Clipping Mask
function step7(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putEnumerated(PSClass.Layer, PSType.Ordinal, PSEnum.Target);
desc1.putReference(PSString.Null, ref1);
executeAction(sTID('groupEvent'), desc1, dialogMode);
};
// Set
function step8(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putEnumerated(PSClass.AdjustmentLayer, PSType.Ordinal, PSEnum.Target);
desc1.putReference(PSString.Null, ref1);
var desc2 = new ActionDescriptor();
desc2.putEnumerated(PSString.presetKind, PSString.presetKindType, PSString.presetKindCustom);
var list1 = new ActionList();
var desc3 = new ActionDescriptor();
desc3.putInteger(PSKey.Hue, 0);
desc3.putInteger(PSKey.Start, -20);
desc3.putInteger(PSKey.Lightness, 0);
list1.putObject(PSClass.HueSatAdjustmentV2, desc3);
desc2.putList(PSKey.Adjustment, list1);
desc1.putObject(PSKey.To, PSClass.HueSaturation, desc2);
executeAction(PSEvent.Set, desc1, dialogMode);
};
// Set
function step9(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putEnumerated(PSClass.Layer, PSType.Ordinal, PSEnum.Target);
desc1.putReference(PSString.Null, ref1);
var desc2 = new ActionDescriptor();
desc2.putString(PSKey.Name, "Desatutare_Burn");
desc1.putObject(PSKey.To, PSClass.Layer, desc2);
executeAction(PSEvent.Set, desc1, dialogMode);
};
// Make
function step10(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putClass(PSClass.AdjustmentLayer);
desc1.putReference(PSString.Null, ref1);
var desc2 = new ActionDescriptor();
var desc3 = new ActionDescriptor();
desc3.putEnumerated(PSString.presetKind, PSString.presetKindType, PSString.presetKindDefault);
desc2.putObject(PSKey.Type, PSClass.Curves, desc3);
desc1.putObject(PSKey.Using, PSClass.AdjustmentLayer, desc2);
executeAction(PSEvent.Make, desc1, dialogMode);
};
// Select
function step11(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putEnumerated(PSClass.Channel, PSClass.Channel, PSEnum.RGB);
desc1.putReference(PSString.Null, ref1);
desc1.putBoolean(PSKey.MakeVisible, false);
executeAction(PSEvent.Select, desc1, dialogMode);
};
// Set
function step12(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putEnumerated(PSClass.Layer, PSType.Ordinal, PSEnum.Target);
desc1.putReference(PSString.Null, ref1);
var desc2 = new ActionDescriptor();
desc2.putString(PSKey.Name, "Dodge");
desc1.putObject(PSKey.To, PSClass.Layer, desc2);
executeAction(PSEvent.Set, desc1, dialogMode);
};
// Select
function step13(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putEnumerated(PSClass.Channel, PSClass.Channel, PSClass.Mask);
desc1.putReference(PSString.Null, ref1);
desc1.putBoolean(PSKey.MakeVisible, false);
executeAction(PSEvent.Select, desc1, dialogMode);
};
// Invert
function step14(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
executeAction(PSEvent.Invert, undefined, dialogMode);
};
// Select
function step15(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putEnumerated(PSClass.Channel, PSClass.Channel, PSEnum.RGB);
desc1.putReference(PSString.Null, ref1);
desc1.putBoolean(PSKey.MakeVisible, false);
executeAction(PSEvent.Select, desc1, dialogMode);
};
// Set
function step16(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putEnumerated(PSClass.AdjustmentLayer, PSType.Ordinal, PSEnum.Target);
desc1.putReference(PSString.Null, ref1);
var desc2 = new ActionDescriptor();
desc2.putEnumerated(PSString.presetKind, PSString.presetKindType, PSString.presetKindCustom);
var list1 = new ActionList();
var desc3 = new ActionDescriptor();
var ref2 = new ActionReference();
ref2.putEnumerated(PSClass.Channel, PSClass.Channel, PSEnum.Composite);
desc3.putReference(PSClass.Channel, ref2);
var list2 = new ActionList();
var desc4 = new ActionDescriptor();
desc4.putDouble(PSKey.Horizontal, 0);
desc4.putDouble(PSKey.Vertical, 0);
list2.putObject(PSClass.Point, desc4);
var desc5 = new ActionDescriptor();
desc5.putDouble(PSKey.Horizontal, 85);
desc5.putDouble(PSKey.Vertical, 125);
list2.putObject(PSClass.Point, desc5);
var desc6 = new ActionDescriptor();
desc6.putDouble(PSKey.Horizontal, 255);
desc6.putDouble(PSKey.Vertical, 255);
list2.putObject(PSClass.Point, desc6);
desc3.putList(PSKey.Curve, list2);
list1.putObject(PSClass.CurvesAdjustment, desc3);
desc2.putList(PSKey.Adjustment, list1);
desc1.putObject(PSKey.To, PSClass.Curves, desc2);
executeAction(PSEvent.Set, desc1, dialogMode);
};
// Make
function step17(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putClass(PSClass.AdjustmentLayer);
desc1.putReference(PSString.Null, ref1);
var desc2 = new ActionDescriptor();
var desc3 = new ActionDescriptor();
desc3.putEnumerated(PSString.presetKind, PSString.presetKindType, PSString.presetKindDefault);
desc3.putBoolean(PSKey.Colorize, false);
desc2.putObject(PSKey.Type, PSClass.HueSaturation, desc3);
desc1.putObject(PSKey.Using, PSClass.AdjustmentLayer, desc2);
executeAction(PSEvent.Make, desc1, dialogMode);
};
// Create Clipping Mask
function step18(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putEnumerated(PSClass.Layer, PSType.Ordinal, PSEnum.Target);
desc1.putReference(PSString.Null, ref1);
executeAction(sTID('groupEvent'), desc1, dialogMode);
};
// Select
function step19(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putEnumerated(PSClass.Channel, PSClass.Channel, PSEnum.RGB);
desc1.putReference(PSString.Null, ref1);
desc1.putBoolean(PSKey.MakeVisible, false);
executeAction(PSEvent.Select, desc1, dialogMode);
};
// Set
function step20(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putEnumerated(PSClass.Layer, PSType.Ordinal, PSEnum.Target);
desc1.putReference(PSString.Null, ref1);
var desc2 = new ActionDescriptor();
desc2.putString(PSKey.Name, "Saturate_Dodge");
desc1.putObject(PSKey.To, PSClass.Layer, desc2);
executeAction(PSEvent.Set, desc1, dialogMode);
};
// Set
function step21(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putEnumerated(PSClass.AdjustmentLayer, PSType.Ordinal, PSEnum.Target);
desc1.putReference(PSString.Null, ref1);
var desc2 = new ActionDescriptor();
desc2.putEnumerated(PSString.presetKind, PSString.presetKindType, PSString.presetKindCustom);
var list1 = new ActionList();
var desc3 = new ActionDescriptor();
desc3.putInteger(PSKey.Hue, 0);
desc3.putInteger(PSKey.Start, 20);
desc3.putInteger(PSKey.Lightness, 0);
list1.putObject(PSClass.HueSatAdjustmentV2, desc3);
desc2.putList(PSKey.Adjustment, list1);
desc1.putObject(PSKey.To, PSClass.HueSaturation, desc2);
executeAction(PSEvent.Set, desc1, dialogMode);
};
// Select
function step22(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putName(PSClass.Layer, "Burn");
desc1.putReference(PSString.Null, ref1);
desc1.putEnumerated(PSString.selectionModifier, PSString.selectionModifierType, PSString.addToSelectionContinuous);
desc1.putBoolean(PSKey.MakeVisible, false);
executeAction(PSEvent.Select, desc1, dialogMode);
};
// Make
function step23(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putClass(PSString.layerGroup);
desc1.putReference(PSString.Null, ref1);
var ref2 = new ActionReference();
ref2.putEnumerated(PSClass.Layer, PSType.Ordinal, PSEnum.Target);
desc1.putReference(PSKey.From, ref2);
executeAction(PSEvent.Make, desc1, dialogMode);
};
// Set
function step24(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putEnumerated(PSClass.Layer, PSType.Ordinal, PSEnum.Target);
desc1.putReference(PSString.Null, ref1);
var desc2 = new ActionDescriptor();
desc2.putString(PSKey.Name, "D&B_Curves");
desc1.putObject(PSKey.To, PSClass.Layer, desc2);
executeAction(PSEvent.Set, desc1, dialogMode);
};
// Select
function step25(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putName(PSClass.Layer, "Desatutare_Burn");
desc1.putReference(PSString.Null, ref1);
desc1.putBoolean(PSKey.MakeVisible, false);
executeAction(PSEvent.Select, desc1, dialogMode);
};
// Delete
function step26(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putEnumerated(PSClass.Channel, PSType.Ordinal, PSEnum.Target);
desc1.putReference(PSString.Null, ref1);
executeAction(PSEvent.Delete, desc1, dialogMode);
};
// Select
function step27(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putName(PSClass.Layer, "Saturate_Dodge");
desc1.putReference(PSString.Null, ref1);
desc1.putBoolean(PSKey.MakeVisible, false);
executeAction(PSEvent.Select, desc1, dialogMode);
};
// Delete
function step28(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putEnumerated(PSClass.Channel, PSType.Ordinal, PSEnum.Target);
desc1.putReference(PSString.Null, ref1);
executeAction(PSEvent.Delete, desc1, dialogMode);
};
// Select
function step29(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putName(PSClass.Layer, "Dodge");
desc1.putReference(PSString.Null, ref1);
desc1.putBoolean(PSKey.MakeVisible, false);
executeAction(PSEvent.Select, desc1, dialogMode);
};
// Select
function step30(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putClass(PSClass.PaintbrushTool);
desc1.putReference(PSString.Null, ref1);
executeAction(PSEvent.Select, desc1, dialogMode);
};
// Set
function step31(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putEnumerated(PSClass.Layer, PSType.Ordinal, PSEnum.Target);
desc1.putReference(PSString.Null, ref1);
var desc2 = new ActionDescriptor();
desc2.putEnumerated(PSKey.Color, PSKey.Color, PSEnum.Blue);
desc1.putObject(PSKey.To, PSClass.Layer, desc2);
executeAction(PSEvent.Set, desc1, dialogMode);
};
// Set
function step32(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putEnumerated(PSClass.Layer, PSType.Ordinal, PSEnum.Target);
desc1.putReference(PSString.Null, ref1);
var desc2 = new ActionDescriptor();
desc2.putEnumerated(PSKey.Color, PSKey.Color, PSEnum.Blue);
desc1.putObject(PSKey.To, PSClass.Layer, desc2);
executeAction(PSEvent.Set, desc1, dialogMode);
};
// Select
function step33(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putName(PSClass.Layer, "D&B_Curves");
desc1.putReference(PSString.Null, ref1);
desc1.putBoolean(PSKey.MakeVisible, false);
executeAction(PSEvent.Select, desc1, dialogMode);
};
// Set
function step34(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putEnumerated(PSClass.Layer, PSType.Ordinal, PSEnum.Target);
desc1.putReference(PSString.Null, ref1);
var desc2 = new ActionDescriptor();
desc2.putEnumerated(PSKey.Color, PSKey.Color, PSEnum.Blue);
desc1.putObject(PSKey.To, PSClass.Layer, desc2);
executeAction(PSEvent.Set, desc1, dialogMode);
};
step1(); // Make
step2(); // Set
step3(); // Invert
step4(); // Select
step5(); // Set
step6(); // Make
step7(); // Create Clipping Mask
step8(); // Set
step9(); // Set
step10(); // Make
step11(); // Select
step12(); // Set
step13(); // Select
step14(); // Invert
step15(); // Select
step16(); // Set
step17(); // Make
step18(); // Create Clipping Mask
step19(); // Select
step20(); // Set
step21(); // Set
step22(); // Select
step23(); // Make
step24(); // Set
step25(); // Select
step26(); // Delete
step27(); // Select
step28(); // Delete
step29(); // Select
step30(); // Select
step31(); // Set
step32(); // Set
step33(); // Select
step34(); // Set
};
cTID = function (s) {
return app.charIDToTypeID(s);
};
sTID = function (s) {
return app.stringIDToTypeID(s);
};
//
// Curves.loadSymbols
// Loading up the symbol definitions like this makes it possible
// to include several of these generated files in one master file
// provided a prefix is specified other than the default. It also
// skips the definitions if PSConstants has already been loaded.
//
Curves.loadSymbols = function () {
var dbgLevel = $.level;
$.level = 0;
try {
PSConstants;
return; // only if PSConstants is defined
} catch (e) {
} finally {
$.level = dbgLevel;
}
var needDefs = true;
$.level = 0;
try {
PSClass;
needDefs = false;
} catch (e) {
} finally {
$.level = dbgLevel;
}
if (needDefs) {
PSClass = function () {
};
PSEnum = function () {
};
PSEvent = function () {
};
PSForm = function () {
};
PSKey = function () {
};
PSType = function () {
};
PSUnit = function () {
};
PSString = function () {
};
}
// We may still end up duplicating some of the following definitions
// but at least we don't redefine PSClass, etc... and wipe out others
PSClass.AdjustmentLayer = cTID('AdjL');
PSClass.Channel = cTID('Chnl');
PSClass.ChannelMatrix = cTID('ChMx');
PSClass.ChannelMixer = cTID('ChnM');
PSClass.Curves = cTID('Crvs');
PSClass.CurvesAdjustment = cTID('CrvA');
PSClass.HueSatAdjustmentV2 = cTID('Hst2');
PSClass.HueSaturation = cTID('HStr');
PSClass.Layer = cTID('Lyr ');
PSClass.Mask = cTID('Msk ');
PSClass.PaintbrushTool = cTID('PbTl');
PSClass.Point = cTID('Pnt ');
PSEnum.Blue = cTID('Bl ');
PSEnum.Composite = cTID('Cmps');
PSEnum.Luminosity = cTID('Lmns');
PSEnum.Midtones = cTID('Mdtn');
PSEnum.RGB = cTID('RGB ');
PSEnum.RevealAll = cTID('RvlA');
PSEnum.Target = cTID('Trgt');
PSEvent.Delete = cTID('Dlt ');
PSEvent.Hide = cTID('Hd ');
PSEvent.Invert = cTID('Invr');
PSEvent.Make = cTID('Mk ');
PSEvent.Select = cTID('slct');
PSEvent.Set = cTID('setd');
PSEvent.Show = cTID('Shw ');
PSKey.Adjustment = cTID('Adjs');
PSKey.At = cTID('At ');
PSKey.Color = cTID('Clr ');
PSKey.Colorize = cTID('Clrz');
PSKey.Colors = cTID('Clrs');
PSKey.Constrain = cTID('Cnst');
PSKey.Curve = cTID('Crv ');
PSKey.From = cTID('From');
PSKey.Gray = cTID('Gry ');
PSKey.Green = cTID('Grn ');
PSKey.Horizontal = cTID('Hrzn');
PSKey.Hue = cTID('H ');
PSKey.Lightness = cTID('Lght');
PSKey.MakeVisible = cTID('MkVs');
PSKey.Mode = cTID('Md ');
PSKey.Monochromatic = cTID('Mnch');
PSKey.Name = cTID('Nm ');
PSKey.New = cTID('Nw ');
PSKey.Opacity = cTID('Opct');
PSKey.Radius = cTID('Rds ');
PSKey.Red = cTID('Rd ');
PSKey.Start = cTID('Strt');
PSKey.To = cTID('T ');
PSKey.Type = cTID('Type');
PSKey.Using = cTID('Usng');
PSKey.Vertical = cTID('Vrtc');
PSString.Null = sTID('null');
PSString.addToSelectionContinuous = sTID('addToSelectionContinuous');
PSString.layerGroup = sTID('layerSection');
PSString.presetKind = sTID('presetKind');
PSString.presetKindCustom = sTID('presetKindCustom');
PSString.presetKindDefault = sTID('presetKindDefault');
PSString.presetKindType = sTID('presetKindType');
PSString.selectionModifier = sTID('selectionModifier');
PSString.selectionModifierType = sTID('selectionModifierType');
PSType.BlendMode = cTID('BlnM');
PSType.Ordinal = cTID('Ordn');
PSType.UserMaskOptions = cTID('UsrM');
PSUnit.Percent = cTID('#Prc');
PSUnit.Pixels = cTID('#Pxl');
};
Curves.loadSymbols(); // load up our symbols
//=========================================
// Curves.main
//=========================================
//
Curves.main = function () {
Curves();
};
Curves.main();
// EOF
2.2 滤色/叠底
大家可通过源代码阅读,来掌握相关技巧,源代码如下:
//
// Generated Mon Sep 07 2015 11:26:20 GMT+0600
//
//
//==================== S+M ==============
//
function S_M() {
// Make
function step1(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putClass(PSClass.Layer);
desc1.putReference(PSString.Null, ref1);
executeAction(PSEvent.Make, desc1, dialogMode);
};
// Merge Visible
function step2(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
desc1.putBoolean(PSEvent.Duplicate, true);
executeAction(sTID('mergeVisible'), desc1, dialogMode);
};
// Set
function step3(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putEnumerated(PSClass.Layer, PSType.Ordinal, PSEnum.Target);
desc1.putReference(PSString.Null, ref1);
var desc2 = new ActionDescriptor();
desc2.putString(PSKey.Name, "Base S+M");
desc1.putObject(PSKey.To, PSClass.Layer, desc2);
executeAction(PSEvent.Set, desc1, dialogMode);
};
// Layer Via Copy
function step4(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
executeAction(sTID('copyToLayer'), undefined, dialogMode);
};
// Set
function step5(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putEnumerated(PSClass.Layer, PSType.Ordinal, PSEnum.Target);
desc1.putReference(PSString.Null, ref1);
var desc2 = new ActionDescriptor();
desc2.putEnumerated(PSKey.Mode, PSType.BlendMode, PSEnum.Multiply);
desc1.putObject(PSKey.To, PSClass.Layer, desc2);
executeAction(PSEvent.Set, desc1, dialogMode);
};
// Set
function step6(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putEnumerated(PSClass.Layer, PSType.Ordinal, PSEnum.Target);
desc1.putReference(PSString.Null, ref1);
var desc2 = new ActionDescriptor();
desc2.putString(PSKey.Name, "1 Multiply");
desc1.putObject(PSKey.To, PSClass.Layer, desc2);
executeAction(PSEvent.Set, desc1, dialogMode);
};
// Make
function step7(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
desc1.putClass(PSKey.New, PSClass.Channel);
var ref1 = new ActionReference();
ref1.putEnumerated(PSClass.Channel, PSClass.Channel, PSClass.Mask);
desc1.putReference(PSKey.At, ref1);
desc1.putEnumerated(PSKey.Using, PSType.UserMaskOptions, PSEnum.HideAll);
executeAction(PSEvent.Make, desc1, dialogMode);
};
// Layer Via Copy
function step8(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
executeAction(sTID('copyToLayer'), undefined, dialogMode);
};
// Set
function step9(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putEnumerated(PSClass.Layer, PSType.Ordinal, PSEnum.Target);
desc1.putReference(PSString.Null, ref1);
var desc2 = new ActionDescriptor();
desc2.putEnumerated(PSKey.Mode, PSType.BlendMode, PSEnum.Screen);
desc1.putObject(PSKey.To, PSClass.Layer, desc2);
executeAction(PSEvent.Set, desc1, dialogMode);
};
// Set
function step10(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putEnumerated(PSClass.Layer, PSType.Ordinal, PSEnum.Target);
desc1.putReference(PSString.Null, ref1);
var desc2 = new ActionDescriptor();
desc2.putString(PSKey.Name, "2 Screen");
desc1.putObject(PSKey.To, PSClass.Layer, desc2);
executeAction(PSEvent.Set, desc1, dialogMode);
};
// Select
function step11(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putName(PSClass.Layer, "Base S+M");
desc1.putReference(PSString.Null, ref1);
desc1.putBoolean(PSKey.MakeVisible, false);
executeAction(PSEvent.Select, desc1, dialogMode);
};
// Hide
function step12(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var list1 = new ActionList();
var ref1 = new ActionReference();
ref1.putEnumerated(PSClass.Layer, PSType.Ordinal, PSEnum.Target);
list1.putReference(ref1);
desc1.putList(PSString.Null, list1);
executeAction(PSEvent.Hide, desc1, dialogMode);
};
// Select
function step13(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putName(PSClass.Layer, "2 Screen");
desc1.putReference(PSString.Null, ref1);
desc1.putEnumerated(PSString.selectionModifier, PSString.selectionModifierType, PSString.addToSelectionContinuous);
desc1.putBoolean(PSKey.MakeVisible, false);
executeAction(PSEvent.Select, desc1, dialogMode);
};
// Make
function step14(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putClass(PSString.layerGroup);
desc1.putReference(PSString.Null, ref1);
var ref2 = new ActionReference();
ref2.putEnumerated(PSClass.Layer, PSType.Ordinal, PSEnum.Target);
desc1.putReference(PSKey.From, ref2);
executeAction(PSEvent.Make, desc1, dialogMode);
};
// Set
function step15(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putEnumerated(PSClass.Layer, PSType.Ordinal, PSEnum.Target);
desc1.putReference(PSString.Null, ref1);
var desc2 = new ActionDescriptor();
desc2.putString(PSKey.Name, "DB_Screen+Multiply");
desc1.putObject(PSKey.To, PSClass.Layer, desc2);
executeAction(PSEvent.Set, desc1, dialogMode);
};
// Set
function step16(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putEnumerated(PSClass.Layer, PSType.Ordinal, PSEnum.Target);
desc1.putReference(PSString.Null, ref1);
var desc2 = new ActionDescriptor();
desc2.putEnumerated(PSKey.Color, PSKey.Color, PSKey.Blue);
desc1.putObject(PSKey.To, PSClass.Layer, desc2);
executeAction(PSEvent.Set, desc1, dialogMode);
};
// Make
function step17(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
desc1.putClass(PSKey.New, PSClass.Channel);
var ref1 = new ActionReference();
ref1.putEnumerated(PSClass.Channel, PSClass.Channel, PSClass.Mask);
desc1.putReference(PSKey.At, ref1);
desc1.putEnumerated(PSKey.Using, PSType.UserMaskOptions, PSEnum.RevealAll);
executeAction(PSEvent.Make, desc1, dialogMode);
};
// Select
function step18(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putEnumerated(PSClass.Channel, PSClass.Channel, PSClass.Mask);
ref1.putName(PSClass.Layer, "2 Screen");
desc1.putReference(PSString.Null, ref1);
desc1.putBoolean(PSKey.MakeVisible, false);
executeAction(PSEvent.Select, desc1, dialogMode);
};
// Select
function step19(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putClass(PSClass.PaintbrushTool);
desc1.putReference(PSString.Null, ref1);
executeAction(PSEvent.Select, desc1, dialogMode);
};
// Select
function step20(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putName(PSClass.Layer, "Base S+M");
desc1.putReference(PSString.Null, ref1);
desc1.putBoolean(PSKey.MakeVisible, false);
executeAction(PSEvent.Select, desc1, dialogMode);
};
// Delete
function step21(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putEnumerated(PSClass.Layer, PSType.Ordinal, PSEnum.Target);
desc1.putReference(PSString.Null, ref1);
executeAction(PSEvent.Delete, desc1, dialogMode);
};
// Select
function step22(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putEnumerated(PSClass.Channel, PSClass.Channel, PSClass.Mask);
ref1.putName(PSClass.Layer, "2 Screen");
desc1.putReference(PSString.Null, ref1);
desc1.putBoolean(PSKey.MakeVisible, false);
executeAction(PSEvent.Select, desc1, dialogMode);
};
step1(); // Make
step2(); // Merge Visible
step3(); // Set
step4(); // Layer Via Copy
step5(); // Set
step6(); // Set
step7(); // Make
step8(); // Layer Via Copy
step9(); // Set
step10(); // Set
step11(); // Select
step12(); // Hide
step13(); // Select
step14(); // Make
step15(); // Set
step16(); // Set
step17(); // Make
step18(); // Select
step19(); // Select
step20(); // Select
step21(); // Delete
step22(); // Select
};
cTID = function(s) { return app.charIDToTypeID(s); };
sTID = function(s) { return app.stringIDToTypeID(s); };
//
// S_M.loadSymbols
// Loading up the symbol definitions like this makes it possible
// to include several of these generated files in one master file
// provided a prefix is specified other than the default. It also
// skips the definitions if PSConstants has already been loaded.
//
S_M.loadSymbols = function() {
var dbgLevel = $.level;
$.level = 0;
try {
PSConstants;
return; // only if PSConstants is defined
} catch (e) {
} finally {
$.level = dbgLevel;
}
var needDefs = true;
$.level = 0;
try {
PSClass;
needDefs = false;
} catch (e) {
} finally {
$.level = dbgLevel;
}
if (needDefs) {
PSClass = function() {};
PSEnum = function() {};
PSEvent = function() {};
PSForm = function() {};
PSKey = function() {};
PSType = function() {};
PSUnit = function() {};
PSString = function() {};
}
// We may still end up duplicating some of the following definitions
// but at least we don't redefine PSClass, etc... and wipe out others
PSClass.AdjustmentLayer = cTID('AdjL');
PSClass.Calculation = cTID('Clcl');
PSClass.Channel = cTID('Chnl');
PSClass.CurvesAdjustment = cTID('CrvA');
PSClass.Document = cTID('Dcmn');
PSClass.Invert = cTID('Invr');
PSClass.Layer = cTID('Lyr ');
PSClass.Mask = cTID('Msk ');
PSClass.PaintbrushTool = cTID('PbTl');
PSClass.Point = cTID('Pnt ');
PSClass.RGBColor = cTID('RGBC');
PSEnum.Backward = cTID('Bckw');
PSEnum.Black = cTID('Blck');
PSEnum.BlackAndWhite = cTID('BanW');
PSEnum.Composite = cTID('Cmps');
PSEnum.First = cTID('Frst');
PSEnum.Forward = cTID('Frwr');
PSEnum.Front = cTID('Frnt');
PSEnum.HideAll = cTID('HdAl');
PSEnum.Image = cTID('Img ');
PSEnum.Merged = cTID('Mrgd');
PSEnum.Multiply = cTID('Mltp');
PSEnum.No = cTID('N ');
PSEnum.Overlay = cTID('Ovrl');
PSEnum.RGB = cTID('RGB ');
PSEnum.RevealAll = cTID('RvlA');
PSEnum.Screen = cTID('Scrn');
PSEnum.Target = cTID('Trgt');
PSEnum.Yellow = cTID('Yllw');
PSEvent.Close = cTID('Cls ');
PSEvent.Curves = cTID('Crvs');
PSEvent.Delete = cTID('Dlt ');
PSEvent.Duplicate = cTID('Dplc');
PSEvent.Hide = cTID('Hd ');
PSEvent.Make = cTID('Mk ');
PSEvent.Move = cTID('move');
PSEvent.Select = cTID('slct');
PSEvent.Set = cTID('setd');
PSKey.Adjustment = cTID('Adjs');
PSKey.At = cTID('At ');
PSKey.Blue = cTID('Bl ');
PSKey.Color = cTID('Clr ');
PSKey.Curve = cTID('Crv ');
PSKey.Cyan = cTID('Cyn ');
PSKey.Dither = cTID('Dthr');
PSKey.From = cTID('From');
PSKey.Green = cTID('Grn ');
PSKey.Group = cTID('Grup');
PSKey.Horizontal = cTID('Hrzn');
PSKey.Intent = cTID('Inte');
PSKey.Magenta = cTID('Mgnt');
PSKey.MakeVisible = cTID('MkVs');
PSKey.MapBlack = cTID('MpBl');
PSKey.Mode = cTID('Md ');
PSKey.Name = cTID('Nm ');
PSKey.New = cTID('Nw ');
PSKey.Opacity = cTID('Opct');
PSKey.PreserveTransparency = cTID('PrsT');
PSKey.Radius = cTID('Rds ');
PSKey.Red = cTID('Rd ');
PSKey.Saving = cTID('Svng');
PSKey.ShadowMode = cTID('sdwM');
PSKey.To = cTID('T ');
PSKey.Type = cTID('Type');
PSKey.Using = cTID('Usng');
PSKey.Vertical = cTID('Vrtc');
PSKey.With = cTID('With');
PSString.Null = sTID('null');
PSString.addToSelection = sTID('addToSelection');
PSString.addToSelectionContinuous = sTID('addToSelectionContinuous');
PSString.layerGroup = sTID('layerSection');
PSString.presetKind = sTID('presetKind');
PSString.presetKindCustom = sTID('presetKindCustom');
PSString.presetKindDefault = sTID('presetKindDefault');
PSString.presetKindFactory = sTID('presetKindFactory');
PSString.presetKindType = sTID('presetKindType');
PSString.selectionModifier = sTID('selectionModifier');
PSString.selectionModifierType = sTID('selectionModifierType');
PSString.tintColor = sTID('tintColor');
PSString.useTint = sTID('useTint');
PSType.BlendMode = cTID('BlnM');
PSType.Ordinal = cTID('Ordn');
PSType.UserMaskOptions = cTID('UsrM');
PSType.YesNo = cTID('YsN ');
PSUnit.Percent = cTID('#Prc');
PSUnit.Pixels = cTID('#Pxl');
};
S_M.loadSymbols(); // load up our symbols
//=========================================
// S_M.main
//=========================================
//
S_M.main = function () {
S_M();
};
S_M.main();
// EOF
2.3 黑&白
大家可通过源代码阅读,来掌握相关技巧,源代码如下:
//
// Generated Thu Apr 30 2015 23:13:25 GMT+0600
//
//
//==================== Black & White ==============
//
function Black_White() {
// Make
function step1(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putClass(PSString.contentLayer);
desc1.putReference(PSString.Null, ref1);
var desc2 = new ActionDescriptor();
var desc3 = new ActionDescriptor();
var desc4 = new ActionDescriptor();
desc4.putDouble(PSEnum.Red, 127.998046875);
desc4.putDouble(PSEnum.Green, 127.998046875);
desc4.putDouble(PSEnum.Blue, 127.998046875);
desc3.putObject(PSKey.Color, PSClass.RGBColor, desc4);
desc2.putObject(PSKey.Type, PSString.solidColorLayer, desc3);
desc1.putObject(PSKey.Using, PSString.contentLayer, desc2);
executeAction(PSEvent.Make, desc1, dialogMode);
};
// Set
function step2(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putEnumerated(PSClass.Layer, PSType.Ordinal, PSEnum.Target);
desc1.putReference(PSString.Null, ref1);
var desc2 = new ActionDescriptor();
desc2.putEnumerated(PSKey.Color, PSKey.Color, PSEnum.Blue);
desc1.putObject(PSKey.To, PSClass.Layer, desc2);
executeAction(PSEvent.Set, desc1, dialogMode);
};
// Set
function step3(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putEnumerated(PSClass.Layer, PSType.Ordinal, PSEnum.Target);
desc1.putReference(PSString.Null, ref1);
var desc2 = new ActionDescriptor();
desc2.putString(PSKey.Name, "Black & White");
desc1.putObject(PSKey.To, PSClass.Layer, desc2);
executeAction(PSEvent.Set, desc1, dialogMode);
};
// Set
function step4(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putEnumerated(PSClass.Layer, PSType.Ordinal, PSEnum.Target);
desc1.putReference(PSString.Null, ref1);
var desc2 = new ActionDescriptor();
desc2.putEnumerated(PSKey.Mode, PSType.BlendMode, PSKey.Color);
desc1.putObject(PSKey.To, PSClass.Layer, desc2);
executeAction(PSEvent.Set, desc1, dialogMode);
};
// Select
function step5(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putEnumerated(PSClass.Channel, PSClass.Channel, PSClass.Mask);
desc1.putReference(PSString.Null, ref1);
desc1.putBoolean(PSKey.MakeVisible, false);
executeAction(PSEvent.Select, desc1, dialogMode);
};
// Delete
function step6(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putEnumerated(PSClass.Channel, PSType.Ordinal, PSEnum.Target);
desc1.putReference(PSString.Null, ref1);
executeAction(PSEvent.Delete, desc1, dialogMode);
};
step1(); // Make
step2(); // Set
step3(); // Set
step4(); // Set
step5(); // Select
step6(); // Delete
};
cTID = function (s) {
return app.charIDToTypeID(s);
};
sTID = function (s) {
return app.stringIDToTypeID(s);
};
//
// Black_White.loadSymbols
// Loading up the symbol definitions like this makes it possible
// to include several of these generated files in one master file
// provided a prefix is specified other than the default. It also
// skips the definitions if PSConstants has already been loaded.
//
Black_White.loadSymbols = function () {
var dbgLevel = $.level;
$.level = 0;
try {
PSConstants;
return; // only if PSConstants is defined
} catch (e) {
} finally {
$.level = dbgLevel;
}
var needDefs = true;
$.level = 0;
try {
PSClass;
needDefs = false;
} catch (e) {
} finally {
$.level = dbgLevel;
}
if (needDefs) {
PSClass = function () {
};
PSEnum = function () {
};
PSEvent = function () {
};
PSForm = function () {
};
PSKey = function () {
};
PSType = function () {
};
PSUnit = function () {
};
PSString = function () {
};
}
// We may still end up duplicating some of the following definitions
// but at least we don't redefine PSClass, etc... and wipe out others
PSClass.AdjustmentLayer = cTID('AdjL');
PSClass.Calculation = cTID('Clcl');
PSClass.Channel = cTID('Chnl');
PSClass.Curves = cTID('Crvs');
PSClass.CurvesAdjustment = cTID('CrvA');
PSClass.Layer = cTID('Lyr ');
PSClass.Mask = cTID('Msk ');
PSClass.Point = cTID('Pnt ');
PSClass.RGBColor = cTID('RGBC');
PSEnum.Blue = cTID('Bl ');
PSEnum.Composite = cTID('Cmps');
PSEnum.Green = cTID('Grn ');
PSEnum.HideAll = cTID('HdAl');
PSEnum.Luminosity = cTID('Lmns');
PSEnum.Merged = cTID('Mrgd');
PSEnum.Overlay = cTID('Ovrl');
PSEnum.RGB = cTID('RGB ');
PSEnum.Red = cTID('Rd ');
PSEnum.Target = cTID('Trgt');
PSEvent.Delete = cTID('Dlt ');
PSEvent.Desaturate = cTID('Dstt');
PSEvent.Make = cTID('Mk ');
PSEvent.Select = cTID('slct');
PSEvent.Set = cTID('setd');
PSKey.Adjustment = cTID('Adjs');
PSKey.At = cTID('At ');
PSKey.Color = cTID('Clr ');
PSKey.Curve = cTID('Crv ');
PSKey.Exposure = cTID('Exps');
PSKey.From = cTID('From');
PSKey.Horizontal = cTID('Hrzn');
PSKey.MakeVisible = cTID('MkVs');
PSKey.Mapping = cTID('Mpng');
PSKey.Mode = cTID('Md ');
PSKey.Name = cTID('Nm ');
PSKey.New = cTID('Nw ');
PSKey.Offset = cTID('Ofst');
PSKey.Opacity = cTID('Opct');
PSKey.Radius = cTID('Rds ');
PSKey.To = cTID('T ');
PSKey.Type = cTID('Type');
PSKey.Using = cTID('Usng');
PSKey.Vertical = cTID('Vrtc');
PSKey.With = cTID('With');
PSString.EXIF = sTID('EXIF');
PSString.Null = sTID('null');
PSString.OpenGLEnabled = sTID('openglEnabled');
PSString.PromptedForColorSetup = sTID('promptedForColorSetup');
PSString.RGBFloatColor = sTID('RGBFloatColor');
PSString.addKnotTool = sTID('addKnotTool');
PSString.addToSelectionContinuous = sTID('addToSelectionContinuous');
PSString.animationKey = sTID('animationKey');
PSString.askLayeredTIFF = sTID('askLayeredTIFF');
PSString.assetManagementEnabled = sTID('assetManagementEnabled');
PSString.autoCollapseDrawers = sTID('autoCollapseDrawers');
PSString.average = sTID('average');
PSString.blueFloat = sTID('blueFloat');
PSString.bucketTool = sTID('bucketTool');
PSString.cameraRaw = sTID('cameraRaw');
PSString.canvasBackgroundColors = sTID('canvasBackgroundColors');
PSString.canvasColorMode = sTID('canvasColorMode');
PSString.colorReplacementBrushTool = sTID('colorReplacementBrushTool');
PSString.colorSamplerTool = sTID('colorSamplerTool');
PSString.contentLayer = sTID('contentLayer');
PSString.convertKnotTool = sTID('convertKnotTool');
PSString.countTool = sTID('countTool');
PSString.cropTool = sTID('cropTool');
PSString.cursorCrosshair = sTID('cursorCrosshair');
PSString.cursorShape = sTID('cursorShape');
PSString.customShape = sTID('customShape');
PSString.customShapeTool = sTID('customShapeTool');
PSString.deleteKnotTool = sTID('deleteKnotTool');
PSString.directSelectTool = sTID('directSelectTool');
PSString.editLogItems = sTID('editLogItems');
PSString.ellipseTool = sTID('ellipseTool');
PSString.enableFontFallback = sTID('enableFontFallback');
PSString.excludeIntersection = sTID('excludeIntersection');
PSString.eyedropperTool = sTID('eyedropperTool');
PSString.flow = sTID('flow');
PSString.fontPreviewsSize = sTID('fontPreviewsSize');
PSString.freeformPenTool = sTID('freeformPenTool');
PSString.gammaCorrection = sTID('gammaCorrection');
PSString.gradientLayer = sTID('gradientLayer');
PSString.grayscaleFloat = sTID('grayscaleFloat');
PSString.greenFloat = sTID('greenFloat');
PSString.handTool = sTID('handTool');
PSString.historyLog = sTID('historyLog');
PSString.lassoTool = sTID('lassoTool');
PSString.layerGroup = sTID('layerSection');
PSString.lineTool = sTID('lineTool');
PSString.magicStampTool = sTID('magicStampTool');
PSString.magicWandTool = sTID('magicWandTool');
PSString.magneticLassoTool = sTID('magneticLassoTool');
PSString.marqueeEllipTool = sTID('marqueeEllipTool');
PSString.marqueeRectTool = sTID('marqueeRectTool');
PSString.marqueeSingleColumnTool = sTID('marqueeSingleColumnTool');
PSString.marqueeSingleRowTool = sTID('marqueeSingleRowTool');
PSString.maximizeCompatibility = sTID('maximizeCompatibility');
PSString.moveTool = sTID('moveTool');
PSString.newDocPresetPrintResolution = sTID('newDocPresetPrintResolution');
PSString.newDocPresetPrintScale = sTID('newDocPresetPrintScale');
PSString.newDocPresetScreenResolution = sTID('newDocPresetScreenResolution');
PSString.newDocPresetScreenScale = sTID('newDocPresetScreenScale');
PSString.opacityFloat = sTID('opacityFloat');
PSString.patchSelection = sTID('patchSelection');
PSString.pathComponentSelectTool = sTID('pathComponentSelectTool');
PSString.patternLayer = sTID('patternLayer');
PSString.pdf13 = sTID('pdf13');
PSString.pdf14 = sTID('pdf14');
PSString.pdf15 = sTID('pdf15');
PSString.pdf16 = sTID('pdf16');
PSString.pdf17 = sTID('pdf17');
PSString.pdfx1a2001 = sTID('pdfx1a2001');
PSString.pdfx1a2003 = sTID('pdfx1a2003');
PSString.pdfx32001 = sTID('pdfx32001');
PSString.pdfx32003 = sTID('pdfx32003');
PSString.penTool = sTID('penTool');
PSString.performance = sTID('performance');
PSString.photoFilter = sTID('photoFilter');
PSString.polySelTool = sTID('polySelTool');
PSString.polygonTool = sTID('polygonTool');
PSString.presetKind = sTID('presetKind');
PSString.presetKindCustom = sTID('presetKindCustom');
PSString.presetKindDefault = sTID('presetKindDefault');
PSString.presetKindType = sTID('presetKindType');
PSString.quickSelectTool = sTID('quickSelectTool');
PSString.rectangleTool = sTID('rectangleTool');
PSString.redEyeTool = sTID('redEyeTool');
PSString.redFloat = sTID('redFloat');
PSString.replace = sTID('replace');
PSString.resizePastePlace = sTID('resizePastePlace');
PSString.rotateTool = sTID('rotateTool');
PSString.roundedRectangleTool = sTID('roundedRectangleTool');
PSString.rulerTool = sTID('rulerTool');
PSString.saveHistoryTo = sTID('saveHistoryTo');
PSString.screenMode = sTID('screenMode');
PSString.screenModeFullScreen = sTID('screenModeFullScreen');
PSString.screenModeFullScreenWithMenubar = sTID('screenModeFullScreenWithMenubar');
PSString.screenModeStandard = sTID('screenModeStandard');
PSString.selectedItems = sTID('selectedItems');
PSString.selectionModifier = sTID('selectionModifier');
PSString.selectionModifierType = sTID('selectionModifierType');
PSString.shapeClass = sTID('shapeClass');
PSString.shapeburst = sTID('shapeburst');
PSString.showCJKFeatures = sTID('showCJKFeatures');
PSString.showFontPreviews = sTID('showFontPreviews');
PSString.showMenuColors = sTID('showMenuColors');
PSString.sliceSelectTool = sTID('sliceSelectTool');
PSString.sliceTool = sTID('sliceTool');
PSString.smartQuotes = sTID('smartQuotes');
PSString.solidColorLayer = sTID('solidColorLayer');
PSString.spotHealingBrushTool = sTID('spotHealingBrushTool');
PSString.subsample = sTID('subsample');
PSString.textAnnotTool = sTID('textAnnotTool');
PSString.toolPreset = sTID('toolPreset');
PSString.typeCreateMaskTool = sTID('typeCreateMaskTool');
PSString.typeCreateOrEditTool = sTID('typeCreateOrEditTool');
PSString.typeUnits = sTID('typeUnits');
PSString.typeVerticalCreateMaskTool = sTID('typeVerticalCreateMaskTool');
PSString.typeVerticalCreateOrEditTool = sTID('typeVerticalCreateOrEditTool');
PSString.workingCMYK = sTID('workingCMYK');
PSString.workingRGB = sTID('workingRGB');
PSString.zoomTool = sTID('zoomTool');
PSString.zoomWithScrollWheel = sTID('zoomWithScrollWheel');
PSType.BlendMode = cTID('BlnM');
PSType.Ordinal = cTID('Ordn');
PSType.UserMaskOptions = cTID('UsrM');
PSUnit.Percent = cTID('#Prc');
PSUnit.Pixels = cTID('#Pxl');
};
Black_White.loadSymbols(); // load up our symbols
//=========================================
// Black_White.main
//=========================================
//
Black_White.main = function () {
Black_White();
};
Black_White.main();
// EOF
3.作者寄语
合理的脚本代码可以有效的提高工作效率,减少重复劳动。
欢迎光临知了软件开发网络平台,本公司定制开发各类软件,主要方向为桌面专业软件开发、插件定制开发、微信小程序(各类小程序)、网站定制开发和App开发,桌面软件主要包括文字图形识别类软件,信息管理类软件,3D打印类软件,视频类软件以及其它涉及专业的各类图形图像处理软件。插件包含AE插件,AI插件,PS插件,PDF插件,3DMAX插件以及Word,Excel等Office插件开发。详情请咨询,微信QQ:312117271,手机:18928899728,邮箱: anjingzhi_sea@163.com.
公司网址:http://www.zhiliaos.com