Advertisement
MSWS

Shapes

Oct 17th, 2019
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.02 KB | None | 0 0
  1. # shapes.py
  2.  
  3. # I. Boaz
  4. # CSC 110
  5. # 10/17/19
  6.  
  7. from graphics import *
  8.  
  9. WIDTH = 600
  10. HEIGHT = 400
  11.  
  12. def main():
  13.     win = GraphWin("Shapes", WIDTH, HEIGHT)
  14.     win.setBackground("white")
  15.    
  16.     line(0, HEIGHT/2, WIDTH, HEIGHT/2, win)
  17.     line(WIDTH/2, 0, WIDTH/2, HEIGHT/2, win)
  18.     line(WIDTH/3, HEIGHT/2, WIDTH/3, HEIGHT, win)
  19.     line(WIDTH/3 * 2, HEIGHT/2, WIDTH/3 * 2, HEIGHT, win)
  20.  
  21.     rect = Rectangle(Point(50, 50), Point(WIDTH/2-50, HEIGHT/2-50))
  22.     rect.setFill("magenta")
  23.     rect.setWidth(5)
  24.     rect.draw(win)
  25.  
  26.  
  27.     poly = Polygon(Point(WIDTH/4*3, 50), Point(WIDTH-50, HEIGHT/2-50), Point(WIDTH/2+50, HEIGHT/2-50))
  28.     poly.setFill("black")
  29.     poly.setOutline("red")
  30.     poly.setWidth(5)
  31.     poly.draw(win)
  32.  
  33.     circle = Circle(Point(100, HEIGHT/4*3), 50)
  34.     circle.setFill("blue")
  35.     circle.setOutline("orange")
  36.     circle.setWidth(5)
  37.     circle.draw(win)
  38.    
  39. def line(x1, y1, x2, y2, win):
  40.     line = Line(Point(x1, y1), Point(x2, y2))
  41.     line.setWidth(5)
  42.     line.draw(win)
  43.  
  44. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement