phlyingpenguin
By: a guest | Sep 4th, 2008 | Syntax:
Python | Size: 0.75 KB | Hits: 179 | Expires: Never
from p2d import *
sys.setrecursionlimit(100000)
p = Python2d(0, 0, 2, 2, 800, 800, 50, 50, 750, 750)
butterfly_func = lambda i: math.exp(math.cos(i)) - 2 * math.cos(4*i) + math.pow(math.sin(i/12), 5)
circle_tol = 1000.0
def butterfly():
global p
theta = arange(0,2*pi,0.001)
for t in theta:
r = butterfly_func(t)
x = r*math.cos(t)
y = r*math.sin(t)
p.point(x,y)
def multi_butterfly():
butterfly()
p.scale(0.9, 0.9)
butterfly()
p.scale(0.9, 0.9)
butterfly()
p.scale(0.9, 0.9)
butterfly()
p.translate(1.1,1.2)
p.rotate(pi/3)
p.scale(0.2, 0.2)
p.set_color(0,0,1)
multi_butterfly()
p.load_identity()
p.translate(0.5, 0.65)
p.rotate(-pi/4)
p.scale(0.15, 0.15)
p.set_color(1,0,0)
multi_butterfly()
p.render()