illustrator 弧線工具?illustrator是矢量編輯軟件,畫闆是繪制處理的重要容器,在印刷方面的一個重要功能就是顔色處理,開發一個随機填充顔色功能,以下功能僅用于學習交流,請勿用于非法用途和商業用途,源代碼如下所示:,我來為大家講解一下關于illustrator 弧線工具?跟着小編一起來看一看吧!
illustrator是矢量編輯軟件,畫闆是繪制處理的重要容器,在印刷方面的一個重要功能就是顔色處理,開發一個随機填充顔色功能,以下功能僅用于學習交流,請勿用于非法用途和商業用途,源代碼如下所示:
len = app.activeDocument.selection.length;
gradAlert = 0;
strokes = false;
if (len == 0) {
alert("Please select one or more objects. Grouped objects will not be affected.");
} else {
ob = app.activeDocument.selection;
var line1 = "1. 要随機填充色,輸入1-100的數值(數值越大,明度越小) ";
var line2 = "2.要随機輪廓色,輸入1-100的數值并以英文“S”結尾(數值越大,明度越大) ";
var line3 = "3.要随機不透明度,輸入1-100的最小值和最大值,如30,100 ";
var data = prompt(line1 line2 line3, "");
if (data == null || data.length == 0) {
} else {
if (data.indexOf(",") > 0) {
action = data.split(",");
} else {
action = data.split(" ");
}
if (action[action.length - 1] == "s") {
action.length = action.length - 1;
strokes = true;
}
if (action[action.length - 1].charAt(action[action.length - 1].length - 1) == "s") {
action[action.length - 1] = action[action.length - 1].substr(0, action[action.length - 1].length - 1);
strokes = true;
}
var baseVal = action[0];
for (var j = 0; j < len; j = 1) {
if (isNumber(action[0]) && isNumber(action[1]) && action.length == 2) {
calcNum = (action[0] * 1) (Math.random(1) * (action[1] - action[0]));
ob[j].opacity = setLegal(calcNum);
} else if (isNumber(action[0], 255) && action.length == 1) {
if (app.activeDocument.documentColorSpace == "DocumentColorSpace.RGB") {
action[0] = Math.round(baseVal * 2.55);
}
if (strokes == false) {
if (ob[j].filled == true) {
setColor(ob[j].fillColor, setLegal(action[0], 255));
}
} else {
if (ob[j].stroked == true) {
setColor(ob[j].strokeColor, setLegal(action[0], 255));
}
}
} else {
j = len;
error(action[0]);
}
}
}
}
function error(val) {
alert(val " 數值與腳本不符,應控制在1-100之間!");
}
function isNumber(num, max) {
if (max == undefined) {
max = 100;
}
if (num >= 0 && num <= max) {
return true;
}
return false;
}
function setLegal(num, max) {
if (max == undefined) {
max = 100;
}
if (num < 0) {
return -num % max;
} else if (num > max) {
return max - (num % max);
} else {
return num;
}
}
function setColor(obj, dev) {
var d = Math.round(Math.random(1) * dev);
if (obj == undefined) {
} else if (obj.typename == "RGBColor") {
d = Math.round(Math.random(1) * dev);
var r = obj.red;
obj.red = setLegal((r - dev) (d * 2), 255);
d = Math.round(Math.random(1) * dev);
var g = obj.green;
obj.green = setLegal((g - dev) (d * 2), 255);
d = Math.round(Math.random(1) * dev);
var b = obj.blue;
obj.blue = setLegal((b - dev) (d * 2), 255);
} else if (obj.typename == "SpotColor") {
var d = Math.round(Math.random(1) * dev);
var t = obj.tint;
obj.tint = setLegal((t - dev) (d * 2), 100);
} else if (obj.typename == "GrayColor") {
var d = Math.round(Math.random(1) * dev);
var t = obj.gray;
obj.gray = setLegal((t - dev) (d * 2), 100);
} else if (obj.typename == "CMYKColor") {
d = Math.round(Math.random(1) * dev);
var c = obj.cyan;
obj.cyan = setLegal((c - dev) (d * 2), 100);
d = Math.round(Math.random(1) * dev);
var m = obj.magenta;
obj.magenta = setLegal((m - dev) (d * 2), 100);
d = Math.round(Math.random(1) * dev);
var y = obj.yellow;
obj.yellow = setLegal((y - dev) (d * 2), 100);
d = Math.round(Math.random(1) * dev);
var k = obj.black;
obj.black = setLegal((k - dev) (d * 2), 100);
} else {
if (gradAlert != 1 && obj.typename == "PatternColor" || obj.typename == "GradientColor") {
gradAlert = 1;
alert("Patterns and Gradients will not be transformed.");
}
}
}
合理的腳本代碼可以有效地提高工作效率,減少重複勞動。
文章引用至 作者聯系方式
,更多精彩资讯请关注tft每日頭條,我们将持续为您更新最新资讯!