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
关注
打赏
热门博文
- Adobe illustrator插件开发-SPInterfaceSuite-插件A向插件B传递消息-插件通信-AI插件开发
- javascript-ztree-树形控件-初始化-加载节点数据-节点数据获取
- Adobe illustrator插件开发-坐标系统-AIHardSoftSuite-画板坐标-页面坐标-AI插件开发
- Adobe illustrator插件开发-AIUIDUtilsSuite-AIUIDPoolSuite-AIUIDSuite-AIUIDREFSuite-Art唯一标识符与索引-AI插件开发
- C++-逆向分析-类的成员函数地址与对象地址动态绑定-this指针-成员函数和成员虚函数反汇编解析
- C++-逆向分析-结构体和类-内存布局-this指针-静态数据成员-对象作为参数和返回值
- Adobe illustrator插件开发-命令名称-AddCommand -AI插件开发
- Adobe illustrator插件开发-事件-PlugPlugAddEventListener-向系统注册事件-AI插件开发
- Adobe illustrator插件开发-ole拖拽粘贴交换数据格式-RegisterClipboardFormat函数-AI插件开发
- Adobe illustrator插件开发-所有模块列表-内部存在大量非公开的Suite-AI插件开发