Photoshop脚本 设置前景色和背景色
源自:http://coolketang.com/tutorials/menu1lesson8.php
本節(jié)將演示如何使用腳本,設(shè)置Photoshop的前景色和背景色。首先創(chuàng)建一個(gè)空白的腳本文檔,并保存在硬盤(pán)上某個(gè)位置。
并輸入腳本代碼:
var answer = confirm("您需要隨機(jī)設(shè)置前景色和背景色嗎?");[confirm]命令會(huì)彈出一個(gè)包含[是/否]的確認(rèn)框,由用戶決定是否執(zhí)行某一個(gè)操作。
選擇的結(jié)果[是/否]將保存在[answer]變量里。
if(answer) {app.foregroundColor.rgb.red = Math.random() * 255;app.foregroundColor.rgb.green = Math.random() * 255;app.foregroundColor.rgb.blue = Math.random() * 255;app.backgroundColor.rgb.red = Math.random() * 255;app.backgroundColor.rgb.green = Math.random() * 255;app.backgroundColor.rgb.blue = Math.random() * 255; }
判斷用戶的選擇,如果用戶選擇[是],則執(zhí)行接下來(lái)的動(dòng)作。
然后就可以設(shè)置Photoshop前景色和背景色了。
[Math.random]命令會(huì)生成一個(gè)0至1之間的隨機(jī)值,隨機(jī)值乘以255則生成0-255之間的隨機(jī)值。
完整的腳本文件:
var answer = confirm("您需要隨機(jī)設(shè)置前景色和背景色嗎?");if(answer) {app.foregroundColor.rgb.red = Math.random() * 255;app.foregroundColor.rgb.green = Math.random() * 255;app.foregroundColor.rgb.blue = Math.random() * 255;app.backgroundColor.rgb.red = Math.random() * 255;app.backgroundColor.rgb.green = Math.random() * 255;app.backgroundColor.rgb.blue = Math.random() * 255; }我們的腳本已經(jīng)編寫(xiě)完成,現(xiàn)在把它保存下來(lái)。
然后切換到Photoshop,然后依次點(diǎn)擊[文件] > [腳本] > [瀏覽],打開(kāi)剛剛保存的腳本文件。Photoshop將直接調(diào)用并執(zhí)行該腳本。
在彈出的[腳本警告]彈出框窗口,點(diǎn)擊[是]按鈕,開(kāi)始設(shè)置前景色和背景色,請(qǐng)留意工具條下方前景色和背景色的變化。
總結(jié)
以上是生活随笔為你收集整理的Photoshop脚本 设置前景色和背景色的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: B/S 开发和 C/S开发的区别
- 下一篇: Hadoop学习之SSH免密登录配置(以