Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import turtle
- turtle.penup()
- def draw_square(x_upper_left, y_upper_left, side_length):
- turtle.goto(x_upper_left, y_upper_left)
- turtle.pendown()
- for i in range(0, 4):
- turtle.forward(side_length)
- turtle.right(90)
- turtle.penup()
- def draw_circle(x_center, y_center, radius):
- turtle.goto(x_center+radius, y_center)
- turtle.pendown()
- turtle.circle(radius)
- turtle.penup()
- def draw_semicircle(x_center, y_center, radius):
- turtle.goto(x_center+radius, y_center)
- turtle.left(90)
- turtle.pendown()
- turtle.circle(radius, 180)
- turtle.penup()
- def draw_triangle(x1, y1, x2, y2, x3, y3):
- turtle.goto(x1, y1)
- turtle.pendown()
- turtle.goto(x2, y2)
- turtle.goto(x3, y3)
- turtle.goto(x1, y1)
- turtle.penup()
- def draw_line(x1, y1, x2, y2):
- turtle.goto(x1, y1)
- turtle.pendown()
- turtle.goto(x2, y2)
- turtle.penup()
- def draw_window(x_center, y_center, radius):
- draw_square(x_center-radius, y_center+radius, 2*radius)
- draw_semicircle(x_center, y_center+radius, radius)
- draw_line(x_center, y_center+radius, x_center, y_center-radius)
- draw_line(x_center+radius, y_center, x_center-radius, y_center)
- def draw_house(x_upper_left, y_upper_left, side_length, x_top, y_top, x_center_window, y_center_window, window_length):
- draw_square(x_upper_left, y_upper_left, side_length)
- draw_triangle(x_upper_left, y_upper_left, x_top, y_top, x_upper_left+side_length, y_upper_left)
- draw_window(x_center_window, y_center_window, window_length)
- draw_house(80, 80, 120, 140, 120, 140, 0, 30)
- draw_circle(0, 100, 25)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement