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()
rotation=180) turtle = turtle(display) #==| Turtle Gizmo Setup end |========================================= # Fractal Christmas Tree: # https://codegolf.stackexchange.com/questions/15860/make-a-scalable-christmas-tree # by Keith Randall n = 42 # input value for scaling the tree. note: ornaments don't scale turtle.goto(0, -20) #star turtle.left(90) turtle.forward(3 * n) turtle.pencolor(Color.YELLOW) turtle.left(126) turtle.pendown() for _ in range(5): turtle.forward(n / 5) turtle.right(144) turtle.forward(n / 5) turtle.left(72) turtle.right(126) #tree turtle.pencolor(Color.GREEN) turtle.back(n * 4.8) def tree(d, s): if d <= 0: return