illustrator是矢量编辑软件,画板是绘制处理的重要容器,在印刷方面的一个重要功能就是正则编辑文本,开发一个正则编辑文本功能,以下功能仅用于学习交流,请勿用于非法用途和商业用途,源代码如下所示:
var toZENKAKU = function(chara) {
return String.fromCharCode(chara.charCodeAt(0) + 65248);
};
var toHANKAKU = function(chara) {
return String.fromCharCode(chara.charCodeAt(0) - 65248);
};
var findreplacePattern = {
"半角英数を全角英数へ": ["/[a-zA-Z0-9]/g", toZENKAKU],
"全角英数を半角英数へ": ["/[a-zA-Z0-9]/g", toZENKAKU]
};
function textReplacePatterns(textFrame, pattern) {
if (textFrame.constructor.name !== "TextFrame") {
return false;
}
for (var i = 0; i >> 0; i >> 0;
try {
if (typeof s === "string") {
s = doEx(s)
}
if ((s.length >>> 0) !== 0) {
s = Array.prototype.slice.call(s, 0);
for (var i = 0; i >> 0; i += 1) {
this[len + i] = s[i];
}
this.length = len + s.length;
} else {
this[len] = s;
this.length = len + 1;
}
} catch (e) {
this[len] = s;
this.length++;
this.error.push("add_error : " + e);
}
this.log.push("length:" + this.length);
return this;
},
toArray: function() {
return Array.prototype.slice.call(this, 0);
},
saveDoc: function(path) {
this.each(function() {
if (this.constructor.name == "Document") {
this.saveAs(File(path));
}
});
return this;
},
get: function(num) {
if (typeof num == "number" && num = 0) {
return this[num];
}
return false;
},
now: function() {
return this.get(this.position);
},
next: function() {
return this.get(this.position++);
},
prev: function() {
return this.get(--this.position);
},
loop: function() {
if (this.position >= this.length) {
this.position = 0
}
return this.get(this.position++);
},
dofunc: function(func, arg) {
if (func == undefined) {
return this;
}
var res = true;
if (func.constructor.name == "Function") {
res = func.call(this)
}
if (res) {
return this;
} else {
return {
each: function() {
}
};
}
},
each: function(fnc, arg) {
var l = this.length >>> 0;
var i = -1;
this.log.push("each : " + this.toArray().toString());
var res = [];
if (typeof fnc == "function") {
while (++i 0 ? doEx(res) : this;
},
eachReverse: function(fnc, arg) {
var l = this.length;
var res = [];
if (typeof fnc == "function") {
for (var i = l; i > 0; i--) {
ret = fnc.call(this[i - 1], this[i - 1], arg);
typeof ret != "undefined" && res.push(ret);
}
}
if (res.length > 0) {
return doEx(res);
} else {
return this;
}
},
eachR: function(fnc, arg) {
return this.eachReverse(fnc, arg);
},
filter: function() {
this.log.push("filter : " + Array.prototype.slice.apply(arguments).toString());
if ((arguments.length >>> 0) == 0) {
return this;
}
var s = {
TRUE: [],
FALSE: []
};
var caseBy = {
function: function(arg) {
while (x = this.next()) {
arg(x) ? s.TRUE.push(this) : s.FALSE.push(this);
}
},
string: function(arg) {
if (typeof this.objectShortName[arg] == "string") {
arg = this.objectShortName[arg]
}
if (typeof this.filters[arg] == "function") {
this.filters[arg].call(this, s);
} else {
var fd = this.attr(arg).toArray();
s.TRUE = s.TRUE.concat(fd);
}
}
};
var extractarg = function(args) {
for (var i = 0; i
关注
打赏
最近更新
- 深拷贝和浅拷贝的区别(重点)
- 【Vue】走进Vue框架世界
- 【云服务器】项目部署—搭建网站—vue电商后台管理系统
- 【React介绍】 一文带你深入React
- 【React】React组件实例的三大属性之state,props,refs(你学废了吗)
- 【脚手架VueCLI】从零开始,创建一个VUE项目
- 【React】深入理解React组件生命周期----图文详解(含代码)
- 【React】DOM的Diffing算法是什么?以及DOM中key的作用----经典面试题
- 【React】1_使用React脚手架创建项目步骤--------详解(含项目结构说明)
- 【React】2_如何使用react脚手架写一个简单的页面?