random_rotate_lines03
void setup() { size(500, 500); colorMode(HSB, 360, 100, 100, 100); background(0, 0, 100); strokeWeight(1); smooth(); frameRate(5); } 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); if (mousePressed) { rotate(90*PI/180); } 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; } } }
random_lines03の改良.クリックしているあいだだけ,ラインの向きが縦になる.ずっとこれがやりたかった.やっとできた.
traslate
で原点の位置を位置を中央にズラさないといけなかった.そして,ズラした分XとYの値を変更する.原点をずらして,XYの値のズラしを考えているとき,楽しかった.
ここを参考にした: Processing入門web4-6