RosettaCodeData/Task/Chaos-game/Processing/chaos-game.processing

30 lines
526 B
Plaintext

size(300, 260);
background(#ffffff); // white
int x = floor(random(width));
int y = floor(random(height));
int colour = #ffffff;
for (int i=0; i<30000; i++) {
int v = floor(random(3));
switch (v) {
case 0:
x = x / 2;
y = y / 2;
colour = #00ff00; // green
break;
case 1:
x = width/2 + (width/2 - x)/2;
y = height - (height - y)/2;
colour = #ff0000; // red
break;
case 2:
x = width - (width - x)/2;
y = y / 2;
colour = #0000ff; // blue
}
set(x, height-y, colour);
}