Guest User

Untitled

a guest
Mar 19th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.84 KB | None | 0 0
  1. from graphics import *
  2. import math
  3.  
  4. def rect(r, theta):
  5. """theta in degrees
  6.  
  7. returns tuple; (float, float); (x,y)
  8. """
  9. x = r * math.cos(math.radians(theta))
  10. y = r * math.sin(math.radians(theta))
  11. return x, y
  12.  
  13.  
  14. def polar(x, y):
  15. """returns r, theta(degrees)
  16. """
  17. r = (x ** 2 + y ** 2) ** .5
  18. if y == 0:
  19. theta = 180 if x < 0 else 0
  20. elif x == 0:
  21. theta = 90 if y > 0 else 270
  22. else:
  23. theta = math.degrees(math.atan(float(y) / x))
  24. return r, theta
  25.  
  26.  
  27. def main():
  28. win = GraphWin('Canvas', 640, 480) # give title and dimensions
  29. win.setCoords(-320, -240, 320, 240)
  30.  
  31. seventh = Circle(Point(0, 0), 90) # set center and radius
  32. # seventh.setFill("yellow")
  33. seventh.draw(win)
  34.  
  35. sixth = Circle(Point(0, 0), 80) # set center and radius
  36. # sixth.setFill("yellow")
  37. sixth.draw(win)
  38.  
  39. fifth = Circle(Point(0, 0), 70) # set center and radius
  40. # fifth.setFill("yellow")
  41. fifth.draw(win)
  42.  
  43. fourth = Circle(Point(0, 0), 60) # set center and radius
  44. # fourth.setFill("yellow")
  45. fourth.draw(win)
  46.  
  47. third = Circle(Point(0, 0), 50) # set center and radius
  48. # third.setFill("yellow")
  49. third.draw(win)
  50.  
  51. second = Circle(Point(0, 0), 40) # set center and radius
  52. # second.setFill("yellow")
  53. second.draw(win)
  54.  
  55. first = Circle(Point(0, 0), 30) # set center and radius
  56. # first.setFill("yellow")
  57. first.draw(win)
  58.  
  59. line = Line(Point(0, 0), Point(rect(90, 0)[0], rect(90, 0)[1]))
  60. line.draw(win)
  61.  
  62. line2 = Line(Point(0, 0), Point(rect(90, 30)[0], rect(90, 30)[1]))
  63. line2.draw(win)
  64.  
  65. line3 = Line(Point(0, 0), Point(rect(90, 60)[0], rect(90, 60)[1]))
  66. line3.draw(win)
  67.  
  68. line4 = Line(Point(0, 0), Point(rect(90, 90)[0], rect(90, 90)[1]))
  69. line4.draw(win)
  70.  
  71. line5 = Line(Point(0, 0), Point(rect(90, 120)[0], rect(90, 120)[1]))
  72. line5.draw(win)
  73.  
  74. line6 = Line(Point(0, 0), Point(rect(90, 150)[0], rect(90, 150)[1]))
  75. line6.draw(win)
  76.  
  77. line7 = Line(Point(0, 0), Point(rect(90, 180)[0], rect(90, 180)[1]))
  78. line7.draw(win)
  79.  
  80. line8 = Line(Point(0, 0), Point(rect(90, 210)[0], rect(90, 210)[1]))
  81. line8.draw(win)
  82.  
  83. line9 = Line(Point(0, 0), Point(rect(90, 240)[0], rect(90, 240)[1]))
  84. line9.draw(win)
  85.  
  86. line10 = Line(Point(0, 0), Point(rect(90, 270)[0], rect(90, 270)[1]))
  87. line10.draw(win)
  88.  
  89. line11 = Line(Point(0, 0), Point(rect(90, 300)[0], rect(90, 300)[1]))
  90. line11.draw(win)
  91.  
  92. line12 = Line(Point(0, 0), Point(rect(90, 330)[0], rect(90, 330)[1]))
  93. line12.draw(win)
  94.  
  95. line13 = Line(Point(0, 0), Point(rect(90, 360)[0], rect(90, 360)[1]))
  96. line13.draw(win)
  97.  
  98. line14 = Line(Point(0, 0), Point(rect(90, 210)[0], rect(90, 210)[1]))
  99. line14.draw(win)
  100.  
  101. first.setFill('black')
  102.  
  103.  
  104. message = Text(Point(0, 200), 'Click anywhere to quit.')
  105. message.draw(win)
  106. win.getMouse()
  107.  
  108. win.close()
  109.  
  110. main()
Add Comment
Please, Sign In to add comment