random_rotate_lines04
boolean flag; void setup() { size(500, 500); colorMode(HSB, 360, 100, 100, 100); background(0, 0, 100); smooth(); frameRate(6); flag = false; strokeWeight(1); } void draw() { int xstep = 10; int ystep = 50; float lastx = -999; float lasty = -999; float ynoise = random(10); float ny; background(0, 0, 100, 2); translate(0, -30); stroke(360%frameCount, 80, 90); translate(width/2, height/2); for (int y = -50 - height/2; y<= height; y += xstep) { for (int x= -50 - width/2; x<= width; x += ystep ) { ny = y + noise(ynoise) * 80; if (lastx > -999) { line(x, ny, lastx, lasty); } lastx = x; lasty = ny; ynoise += 0.1; } } } void mousePressed() { if (flag==false) { //クリックする前がオフの時 strokeWeight(1); flag=true; //クリックしたらオンの状態に変更する } else { //クリックする前がオンの時 strokeWeight(3); flag=false; //クリックしたらオフの状態に変更する } }
random_rotate_lines03でクリックしているときだけ回転していたのを,クリックをし終えても回転を保ているように変更したくて,boolen
を使ってみたけれど,できなかった.時間を大分オーバーしたので,今日のところはこれにて終了.
参考にしたサイト: 建築発明工作ゼミ2008: Processing マウス入力4