Mod: Generative Design / P_2_0_01
書けそうだったのでこれまでのPDF保存などの基本構造をベースに書いた.元のサンプルコードと比較してみるとアルゴリズムはかなりトレース出来たことが確認できた.
コード
import processing.pdf.*; import java.util.Calendar; boolean savePDF = false; void setup() { size(960, 540); colorMode(HSB, 360, 100, 100); } void draw() { if (savePDF) { beginRecord(PDF, timestamp()+".pdf"); } background(0, 0, 100); translate(width/2, height/2); int separation = (int) map(mouseY, 0, height, 2, 60); float len = abs(mouseX-width/2); strokeWeight(separation/2); strokeCap(SQUARE); for (int i = 0; i < separation; i++) { float theta = map(i, 0, separation, 0, PI*2); pushMatrix(); rotate(theta); line(0, len, 0, 0); popMatrix(); } if (savePDF) { savePDF = false; endRecord(); } } void keyPressed() { if (key=='s' || key=='S') saveFrame(timestamp()+"_##.png"); if (key=='p' || key=='P') savePDF = true; } String timestamp() { Calendar now = Calendar.getInstance(); return String.format("%1$ty%1$tm%1$td_%1$tH%1$tM%1$tS", now); }