initial commit
This commit is contained in:
commit
39f56a3b10
83 files changed
+3583
No files matched your search
@@ -0,0 +1,29 @@
|
||||
import math
|
||||
import random
|
||||
from turtle import Turtle
|
||||
|
||||
|
||||
def draw_turtle_line(turtle, start: (float,float), end: (float, float)):
|
||||
turtle.penup()
|
||||
turtle.goto(start[0], start[1])
|
||||
turtle.pendown()
|
||||
turtle.goto(end[0], end[1])
|
||||
|
||||
def draw_branch(turtle, point: (float, float), angle: float, length: float):
|
||||
if length > 10:
|
||||
x1 = round(point[0] - math.sin(angle) * length)
|
||||
y1 = round(point[1] + math.cos(angle) * length)
|
||||
draw_turtle_line(turtle, point, (x1, y1))
|
||||
|
||||
bend_angle = math.radians(random.uniform(-10, 10))
|
||||
branch_angle = math.radians(random.uniform(-40, 40))
|
||||
draw_branch(turtle,(x1, y1), bend_angle - branch_angle, length *
|
||||
random.uniform(0.6, 0.8))
|
||||
draw_branch(turtle,(x1, y1), bend_angle + branch_angle, length *
|
||||
random.uniform(0.6, 0.8))
|
||||
|
||||
sophia = Turtle()
|
||||
draw_branch(sophia, (0, 0), 0.0 ,100)
|
||||
|
||||
sophia.screen.mainloop()
|
||||
|
||||
Reference in new issue
Block a user