일러스트 스크립트
직선 및 곡선을 그리는 일러스트레이터 스크립트
illustscript
2024. 7. 31. 13:01
직선, 꼭지점이 여러개인 선, 하트를 그리는 일러스트레이터 스크립트
//heart.jsx
//https://illustscript.tistory.com
//선을 그리는 일러스트레이터 스크립트
var title = "heart";
var mm = 2.83464566929134;
var noColor = new NoColor();
var myBlue = new CMYKColor();
myBlue.black = 0;
myBlue.cyan = 100;
myBlue.magenta = 0;
myBlue.yellow = 0;
var myRed = new CMYKColor();
myRed.black = 0;
myRed.cyan = 0;
myRed.magenta = 100;
myRed.yellow = 0;
var myYellow = new CMYKColor();
myYellow.black = 0;
myYellow.cyan = 0;
myYellow.magenta = 0;
myYellow.yellow = 100;
if(app.documents.length == 0){
alert("문서를 열어주세요");
}
else{
var docRef = activeDocument;
drawSingleline();
drawLongline();
drawHeart();
}
function drawSingleline(){
var path = docRef.pathItems.add();
var pos1 = [100, -300];
var pos2 = [200, -400];
path.setEntirePath([pos1, pos2]);
path.fillColor=noColor;
path.stroked=true;
path.strokeWidth=1*mm;
path.strokeColor=myBlue;
}
function drawLongline(){
var path = docRef.pathItems.add();
var pos1 = [500, -110];
var pos2 = [500, -200];
var pos3 = [620, -320];
var dot = new Array();
dot[0] = path.pathPoints.add();
dot[0].anchor = pos1;
dot[0].leftDirection = dot[0].anchor;
dot[0].rightDirection = dot[0].anchor;
dot[0].pointType = PointType.CORNER;
dot[1] = path.pathPoints.add();
dot[1].anchor = pos2;
dot[1].leftDirection = dot[1].anchor;
dot[1].rightDirection = dot[1].anchor;
dot[1].pointType = PointType.CORNER;
dot[2] = path.pathPoints.add();
dot[2].anchor = pos3
dot[2].leftDirection = dot[2].anchor;
dot[2].rightDirection = dot[2].anchor;
dot[2].pointType = PointType.CORNER;
path.fillColor=noColor;
path.stroked=true;
path.strokeWidth=1*mm;
path.strokeColor=myYellow;
}
function drawHeart(){
var path = docRef.pathItems.add();
var pos0 = [200, -200];
var pos1 = [300, -300];
var pos2 = [400, -200];
var pos3 = [350, -150];
var pos3_left = [400, -150];
var pos3_right = [300, -150];
var pos4 = [300, -200];
var pos5 = [250, -150];
var pos5_left = [300, -150];
var pos5_right = [200, -150];
var dot = new Array();
dot[0] = path.pathPoints.add();
dot[0].anchor = pos0;
dot[0].leftDirection = dot[0].anchor;
dot[0].rightDirection = dot[0].anchor;
dot[0].pointType = PointType.CORNER;
dot[1] = path.pathPoints.add();
dot[1].anchor = pos1;
dot[1].leftDirection = dot[1].anchor;
dot[1].rightDirection = dot[1].anchor;
dot[1].pointType = PointType.CORNER;
dot[2] = path.pathPoints.add();
dot[2].anchor = pos2;
dot[2].leftDirection = dot[2].anchor;
dot[2].rightDirection = dot[2].anchor;
dot[2].pointType = PointType.CORNER;
dot[3] = path.pathPoints.add();
dot[3].anchor = pos3;
dot[3].leftDirection = pos3_left;
dot[3].rightDirection = pos3_right;
dot[3].pointType = PointType.CORNER;
dot[4] = path.pathPoints.add();
dot[4].anchor = pos4;
dot[4].leftDirection = dot[4].anchor;
dot[4].rightDirection = dot[4].anchor;
dot[4].pointType = PointType.CORNER;
dot[5] = path.pathPoints.add();
dot[5].anchor = pos5;
dot[5].leftDirection = pos5_left;
dot[5].rightDirection = pos5_right;
dot[5].pointType = PointType.CORNER;
dot[6] = path.pathPoints.add();
dot[6].anchor = pos0;
dot[6].leftDirection = dot[6].anchor;
dot[6].rightDirection = dot[6].anchor;
dot[6].pointType = PointType.CORNER;
path.fillColor=noColor;
path.stroked=true;
path.strokeWidth=1*mm;
path.strokeColor=myRed;
}
결과