Advertisement
richwhilecooper

Using shapes classes in Python

Nov 12th, 2018
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.84 KB | None | 0 0
  1. ##my_drawing.py by Rich While-Cooper
  2. ##Check out my YOUTUBE channel (same as my name) for my PYTHON tutorials playlist
  3. from shapes import Triangle, Rectangle, Oval, Paper
  4. rect1 = Rectangle()
  5. rect1.set_width(200)
  6. rect1.set_height(100)
  7. rect1.set_color("blue")
  8. rect1.draw()
  9.  
  10. ###I found you can define all the settings for a shape
  11. ###on one line rather than do it attribute by attribute
  12.  
  13. rect2 = Rectangle(100,100,50,150,color="yellow")
  14. ##rect2.set_x(100)
  15. ##rect2.set_y(100)
  16. ##rect2.set_width(50)
  17. ##rect2.set_height(150)
  18. #rect2.set_color("yellow")
  19. rect2.draw()
  20.  
  21. oval1 = Oval(200,200,0,0,color = "red")
  22. ##oval1.set_x(200)
  23. ##oval1.set_y(200)
  24. ##oval1.randomize(smallest=50,largest=300)
  25. ##oval1.set_color("red")
  26. oval1.draw()
  27.  
  28. tri1 = Triangle(5, 5, 100, 5, 100, 200,color = "purple")
  29. #tri1.set_color = "purple"
  30. tri1.draw()
  31.  
  32. Paper.display()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement