from turtle import * from random import * class Tree: def __init__(self, X, Y, NormalLenght, LenghtError, LenghtCoefficient, AngleCoefficient, GrowRate, Size, LastAngle): self.Pen = Pen() self.DrawLine(X, Y, NormalLenght, LenghtError, LenghtCoefficient, AngleCoefficient, GrowRate, Size, LastAngle) def DrawLine(self, X, Y, NormalLenght, LenghtError, LenghtCoefficient, AngleCoefficient, GrowRate, Size_, LastAngle): self.Pen.penup() self.Pen.goto(X,Y) self.Pen.pensize(5) R = randint(20,40)/100 G = randint(20,30)/100 B = randint(0,10)/100 self.Pen.color(R,G,B) self.Pen.pendown() Angle = LastAngle+randint(-AngleCoefficient,AngleCoefficient) self.Pen.setheading(Angle) self.Pen.forward((NormalLenght+randint(-LenghtError,LenghtError))-Size_*LenghtCoefficient) if Size_>1: for i in range(randint(1,GrowRate)): self.DrawLine(self.Pen.xcor(),self.Pen.ycor(), NormalLenght, LenghtError, LenghtCoefficient, AngleCoefficient, GrowRate, Size_-1, Angle) self.Pen.goto(X,Y) else: R = randint(50,70)/100 G = randint(80,100)/100 B = randint(0,10)/100 self.Pen.color(R,G,B) self.Pen.begin_fill() self.Pen.circle(NormalLenght/3) self.Pen.end_fill() self.Pen.penup() self.Pen.backward(((NormalLenght+randint(-LenghtError,LenghtError))-Size_*LenghtCoefficient)) Tree(0,-350 , 20 , 5 , 0 , 30 , 2 ,20 , 90)