You know, we procedural apes also need romance , Xiaobo, I searched a lot of codes on the Internet before , It turns out that many of them are not up to date , So I sorted out the code , Now share with the majority of bloggers

<> Bags we need to use

use pip install +( Package name )

* turtle 2.random
<> Program source code
# Project Leader: Liu # Project: Declare the source code import turtle import random def
love(x,y):# stay (x,y) Painting love lalala lv=turtle.Turtle() lv.hideturtle() lv.up()
lv.goto(x,y)# Locate to (x,y) def curvemove():# arc for i in range(20): lv.right(10)
lv.forward(2) lv.color('red','pink') lv.speed(10000000) lv.pensize(1)
# Start painting love lalala lv.down() lv.begin_fill() lv.left(140) lv.forward(22) curvemove()
lv.left(120) curvemove() lv.forward(22)
lv.write(" name ",font=("Arial",12,"normal"),align="center")# Write the name of the Confessor
lv.left(140)# Reset after drawing lv.end_fill() def tree(branchLen,t): if branchLen >
5:# Too few branches left to end recursion if branchLen<20: t.color("green")
t.pensize(random.uniform((branchLen + 5) / 4 - 2, (branchLen + 6) / 4 + 5))
t.down() t.forward(branchLen) love(t.xcor(),t.ycor())# Transmit now turtle Coordinates of t.up()
t.backward(branchLen) t.color("brown") return
t.pensize(random.uniform((branchLen+5)/4-2,(branchLen+6)/4+5)) t.down()
t.forward(branchLen) # The following recursion ang=random.uniform(15,45) t.right(ang)
tree(branchLen-random.uniform(12,16),t)# Random decision to reduce length t.left(2*ang)
tree(branchLen-random.uniform(12,16),t)# Random decision to reduce length t.right(ang) t.up()
t.backward(branchLen) myWin = turtle.Screen() t = turtle.Turtle()
t.hideturtle() t.speed(1000) t.left(90) t.up() t.backward(200) t.down()
t.color("brown") t.pensize(32) t.forward(60) tree(100,t) myWin.exitonclick()
<> Operation effect

Technology