SHARE
TWEET

Untitled

a guest Oct 15th, 2019 109 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     import turtle
  2.     import math
  3.  
  4.     def petal(t, r, angle):
  5.         for i in range(2):
  6.             arc(t, r, angle)
  7.             t.lt(180 - angle)
  8.  
  9.     def flower(t, n, r, angle):
  10.         for i in range(n):
  11.             petal(t, r, angle)
  12.             t.lt(360.0 / n)
  13.  
  14.     def move(t, length):
  15.         t.pu()
  16.         t.fd(length)
  17.         t.pd()
  18.  
  19.     def square(t, length):
  20.         for i in range(4):
  21.             t.fd(length)
  22.             t.lt(90)
  23.  
  24.     def polyline(t, n, length, angle):
  25.         for i in range(n):
  26.             t.fd(length)
  27.             t.lt(angle)
  28.  
  29.     def polygon(t, n, length):
  30.         angle = 360.0 / n
  31.         polyline(t, n, length, angle)
  32.  
  33.     def arc(t, r, angle):
  34.         arc_length = 2 * math.pi * r * abs(angle) / 360
  35.         n = int(arc_length / 4) + 3
  36.         step_length = arc_length / n
  37.         step_angle = float(angle) / n
  38.  
  39.         # making a slight left turn before starting reduces
  40.         # the error caused by the linear approximation of the arc
  41.         t.lt(step_angle / 2)
  42.         polyline(t, n, step_length, step_angle)
  43.         t.rt(step_angle / 2)
  44.  
  45.     def circle(t, r):
  46.         arc(t, r, 360)
  47.  
  48.     def kvetina(t,n,r,angle,dlzkastonky,uholstonky,dlzkalistu,hrubkalistu,uhollistusozemou):
  49.         flower(t,n,r,angle)
  50.         x=(uholstonky+180)/2
  51.         bob.rt(x)
  52.         arc(t,dlzkastonky,uholstonky)
  53.         bob.seth(0)
  54.         bob.lt(uhollistusozemou)
  55.         petal(t,dlzkalistu,hrubkalistu)
  56.         bob.seth(180 - uhollistusozemou)
  57.         petal(t, dlzkalistu, -hrubkalistu)
  58.  
  59.     bob = turtle.Turtle()
  60.     bob.speed(50)
  61.  
  62.     kvetina(bob,5,60,80,140,90,60,80,0)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top