Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

Amazing Trees with python turtle

from random import *
from turtle import *

t1, t2, t3, t4, t5 = Turtle(), Turtle(), Turtle(), Turtle(), Turtle()

turtles = [t1, t2, t3, t4, t5]
x = -200

for t in turtles:
      x += randint(60, 160)
      y = randint(-200, -100)
      t.speed(100)
      t.lt(90)
      t.color('brown')
      t.up()
      t.goto(x, y)
      t.down()


def branch(turt, branch_len, angle):
      angle = randint(22, 30)
      sf = uniform(0.6, 0.8)
      size = branch_len / 10
      turt.pensize(size)
      if branch_len < 20:
            turt.color('forest green')
            turt.stamp()
            turt.color('brown')
            
      
      if branch_len > 10:
            
            turt.fd(branch_len)
            turt.lt(angle)
            branch(turt, branch_len * sf, angle)
            turt.rt(angle * 2)
            branch(turt, branch_len * sf, angle)
            turt.lt(angle)
            turt.bk(branch_len)

for t in turtles:            
      branch(t, 100, 30)


Screen().exitonclick()
Comment

Amazing Trees with python turtle


t.left(90) # then call tree after with tree()

Comment

PREVIOUS NEXT
Code Example
Python :: change period to timestamp python 
Python :: py environment variables register in flask 
Python :: matplotlib force scientific notation and define exponent 
Python :: Plot kdeplot, lineplot, scatterplot in seaborn 
Python :: dataframe rolling first eleemnt 
Python :: django query string route 
Python :: python typewriter effect 
Python :: standard streams with python3 
Python :: bst deleting in python 
Python :: Return array of odd rows and even columns from array using numpy 
Python :: python using os module file name from file path 
Python :: python how to locate and fill a specific column null values 
Python :: get all permutations of string 
Python :: upload folder to s3 bucket python 
Python :: python time a task 
Python :: destructuring in for loops python 
Python :: how to remove whitespace from string in python 
Python :: python django adding category 
Python :: embeds discord.py 
Python :: get image data cv2 
Python :: root mean squared error in machine learning formula 
Python :: ski learn decision tree 
Python :: python resample and interpolate 
Python :: python unpack list 
Python :: split df coliumn 
Python :: rename files in python 
Python :: root = tk() python 3 
Python :: print value of array python 
Python :: python is ascii 
Python :: how to open py file without console 
ADD CONTENT
Topic
Content
Source link
Name
5+7 =