Guest
Public paste!

phlyingpenguin

By: a guest | Sep 4th, 2008 | Syntax: Python | Size: 0.75 KB | Hits: 179 | Expires: Never
Copy text to clipboard
  1. from p2d import *
  2.  
  3. sys.setrecursionlimit(100000)
  4.  
  5. p = Python2d(0, 0, 2, 2, 800, 800, 50, 50, 750, 750)
  6.  
  7. butterfly_func = lambda i: math.exp(math.cos(i)) - 2 * math.cos(4*i) + math.pow(math.sin(i/12), 5)
  8. circle_tol = 1000.0
  9.  
  10. def butterfly():
  11.         global p
  12.         theta = arange(0,2*pi,0.001)
  13.         for t in theta:
  14.                 r = butterfly_func(t)
  15.                 x = r*math.cos(t)
  16.                 y = r*math.sin(t)
  17.                 p.point(x,y)
  18.  
  19. def multi_butterfly():
  20.         butterfly()
  21.         p.scale(0.9, 0.9)
  22.         butterfly()
  23.         p.scale(0.9, 0.9)
  24.         butterfly()
  25.         p.scale(0.9, 0.9)
  26.         butterfly()
  27.  
  28. p.translate(1.1,1.2)
  29. p.rotate(pi/3)
  30. p.scale(0.2, 0.2)
  31. p.set_color(0,0,1)
  32. multi_butterfly()
  33.  
  34. p.load_identity()
  35. p.translate(0.5, 0.65)
  36. p.rotate(-pi/4)
  37. p.scale(0.15, 0.15)
  38. p.set_color(1,0,0)
  39. multi_butterfly()
  40.  
  41. p.render()