Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.87 KB | None | 0 0
  1. phi =0
  2.  
  3. def setup():
  4. fullScreen(P2D)
  5. frameRate(50)
  6. textAlign(CENTER, CENTER)
  7.  
  8.  
  9. def draw():
  10. stroke(0)
  11.  
  12. global phi
  13. phi += 0.001
  14. centers = [(width/2, height/2), \
  15. (width/2 + 250*cos(phi)*(sqrt(2)-1)/(sqrt(2)+1), \
  16. height/2 + 250*sin(phi)*(sqrt(2)-1)/(sqrt(2)+1))]
  17.  
  18. background(100)
  19. fill(200)
  20. ellipse(width/2, height/2, 500, 500)
  21. fill(150)
  22. arc(width/2 + cos(phi)*250, height/2 + sin(phi)*250, \
  23. 500*sqrt(2), 500*sqrt(2),PI+ phi-QUARTER_PI,PI+ phi+QUARTER_PI, PIE)
  24. fill(200)
  25. ellipse(centers[1][0], centers[1][1], \
  26. 500*sqrt(2)/(sqrt(2)+1),500*sqrt(2)/(sqrt(2)+1))
  27. fill(150)
  28. arc(centers[1][0] + cos(2*phi)*250*sqrt(2)/(sqrt(2)+1), \
  29. centers[1][1] + sin(2*phi)*250*sqrt(2)/(sqrt(2)+1), \
  30. 500*sqrt(2)/(sqrt(2)+1)*sqrt(2), 500*sqrt(2)/(sqrt(2)+1)*sqrt(2), \
  31. PI+2*phi - QUARTER_PI, PI+2*phi+QUARTER_PI, PIE)
  32. stroke(200, 0, 0)
  33. line(centers[1][0], centers[1][1], \
  34. width/2+ cos(phi)*250, height/2 + sin(phi)*250)
  35. line(centers[1][0] + cos(2*phi)*250*sqrt(2)/(sqrt(2)+1), \
  36. centers[1][1] + sin(2*phi)*250*sqrt(2)/(sqrt(2)+1), \
  37. centers[1][0], \
  38. centers[1][1])
  39. noFill();
  40. arc(centers[1][0], centers[1][1], 60, 60, phi, phi+(phi)%(TWO_PI));
  41. fill(200, 0, 0)
  42. text("phi", centers[1][0] + 20*cos((phi%TWO_PI)/2+phi),
  43. centers[1][1] + 20*sin((phi%TWO_PI)/2+phi))
  44. stroke(0,0,200)
  45. noFill()
  46. arc(centers[0][0], centers[0][1], 60, 60, 0, phi%TWO_PI)
  47. fill(0, 0, 200)
  48. text("phi", centers[0][0] + 20*cos((phi%TWO_PI)/2),\
  49. centers[0][1] + 20*sin((phi%TWO_PI)/2))
  50. line(centers[0][0], centers[0][1], centers[0][0]+250, centers[0][1])
  51. line(centers[0][0],centers[0][1], \
  52. width/2 + cos(phi)*250, height/2 + sin(phi)*250)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement