Files
sunny9898/task8/wk8/wk8_example2c/wk8_example2c.pde
louiscklaw 5637fbf94f update,
2025-02-01 02:07:58 +08:00

40 lines
695 B
Plaintext

// Based on Listing 4-3, Generative Art
float x, y, radius, centX, centY;
float t = 0;
void setup() {
size(500, 500);
strokeWeight(5);
centX = width / 2;
centY = height / 2;
frameRate(5);
}
void draw() {
background(255);
float lastx = -999, lasty = -999;
radius = 20;
t = random(10);
for (float ang = 0; ang <= 360 * 4; ang += 5) { // loop for four times
float rad = radians(ang);
radius += 0.5;
float r_noise = radius + noise(t) * 100;
x = centX + (r_noise * cos(rad));
y = centY + (r_noise * sin(rad));
if (lastx > 0 )
line(x, y, lastx, lasty);
lastx = x;
lasty = y;
t += 0.05;
}
}