Skip to content

Instantly share code, notes, and snippets.

@iizukak
Created April 15, 2012 05:24
Show Gist options
  • Select an option

  • Save iizukak/2390231 to your computer and use it in GitHub Desktop.

Select an option

Save iizukak/2390231 to your computer and use it in GitHub Desktop.
Fractal Leaf
import random
def leaf(a):
prob = random.randint(1,100)
#print prob
if prob == 1:
a[0] = 0.0
a[1] = 0.16 * a[1]
elif 1 < prob and prob <= 85:
a[0] = 0.85 * a[0] + 0.04 * a[1]
a[1] = -0.04 * a[0] + 0.85 * a[1] + 1.6
elif 85 < prob and prob <= 92:
a[0] = 0.2 * a[0] - 0.26 * a[1]
a[1] = 0.23 * a[0] + 0.22 * a[1] + 1.6
elif 92 < prob and prob <= 100:
a[0] = -0.15 * a[0] + 0.28 * a[1]
a[1] = 0.26 * a[0] + 0.24 * a[1] + 0.44
a = [0.0, 0.0]
for i in range(100000):
print(a[0], a[1])
leaf(a)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment