1

さまざまなレイヤーを循環する Photoshop Javascript スクリプトがあり、レイヤーの名前に基づいて各レイヤーに異なる外側の輝きを与えたいと考えています。

ArtLayer クラスのブレンディング オプションをプログラムで変更する方法の例を教えてください。

4

1 に答える 1

2

残念ながら、レイヤー スタイルを簡単に追加する方法はありません。

ありますが.applyStyle("Puzzle (Image)")、他のスタイルはドキュメントに含まれておらず、他のスタイルはどこにも見つかりませんでした。

そのため、回避策 (トリッキーで複雑なプロセス) を使用する必要があります。

ステップ 1 (すぐに解決したい場合はスキップしてください)

まず、アクション (外側のグローをレイヤーに追加) を行い、.jsx スクリプトに変換する必要があります。

変換には次のスクリプトを使用する必要があります: http://ps-scripts.cvs.sourceforge.net/viewvc/ps-scripts/xtools/apps/ActionToJavascript.jsx?revision=1.29

Ps または ExtendScript から実行し、アクションを選択して保存します。

ステップ2

新しく作成したスクリプトでは、恐ろしく判読できないコードが表示されますが、すぐに機能しますが、別の設定 (色、不透明度、ブレンド モードなど) を使用する場合は、関数を作成する必要があります。

こちらがクリーンバージョンです。

cTID = function(s){ return app.charIDToTypeID(s); };
sTID = function(s){ return app.stringIDToTypeID(s); };
// Add Style: Glow
function addStyleGlow( R, G, B, blendingMode, opacity, spread, size ){
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putProperty(cTID('Prpr'), cTID('Lefx'));
ref1.putEnumerated(cTID('Lyr '), cTID('Ordn'), cTID('Trgt'));
desc1.putReference(cTID('null'), ref1);
var desc2 = new ActionDescriptor();
desc2.putUnitDouble(cTID('Scl '), cTID('#Prc'), 100);
// Glow color
var desc4 = new ActionDescriptor();
var rgb = new Array();
desc4.putDouble(cTID('Rd  '), R);
desc4.putDouble(cTID('Grn '), G);
desc4.putDouble(cTID('Bl  '), B);
// Blending mode of the effect
var desc3 = new ActionDescriptor();
desc3.putBoolean(cTID('enab'), true);
desc3.putEnumerated( cTID('Md  '), cTID('BlnM'), cTID(blendingMode) );
desc3.putObject(cTID('Clr '), sTID("RGBColor"), desc4);
// Opacity
desc3.putUnitDouble(cTID('Opct'), cTID('#Prc'), opacity);
desc3.putEnumerated(cTID('GlwT'), cTID('BETE'), cTID('SfBL'));
// Spread
desc3.putUnitDouble(cTID('Ckmt'), cTID('#Pxl'), spread);
// Size
desc3.putUnitDouble(cTID('blur'), cTID('#Pxl'), size);
// Noise
desc3.putUnitDouble(cTID('Nose'), cTID('#Prc'), 0);
// Quality: Jitter
desc3.putUnitDouble(cTID('ShdN'), cTID('#Prc'), 0);
desc3.putBoolean(cTID('AntA'), true);
var desc5 = new ActionDescriptor();
desc5.putString(cTID('Nm  '), "Linear");
desc3.putObject(cTID('TrnS'), cTID('ShpC'), desc5);
// Quality: Range
desc3.putUnitDouble(cTID('Inpr'), cTID('#Prc'), 50);
desc2.putObject(cTID('OrGl'), cTID('OrGl'), desc3);
desc1.putObject(cTID('T   '), cTID('Lefx'), desc2);
executeAction(cTID('setd'), desc1, DialogModes.NO);
}; // End of Add Style: Glow

ステップ 3

その関数を呼び出すには、別のスクリプト ファイルが必要です。同じフォルダーに配置します (「antoxa_myGlow.jsx」をスクリプト名に置き換えます)。

//@include "antoxa_myGlow.jsx"
// R, G, B, blend mode, opacity, spread, size
addStyleGlow(255, 255, 54, 'Nrml', 75, 0, 5);

現在、選択した 1 つのレイヤーでのみ機能します。複数のレイヤーを選択すると、エラーが発生します。選択した複数のレイヤーに関数を適用する方法はまだわかりません。

于 2011-10-11T09:31:12.690 に答える