Guest User

Untitled

a guest
Oct 15th, 2019
110
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import turtle
  2. import math
  3. bob = turtle.Turtle()
  4. bob.speed(100)
  5. def arc(t, r, angle):
  6. arc_length = 2 * math.pi * r * angle / 360
  7. n = int(arc_length / 3) +1
  8. step_length = arc_length / n
  9. step_angle = float(angle) / n
  10. polyline(t, n, step_length, step_angle)
  11. def polyline(t, n, length, angle):
  12. for i in range(n):
  13. t.fd(length)
  14. t.lt(angle)
  15. def lupen(t, r, angle):
  16. for i in range(2):
  17. arc(t,r,angle)
  18. t.lt(180 - angle)
  19. def kvet(t, r, n):
  20. angle=360/n
  21. for i in range(n):
  22. lupen(t, r, angle)
  23. t.lt(angle)
  24. def stonka(t,dlzka_stonky,us):
  25. t.heading()
  26. t.rt(135)
  27. arc(t,dlzka_stonky,us)
  28. def listy(t,dlzka_listu,ul):
  29. t.setheading(0)
  30. t.lt(90-ul)
  31. for i in range(2):
  32. for i in range(2):
  33. arc(t,dlzka_listu,ul)
  34. t.lt(180-ul)
  35. t.lt(ul)
  36. def kvet2(t, r, n):
  37. angle=360/n
  38. for i in range(n):
  39. lupen(t, r, angle*2)
  40. t.lt(angle)
  41. def stonka2(t,dlzka_stonky,us):
  42. t.heading()
  43. t.rt(112.5)
  44. arc(t,dlzka_stonky,us)
  45. def stonka3(t,dlzka_stonky,us):
  46. t.heading()
  47. t.rt(112.5-22.5/2)
  48. arc(t,dlzka_stonky,us)
  49. def flower1(t,r,n,dlzka_stonky,us,dlzka_listu,ul):
  50. kvet(t,r,n)
  51. stonka(t,dlzka_stonky,us) #flower1(bob,100,7,150,90,60,90)
  52. listy(t,dlzka_listu,ul)
  53. def flower2(t,r,n,dlzka_stonky,us,dlzka_listu,ul):
  54. kvet2(t,r,n)
  55. stonka2(t,dlzka_stonky,us) #flower2(bob,70,10,350,45,300,25)
  56. listy(t,dlzka_listu,ul)
  57. def flower3(t,r,n,dlzka_stonky,us,dlzka_listu,ul):
  58. kvet(t,r,n)
  59. stonka3(t,dlzka_stonky,us) #flower3(bob,200,20,500,22.5,100,90)
  60. listy(t,dlzka_listu,ul)
  61. bob.pu()
  62. bob.backward(250)
  63. bob.pd()
  64. flower1(bob,100,7,150,90,60,90)
  65. bob.pu()
  66. bob.home()
  67. bob.pd()
  68. flower2(bob,60,10,350,45,300,25)
  69. bob.pu()
  70. bob.home()
  71. bob.fd(250)
  72. bob.pd()
  73. flower3(bob,200,20,500,22.5,100,90)
RAW Paste Data