//20201206-Photoshop jsx常用模块封装

本文分享了Photoshop中JavaScript(jsx)的常用模块封装方法,通过模块化提高代码复用性和维护性,适用于进行批量处理和自动化工作流程。
摘要由CSDN通过智能技术生成
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]
    }
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值