Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import turtle
- import math
- def petal(t, r, angle):
- for i in range(2):
- arc(t, r, angle)
- t.lt(180 - angle)
- def flower(t, n, r, angle):
- for i in range(n):
- petal(t, r, angle)
- t.lt(360.0 / n)
- def move(t, length):
- t.pu()
- t.fd(length)
- t.pd()
- def square(t, length):
- for i in range(4):
- t.fd(length)
- t.lt(90)
- def polyline(t, n, length, angle):
- for i in range(n):
- t.fd(length)
- t.lt(angle)
- def polygon(t, n, length):
- angle = 360.0 / n
- polyline(t, n, length, angle)
- def arc(t, r, angle):
- arc_length = 2 * math.pi * r * abs(angle) / 360
- n = int(arc_length / 4) + 3
- step_length = arc_length / n
- step_angle = float(angle) / n
- # making a slight left turn before starting reduces
- # the error caused by the linear approximation of the arc
- t.lt(step_angle / 2)
- polyline(t, n, step_length, step_angle)
- t.rt(step_angle / 2)
- def circle(t, r):
- arc(t, r, 360)
- def kvetina(t,n,r,angle,dlzkastonky,uholstonky,dlzkalistu,hrubkalistu,uhollistusozemou):
- flower(t,n,r,angle)
- x=(uholstonky+180)/2
- bob.rt(x)
- arc(t,dlzkastonky,uholstonky)
- bob.seth(0)
- bob.lt(uhollistusozemou)
- petal(t,dlzkalistu,hrubkalistu)
- bob.seth(180 - uhollistusozemou)
- petal(t, dlzkalistu, -hrubkalistu)
- bob = turtle.Turtle()
- bob.speed(50)
- kvetina(bob,5,60,80,140,90,60,80,0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement