ps_key_class = {
/*
Application
notifiter
preferences
document
layers
art layers
text item(Object)
layer sets
layer set
art layer
selection
path item 路径
sub path item
path point
channel
layer comp
count item
color sampler
measurement scale
document info
history state
save options
Photoshop
BMP
DIF
EPS
JPEG
PDF
Pict File
PNG
TIFF
...
solid color
RGB color
CMYK color
Gray color
HSB color
Lab color
No color
*/}
// macOS类
Mac = function () {
this.font = app.fonts
this.systemInformation = app.systemInformation
this.answer = function answer() {
answer = confirm("Set the foreground and background to my favorite colors?") //确认弹框(选择yes or none)
if (answer) {
//command
}
}
}
//Photoshop类
Ps = function () {
// 属性
//ps自身相关信息
this.name = app.name
this.version = app.version
this.memorySize = parseInt(app.freeMemory / (1024 * 1024)) + "MB\r\r" //可用内存
this.path = app.path.fsName //不使用fsName会有乱码
this.language = app.language
this.rulerUnits = app.preferences.rulerUnits //ps标尺
this.isQuicktimeAvailable = app.isQuicktimeAvailable //是否支持quciktime
this.colorSettings = app.colorSettings
this.displayDialogs = app.displayDialogs //警告弹窗
this.macintoshFileTypes = app.macintoshFileTypes //ps支持打开的文档类型列表
//文件
this.open = function openFile(filePath) {
// var filePath = "/Users/luomingyang/Luo_MingYang/Example/eg_jpg.jpg"
var file = new File(filePath) //文件夹是Folder
open(file)
return true
}
// app.openDialog() //文件选择弹框
//文档
this.recentFiles = app.recentFiles //列表
this.docs = app.documents
this.activeDocument = app.activeDocument //如果没有打开的文件,则会报异常
this.length = app.documents.length //当前ps的文档数目
//工具栏
this.currentTool = app.currentTool //当前选中的工具
//拾色器
this.foregroundColor = app.foregroundColor
this.backgroundColor = app.backgroundColor //返回 solodcolor
//方法
//rgb 颜色模式的色值
this.rgbColor = function rgbColor(red, green, blue) {
red = typeof red !== 'undefined' ? red : app.foregroundColor.rgb.red
green = typeof green !== 'undefined' ? green : app.foregroundColor.rgb.green
blue = typeof blue !== 'undefined' ? blue : app.foregroundColor.rgb.blue
var rgbColor = new SolidColor().rgb // 实例化颜色对象
rgbColor.red = red
rgbColor.green = green
rgbColor.blue = blue
// return { 'red': red, 'green': green, 'blue': blue }
return [red, green, blue]
}
//20201206-Photoshop jsx常用模块封装
最新推荐文章于 2023-03-29 18:52:05 发布
本文分享了Photoshop中JavaScript(jsx)的常用模块封装方法,通过模块化提高代码复用性和维护性,适用于进行批量处理和自动化工作流程。
摘要由CSDN通过智能技术生成