Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from turtle import Turtle
- from numpy import cos, sin, pi
- t = Turtle()
- t.speed(100_000)
- def jump2next(pt: tuple):
- t.penup()
- t.goto(pt)
- t.pendown()
- def pol2dec(r: float, phi: float) -> tuple:
- x = r * cos(phi)
- y = r * sin(phi)
- return x, y
- def draw_circle(radius: int, x0: int=0, y0: int=0) ->None:
- vertex_num = 10 + 5 * radius // 10
- x, y = pol2dec(radius, 0)
- jump2next((x0 + x, y0 + y))
- for vn in range(vertex_num + 1):
- angle = vn * 2 * pi / vertex_num
- x, y = pol2dec(radius, angle)
- t.goto((x0 + x,y0 + y))
- def draw_flower(num_petal = 5, size=200, x0=0, y0=0):
- base_angle = 0
- max_petal = num_petal
- angle_inc = 2 * pi / max_petal
- flower_radius = size
- petal_radius = int(flower_radius * sin(angle_inc / 2))
- for petal_n in range(max_petal):
- angle = base_angle + petal_n * angle_inc
- x, y = pol2dec(flower_radius, angle)
- draw_circle(petal_radius, x0+x, y0+y)
- draw_flower(5)
- draw_flower(7, 150, 300, 300)
- draw_flower(5, 10, -300, -300)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement