LoginSignup
0
1

More than 5 years have passed since last update.

photoshopのjsxをプロトタイプで簡潔に。

Last updated at Posted at 2018-11-17

フォトショップのjsxはprototypeで簡潔に書く事ができます。

以下、サンプルです。(座標とカラーだけ指定すれば、描画できるプロトタイプを宣言しています。)

参考サイト:http://www.openspc2.org/book/PhotoshopCC/





//プロトタイプで描画を宣言する
function Draw() {}
Draw.prototype.bark =
//x1〜y4まで→座標、R,G,B→RGBでカラー指定
function (x1,y1,x2,y2,x3,y3,x4,y4,R,G,B) {
//単位をピクセルにする
 preferences.rulerUnits = Units.PIXELS
//画像のサイズを取得
  const w = activeDocument.width;
  const h = activeDocument.height;

  RGBColor = new SolidColor();
  RGBColor.red    = R;
  RGBColor.green  = G;
  RGBColor.blue   = B;
  selReg = [[w-x1,h-y1],[w-x2,h-y2],[w-x3,h-y3],[w-x4,h-y4]];
activeDocument.selection.select(selReg);
activeDocument.selection.fill(RGBColor,ColorBlendMode.NORMAL, 100, false);
activeDocument.selection.deselect();
}

//インスタンスで座標とRGBだけ指定すれば描画できる。
draw = new Draw;
draw.bark(10,10,10,0,0,0,0,10,25,54,47)

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1