手机
当前位置:查字典教程网 >平面设计 >Illustrator教程 >AI脚本建立点到点的连线教程
AI脚本建立点到点的连线教程
摘要:这篇教程像查字典教程网的AI爱好者们介绍用AI脚本建立点到点的连线这个脚本是将对象上能互相连接的点做一个连接。示例如图:连接之后类似于曼陀罗...

这篇教程像查字典教程网的AI爱好者们介绍用AI脚本建立点到点的连线这个脚本是将对象上能互相连接的点做一个连接。示例如图:

AI脚本建立点到点的连线教程1

连接之后类似于曼陀罗的形状。在多边形、星型或者手绘图形上也试试吧。

点最好多一些,这样能得到更好的形状;较少的点可能没有什么变化。

要用“文件-脚本”来使用,以CS3为例应放在"C:Program FilesAdobeAdobe Illustrator CS3预设脚本"下。

当然,也可以放置在其他文件夹中,通过Ctrl+F12定位到脚本所在处来使用。

复制以下全部文字到记事本中,保存为以.js结尾的脚本文件(如:脚本.js)即可。

复制代码代码如下://///////////////////////////////////////////////////////////////

// All Points v.1.3 -- CS,CS2,CS3,CS4

//>=--------------------------------------

// This script simply draws a line from every point to every other point of your selected pathitem.

// Handy for making Mandalas. Try on polygons, stars or even freehand shapes.

//>=--------------------------------------

// JS code (c) copyright: John Wundes ( john@wundes.com ) www.wundes.com

//copyright full text here: http://www.wundes.com/js4ai/copyright.txt

//////////////////////////////////////////////////////////////////

function Loadbar(x){

this.versionNum= app.version.split(".")[0] ;

if (this.versionNum >= 13){

this.w = new Window('window', "Processing...", undefined, {independent:true});

this.w.frameLocation = [600,400];

this.w.tracker = this.w.add ('statictext' , [15,15,250,35], "processing");

this.w.prog = this.w.add ('progressbar' , [15,15,250,35], 0, x);

//this.w.show();

}

}

Loadbar.prototype.close = function(){

if (this.versionNum >= 13){

this.w.close();

}

}

Loadbar.prototype.hide=function(){

if (this.versionNum >= 13){

this.w.hide();

}

}

Loadbar.prototype.show=function(){

if (this.versionNum >= 13){

this.w.show();

}

}

Loadbar.prototype.update=function(x){

if (this.versionNum >= 13){

this.w.prog.value = x;

}

}

Loadbar.prototype.label=function(x){

if (this.versionNum >= 13){

this.w.tracker.text = x;

}

}

Array.prototype.indexOf = function(i){

var len = this.length;

for (var a=0;a{

if (this[a]==i)

{

return a;

}

return -1;

}

}

Array.prototype.man = function(test, tvars_arr, doThis, dovars_arr) {

var FUN="function";

var OBJ="object";

var UND="undefined";

var a=typeof test;

var b=typeof tvars_arr;

var c=typeof doThis;

var d=typeof dovars_arr;

// if only an array is given, it is assumed we wish to copy to it:

if (a==OBJ && tvars_arr ==undefined && doThis==undefined && dovars_arr==undefined)

{

dovars_arr = test;

test=undefined;

}

//if we just want to process all items without any testing: doThis,[dovars_arr] fun,ob

if (a==FUN && b==OBJ && doThis==undefined && dovars_arr==undefined)

{

//alert("correct");

doThis=test;

test=undefined;

dovars_arr=tvars_arr;

tvars_arr=undefined;

}else if(a==FUN && b==FUN){ // fun,fun OR fun,fun,ob

if (c==OBJ)

{

dovars_arr=doThis;

}

doThis=tvars_arr;

tvars_arr=undefined;

}

// Either case should work as normal: fun,ob,fun OR fun,ob,fun,ob

// Now set defaults if anything is missing:

test= test==undefined?AMT_exists:test;

tvars_arr= tvars_arr==undefined?[0]:tvars_arr;

doThis= doThis==undefined?AMA_exportTo:doThis;

dovars_arr= dovars_arr==undefined?[0]:dovars_arr;

//

var sl = this.length;

for (var ds = 0; ds<(sl-1); ds++) {

//first referenced function call

if (test(this[ds], tvars_arr)) {

// second referenced function call

var ret = doThis(this[ds], dovars_arr);

//change original array item if something is returned

if (ret != undefined) {

this[ds] = ret;

}

}

}

}

//DEFAULT TEST:

function AMT_exists(item, y_arr) {

//filler function for arrayMan

//always true

return 1;

}

//DEFAULT ACTION:

// exports each tested item to exp_arr

function AMA_exportTo(item, exp_arr) {

//alert(item);

exp_arr.unshift(item); //unshift because the array is being processed backwards.

}

function AMA_LinesTo(item, vars_arr) {

var count = vars_arr[0];

var group = vars_arr[1];

var src_arr = vars_arr[2];

var sal = src_arr.length;

// draw a line from this point, to every remaining point in the array

if (count == sal-1)

{

//alert("last one");

return

}

//

for (var p=(count+1);p<sal></sal>{

var myLine = drawLine(item.anchor, src_arr[p].anchor);

/* // uncomment for some fun grayscale action

var col=255/(sal/(count+1));

myLine.strokeColor.red = col;

myLine.strokeColor.green= col;

myLine.strokeColor.blue = col;

*/

b.update(p);

b.label("Item:"+(s+1)+" of "+selLen+". (node "+count+" of "+(sal-1)+")");

//redraw();

//alert("drawing count:"+count+"nindex of "+item+" in:"+src_arr+":"+src_arr.indexOf(item));

}

vars_arr[0]++; //note: count++ doesnt work

}

function drawLine(anchor1,anchor2) {

//alert(anchor1+" and "+anchor2);

//draw a single line from point a to point b

var linePath = shapeGroup.pathItems.add();

var offset=0; // [anchor1[0]-offset,anchor1[1]-offset]

linePath.setEntirePath( Array(anchor1,anchor2) );

linePath.closed = false;

linePath.stroked = true;

linePath.filled = false;

linePath.strokeWidth = 1;

return linePath;

}

//----------------main

alert0="请打开一个文档";

alert1="只能对单一对象生效!n不能是剪切蒙版、复合路径、复合形状、群组等!";

if ( app.documents.length == 0 ) {

alert(alert0);

}else if (app.activeDocument.selection.length == 0){

alert(alert1);

}else if (app.activeDocument.selection[0].typename != "PathItem"){

alert(alert1);

}else{

doc=activeDocument;

sel=doc.selection;

selLen=sel.length;

// walk through each selected item

for (var s=0;s<sellen></sellen>{

if (sel[s].typename == "PathItem")

{

var b = new Loadbar(sel[s].selectedPathPoints.length);

b.show();

var obj = sel[s];

var src_arr = obj.selectedPathPoints;

var count = 0;

var shapeGroup = app.activeDocument.groupItems.add();

src_arr.man(AMA_LinesTo,[count,shapeGroup,src_arr]);

b.close();

}

}

}

【AI脚本建立点到点的连线教程】相关文章:

Illustrator绘制立体效果的蜗牛教程

AI CS3模仿绘制矢量效果的荷花插画实例教程

AI绘制出四方连续图案实例教程

AI打造野马跑车实例教程

AI制作QuickTime Logo教程

AI绘制立体保龄球瓶教程

Illustrator实例绘制逼真质感的红绸缎

AI绘制精美圣诞花环教程

AI制作漂亮的线条效果文字

AI快速制作眼球教程

精品推荐
分类导航