scriptographer

Hector:などでおなじみJürg Lehni(ヨーグ・レーニ)が公開してるillustratorのプラグイン。javascriptで書けるってのに、なんでもっと情報がないんだろ。学校とかでも教えてくれないかな。存在は知ってたものの、openstudioで初めて使ってみて、その絶大な効果を思い知らされました。

画像

僕の環境だと古いバージョン(0.5)でしか使えなかった(新しいバージョンだと起動できない)んだけど、見よう見まねでコードを書いて作ってみた。simple.jsをちょっと書き換えただけ。誰でもできるし、Math.sin()とかにどんな値が渡されてるかとか全然気にしてない...。もうちょっとちゃんとドキュメント読んで研究します。

Scriptographer.com

適当なテキストファイルに下のソースコードをコピー&ペーストして拡張子を.jsにして保存してtoolsフォルダに入れて使ってみて下さい。

art.pointsToCurves(tolerance, thresh, 10.0, 10.0);
の行頭に//つけてコメントアウトしたりするとカチッとした線になったり。

function init() {
    size = 50;
    tolerance = 25;
    thresh = 10;
}

function options() {
    values = prompt("Radius:", 
        {type: "number", value: size, 
         title: "size", width: 50},
        {type: "number", value: tolerance, 
         title: "tolerance", width: 50},
        {type: "number", value: thresh, 
         title: "thresh", width: 50}
    );
    if (values != null) {
        size = values[0];
        tolerance = values[1];
        thresh = values[2];
    }
}

function mouseDown(event) {
    art = new Art("path");
}

function mouseUp(event) {
    art.pointsToCurves(tolerance, thresh, 10.0, 10.0);
}

function mouseDrag(event) {
    var point = event.point;
    art.segments.push(point.add(size * 
    (Math.cos(point.x)), size * Math.sin(point.y)));
}