def triangle(points, depth): turtle.penup() turtle.goto(points[0][0], points[0][1]) turtle.pendown() turtle.goto(points[1][0], points[1][1]) turtle.goto(points[2][0], points[2][1]) turtle.goto(points[0][0], points[0][1]) if depth > 0: triangle([ points[0], getMid(points[0], points[1]), getMid(points[0], points[2]) ], depth - 1) triangle([ points[1], getMid(points[0], points[1]), getMid(points[1], points[2]) ], depth - 1) triangle([ points[2], getMid(points[2], points[1]), getMid(points[0], points[2]) ], depth - 1)
def ornament(x, y): turtle.penup() turtle.goto(x, y) turtle.pencolor(Color.RED) turtle.pendown() turtle.dot(7) turtle.penup()
def draw_arm(): turtle.pendown() for angle, length in arm_data: turtle.forward(length) turtle.left(angle) turtle.forward(length) turtle.backward(length) turtle.right(2 * angle) turtle.forward(length) turtle.backward(length) turtle.left(angle) turtle.penup()
def draw_flake(arms): turtle.penup() turtle.home() turtle.clear() angle = 0 delta_angle = 360 // arms for _ in range(arms): turtle.home() turtle.setheading(angle) draw_arm() angle += delta_angle turtle.penup() turtle.home()
turtle.back(s) turtle.pendown() turtle.pencolor(Color.GREEN) tree(15, n) turtle.back(n / 2) #ornaments def ornament(x, y): turtle.penup() turtle.goto(x, y) turtle.pencolor(Color.RED) turtle.pendown() turtle.dot(7) turtle.penup() orn_pnts = [(5, 60), (-7, 40), (10, 20), (-15, 0), (25, -20), (-27, -30), (7, -33), (40, -60), (-9, -63), (-50, -88), (62, -97)] for j in range(len(orn_pnts)): ornament(orn_pnts[j][0], orn_pnts[j][1]) turtle.penup() turtle.goto(0, -120) while True: pass