RosettaCodeData/Task/Chaos-game/Processing-Python-mode/chaos-game.processing-py

26 lines
554 B
Plaintext

from __future__ import division
size(300, 260)
background(255) # white
x = floor(random(width))
y = floor(random(height))
for _ in range(30000):
v = floor(random(3))
if v == 0:
x = x / 2
y = y / 2
colour = color(0, 255, 0) # green
elif v == 1:
x = width / 2 + (width / 2 - x) / 2
y = height - (height - y) / 2
colour = color(255, 0, 0) # red
elif v == 2:
x = width - (width - x) / 2
y = y / 2
colour = color(0, 0, 255) # blue
set(x, height - y, colour)