文章目录
PS是一款栅格图像编辑软件,具有许多强大的功能,本文演示如何通过脚本实现晕影动态和选区相关功能,展示从互联网收集而来的一个小插件,供大家学习交流,请勿用于商业用途。
1.插件界面
本文界面是一系列功能的一部分,将逐步展示,但是功能界面是共同的,如下图所示:
2.关键代码
2.1 选区
大家可通过源代码阅读,来掌握相关技巧,源代码如下:
var idslct = charIDToTypeID("slct");
var desc18 = new ActionDescriptor();
var idnull = charIDToTypeID("null");
var ref15 = new ActionReference();
var idmarqueeEllipTool = stringIDToTypeID("marqueeEllipTool");
ref15.putClass(idmarqueeEllipTool);
desc18.putReference(idnull, ref15);
var iddontRecord = stringIDToTypeID("dontRecord");
desc18.putBoolean(iddontRecord, true);
var idforceNotify = stringIDToTypeID("forceNotify");
desc18.putBoolean(idforceNotify, true);
executeAction(idslct, desc18, DialogModes.NO);
2.2 动态晕影
大家可通过源代码阅读,来掌握相关技巧,源代码如下:
win = new Window("dialog", "动态不透明度");
win.orientation = "column";
leftGr = win.add("group");
baton10 = leftGr.add("group");
leftGr.orientation = "column";
sliderGroup26 = leftGr.add("group");
sliderGroup26.orientation = "row";
sliderGroup26.alignChildren = ["fill", "fill"];
slTxt = sliderGroup26.add("staticText", undefined, "0");
slider6 = sliderGroup26.add("slider", undefined, 50, 0, 100);
slider6.preferredSize.width = 240;
sliderValue6 = sliderGroup26.add("statictext", undefined, " 50 ");
slider6.onChanging = function() {
sliderValue6.text = Math.round(this.value);
};
slider6.onChange = function() {
foo66 = Math.round(this.value);
var idslct = charIDToTypeID("slct");
var desc37 = new ActionDescriptor();
var idnull = charIDToTypeID("null");
var ref16 = new ActionReference();
var idLyr = charIDToTypeID("Lyr ");
ref16.putName(idLyr, "Vignette");
desc37.putReference(idnull, ref16);
var idMkVs = charIDToTypeID("MkVs");
desc37.putBoolean(idMkVs, false);
executeAction(idslct, desc37, DialogModes.NO);
var idsetd = charIDToTypeID("setd");
var desc18 = new ActionDescriptor();
var idnull = charIDToTypeID("null");
var ref10 = new ActionReference();
var idLyr = charIDToTypeID("Lyr ");
var idOrdn = charIDToTypeID("Ordn");
var idTrgt = charIDToTypeID("Trgt");
ref10.putEnumerated(idLyr, idOrdn, idTrgt);
desc18.putReference(idnull, ref10);
var idT = charIDToTypeID("T ");
var desc19 = new ActionDescriptor();
var idOpct = charIDToTypeID("Opct");
var idPrc = charIDToTypeID("#Prc");
desc19.putUnitDouble(idOpct, idPrc, foo66);
var idLyr = charIDToTypeID("Lyr ");
desc18.putObject(idT, idLyr, desc19);
executeAction(idsetd, desc18, DialogModes.NO);
app.refresh();
};
closeBtn = leftGr.add("button", undefined, "关闭");
closeBtn.preferredSize.width = 270;
close = false;
closeBtn.onClick = function() {
close = true;
win.close();
};
win.onClose = function() {
close = true;
};
win.show();
while (close === false) {
app.refresh();
}
3.作者寄语
合理的脚本代码可以有效的提高工作效率,减少重复劳动。
欢迎光临知了软件开发网络平台,本公司定制开发各类软件,主要方向为桌面专业软件开发、插件定制开发、微信小程序(各类小程序)、网站定制开发和App开发,桌面软件主要包括文字图形识别类软件,信息管理类软件,3D打印类软件,视频类软件以及其它涉及专业的各类图形图像处理软件。插件包含AE插件,AI插件,PS插件,PDF插件,3DMAX插件以及Word,Excel等Office插件开发。详情请咨询,微信QQ:312117271,手机:18928899728,邮箱: anjingzhi_sea@163.com.
公司网址:http://www.zhiliaos.com