radius_lines02
int centx; int centy; float x, y; void setup() { size(500, 500); colorMode(HSB, 360, 100, 100, 100); background(0, 0, 100); strokeWeight(3); smooth(); int centx = 0; int centy = 0; } void draw() { translate(width/2, height/2); for (int i = 0; i < 100; i ++) { float lastx = -999; float lasty = -999; float radiusNoise = random(10); float radius = 10; stroke(frameCount%360, random(50), random(70, 100)); int startangle = int(random(360)); int endangle = 1440 + int(random(1440)); int anglestep = 5 + int(random(3)); for (float ang = startangle; ang <= endangle; ang += anglestep) { radiusNoise += 0.05; radius += 0.5; float thisRadius = radius + (noise(radiusNoise) * 200) - 100; float rad = radians(ang); x = centx + (radius * cos(rad)); y = centy + (radius * sin(rad)); if ( lastx > -999) { line(x, y, lastx, lasty); } lastx = x; lasty = y; } } }
今日も教科書の写経から,void setip
void draw
に書き直す流れ.昨日よりは考えながら,写経できた.コードが長くなってきて,変数が多くなってくると,「これがああなって」「あれがこうなって」と流れを追っていくことが難しくなってくる.for
文がふたつあると,どこを繰り返すのかもわからなくなってくる.