Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from graphics import *
- import math
- def rect(r, theta):
- """theta in degrees
- returns tuple; (float, float); (x,y)
- """
- x = r * math.cos(math.radians(theta))
- y = r * math.sin(math.radians(theta))
- return x, y
- def polar(x, y):
- """returns r, theta(degrees)
- """
- r = (x ** 2 + y ** 2) ** .5
- if y == 0:
- theta = 180 if x < 0 else 0
- elif x == 0:
- theta = 90 if y > 0 else 270
- else:
- theta = math.degrees(math.atan(float(y) / x))
- return r, theta
- def main():
- win = GraphWin('Canvas', 640, 480) # give title and dimensions
- win.setCoords(-320, -240, 320, 240)
- seventh = Circle(Point(0, 0), 90) # set center and radius
- # seventh.setFill("yellow")
- seventh.draw(win)
- sixth = Circle(Point(0, 0), 80) # set center and radius
- # sixth.setFill("yellow")
- sixth.draw(win)
- fifth = Circle(Point(0, 0), 70) # set center and radius
- # fifth.setFill("yellow")
- fifth.draw(win)
- fourth = Circle(Point(0, 0), 60) # set center and radius
- # fourth.setFill("yellow")
- fourth.draw(win)
- third = Circle(Point(0, 0), 50) # set center and radius
- # third.setFill("yellow")
- third.draw(win)
- second = Circle(Point(0, 0), 40) # set center and radius
- # second.setFill("yellow")
- second.draw(win)
- first = Circle(Point(0, 0), 30) # set center and radius
- # first.setFill("yellow")
- first.draw(win)
- line = Line(Point(0, 0), Point(rect(90, 0)[0], rect(90, 0)[1]))
- line.draw(win)
- line2 = Line(Point(0, 0), Point(rect(90, 30)[0], rect(90, 30)[1]))
- line2.draw(win)
- line3 = Line(Point(0, 0), Point(rect(90, 60)[0], rect(90, 60)[1]))
- line3.draw(win)
- line4 = Line(Point(0, 0), Point(rect(90, 90)[0], rect(90, 90)[1]))
- line4.draw(win)
- line5 = Line(Point(0, 0), Point(rect(90, 120)[0], rect(90, 120)[1]))
- line5.draw(win)
- line6 = Line(Point(0, 0), Point(rect(90, 150)[0], rect(90, 150)[1]))
- line6.draw(win)
- line7 = Line(Point(0, 0), Point(rect(90, 180)[0], rect(90, 180)[1]))
- line7.draw(win)
- line8 = Line(Point(0, 0), Point(rect(90, 210)[0], rect(90, 210)[1]))
- line8.draw(win)
- line9 = Line(Point(0, 0), Point(rect(90, 240)[0], rect(90, 240)[1]))
- line9.draw(win)
- line10 = Line(Point(0, 0), Point(rect(90, 270)[0], rect(90, 270)[1]))
- line10.draw(win)
- line11 = Line(Point(0, 0), Point(rect(90, 300)[0], rect(90, 300)[1]))
- line11.draw(win)
- line12 = Line(Point(0, 0), Point(rect(90, 330)[0], rect(90, 330)[1]))
- line12.draw(win)
- line13 = Line(Point(0, 0), Point(rect(90, 360)[0], rect(90, 360)[1]))
- line13.draw(win)
- line14 = Line(Point(0, 0), Point(rect(90, 210)[0], rect(90, 210)[1]))
- line14.draw(win)
- first.setFill('black')
- message = Text(Point(0, 200), 'Click anywhere to quit.')
- message.draw(win)
- win.getMouse()
- win.close()
- main()
Add Comment
Please, Sign In to add comment