0
0

More than 1 year has passed since last update.

vistaでillustrator その6

Posted at

概要

vistaでillustratorやってみる。
アートボード作って、コッホ曲線書いて、png出力してみた。

写真

ill5.png

サンプルコード

var v = [];
var ANGLE = 0;
var LX = 10;
var LY = 100;
function fmod(a, b) {
    var x = Math.floor(a / b);
    return a - b * x;
}
function turn(a) {
    ANGLE = fmod(ANGLE + a, 360.0);
}
function gmove(l) {
    var rd = Math.PI / 180.0;
    var x = l * Math.cos(rd * ANGLE);
    var y = -l * Math.sin(rd * ANGLE);
    var px = LX;
    var py = LY;
    LX += x;
    LY += y;
    v.push([LX, LY]);
}
function koch(i) {
    if (i <= 1)
    {
        gmove(5);
        return;
    }
    koch(i - 1);
    turn(-60);
    koch(i - 1);
    turn(120);
    koch(i - 1);
    turn(-60);
    koch(i - 1);
}
koch(5);
var docRef = documents.add(DocumentColorSpace.RGB, 400, 400);
var lineColor = new RGBColor();
lineColor.red = 255;
lineColor.green = 0;
lineColor.blue = 0;
var line = activeDocument.pathItems.add();
line.filled = false;
line.strokeColor = lineColor;
line.setEntirePath(v);
var pngOpt = new ExportOptionsPNG24();
pngOpt.artBoardClipping = true;
var filePath = new File("/Users/ore/ill5.png");
activeDocument.exportFile(filePath, ExportType.PNG24, pngOpt);
alert("ok");




以上。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0