Advertisement
Guest User

Untitled

a guest
Nov 17th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. import turtle
  2.  
  3. turtle.penup()
  4.  
  5. def draw_square(x_upper_left, y_upper_left, side_length):
  6. turtle.goto(x_upper_left, y_upper_left)
  7. turtle.pendown()
  8. for i in range(0, 4):
  9. turtle.forward(side_length)
  10. turtle.right(90)
  11. turtle.penup()
  12.  
  13. def draw_circle(x_center, y_center, radius):
  14. turtle.goto(x_center+radius, y_center)
  15. turtle.pendown()
  16. turtle.circle(radius)
  17. turtle.penup()
  18.  
  19. def draw_semicircle(x_center, y_center, radius):
  20. turtle.goto(x_center+radius, y_center)
  21. turtle.left(90)
  22. turtle.pendown()
  23. turtle.circle(radius, 180)
  24. turtle.penup()
  25.  
  26. def draw_triangle(x1, y1, x2, y2, x3, y3):
  27. turtle.goto(x1, y1)
  28. turtle.pendown()
  29. turtle.goto(x2, y2)
  30. turtle.goto(x3, y3)
  31. turtle.goto(x1, y1)
  32. turtle.penup()
  33.  
  34. def draw_line(x1, y1, x2, y2):
  35. turtle.goto(x1, y1)
  36. turtle.pendown()
  37. turtle.goto(x2, y2)
  38. turtle.penup()
  39.  
  40. def draw_window(x_center, y_center, radius):
  41. draw_square(x_center-radius, y_center+radius, 2*radius)
  42. draw_semicircle(x_center, y_center+radius, radius)
  43. draw_line(x_center, y_center+radius, x_center, y_center-radius)
  44. draw_line(x_center+radius, y_center, x_center-radius, y_center)
  45.  
  46. def draw_house(x_upper_left, y_upper_left, side_length, x_top, y_top, x_center_window, y_center_window, window_length):
  47. draw_square(x_upper_left, y_upper_left, side_length)
  48. draw_triangle(x_upper_left, y_upper_left, x_top, y_top, x_upper_left+side_length, y_upper_left)
  49. draw_window(x_center_window, y_center_window, window_length)
  50.  
  51. draw_house(80, 80, 120, 140, 120, 140, 0, 30)
  52. draw_circle(0, 100, 25)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement