Commit b1f02efc by BellCodeEditor

auto save

parent e9d90fee
Showing with 158 additions and 0 deletions
from turtle import *
from time import sleep
def go_to(x, y):
up()
goto(x, y)
down()
def big_Circle(size):
speed(10)
for i in range(150):
forward(size)
right(0.3)
def small_Circle(size):
speed(10)
for i in range(210):
forward(size)
right(0.786)
def line(size):
speed(10)
forward(51*size)
def heart(x, y, size):
go_to(x, y)
left(150)
begin_fill()
line(size)
big_Circle(size)
small_Circle(size)
left(120)
small_Circle(size)
big_Circle(size)
line(size)
end_fill()
def arrow():
pensize(10)
setheading(0)
go_to(-400, 0)
left(15)
forward(150)
go_to(339, 178)
forward(150)
def arrowHead():
pensize(1)
speed(10)
color('red', 'red')
begin_fill()
left(120)
forward(20)
right(150)
forward(35)
right(120)
forward(35)
right(150)
forward(20)
end_fill()
def main():
pensize(2)
color('red', 'pink')
getscreen().tracer(30, 0)
heart(200, 0, 1)
setheading(0)
heart(-80, -100, 1.5)
arrow()
arrowHead()
go_to(400, -300)
#write("author:520Python", move=True, align="left", font=("宋体", 30, "normal"))
done()
main()
import turtle as T
import turtle as T
import random
import time
# 画樱花的躯干(60,t)
def Tree(branch, t):
time.sleep(0.0005)
if branch > 3:
if 8 <= branch <= 12:
if random.randint(0,2) == 0:
t.color('snow') # 白
else:
t.color('lightcoral') # 淡珊瑚色
t.pensize(branch / 3)
elif branch < 8:
if random.randint(0, 1) == 0:
t.color('snow')
else:
t.color('lightcoral') # 淡珊瑚色
t.pensize(branch / 2)
else:
t.color('sienna') # 赭(zhě)色
t.pensize(branch / 10) # 6
t.forward(branch)
a = 1.5 * random.randint(10,100)
t.right(20 * a)
b = 1.5 * random.randint(1,9)
Tree(branch - 10 * b, t)
t.left(40 * a)
Tree(branch - 10 * b, t)
t.right(20 * a)
t.up()
t.backward(branch)
t.down()
# 掉落的花瓣
def Petal(m, t):
for i in range(m):
a = 200 - 400 * random.random()
b = 10 - 20 * random.random()
t.up()
t.forward(b)
t.left(90)
t.forward(a)
t.down()
t.color('lightcoral') # 淡珊瑚色
t.circle(1)
t.up()
t.backward(a)
t.right(90)
t.backward(b)
# 绘图区域
t = T.Turtle()
# 画布大小
w = T.Screen()
w.
t.hideturtle() # 隐藏画笔
t.getscreen().tracer(5, 0)
w.screensize(canvheight=768, canvwidth=1024, bg='wheat') # wheat小麦
w.title('**************樱花**************')
t.left(90)
t.up()
t.backward(150)
t.down()
t.color('sienna')
# 画樱花的躯干
Tree(400, t)
# 掉落的花瓣
Petal(400, t)
w.exitonclick()
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment