使用python中的 turtle海龟库写表白代码
快去发给你心爱的人吧!
效果图:
代码
import time
import turtle as t
t.speed(10)
t.pensize(4)
t.home()
t.left(30)
t.circle(60, 300)
p = t.position()
t.up()
t.goto(-10, 80)
t.down()
t.right(60)
t.circle(10, 80)
t.up()
t.goto(-10, 50)
t.down()
t.begin_fill()
t.fillcolor("black")
t.circle(5)
t.end_fill()
t.begin_fill()
t.fillcolor("white")
t.circle(4)
t.end_fill()
t.up()
t.goto(-60, 70)
t.down()
t.left(20)
t.forward(10)
t.up()
t.goto(-50, 50)
t.down()
t.begin_fill()
t.fillcolor("black")
t.circle(5)
t.end_fill()
t.begin_fill()
t.fillcolor("white")
t.circle(4)
t.end_fill()
t.up()
t.goto(-65, 30)
t.down()
t.begin_fill()
t.color("#ff5eb1")
t.circle(5)
t.end_fill()
t.up()
t.goto(5, 30)
t.down()
t.begin_fill()
t.color("#ff5eb1")
t.circle(5)
t.end_fill()
t.pencolor("black")
t.up()
t.goto(-40, 20)
t.down()
t.right(90)
t.circle(10, 160)
t.up()
t.goto(p[0]-15, p[1]+10)
t.down()
t.left(150)
t.circle(70, 70)
t.left(100)
t.circle(40, 40)
t.forward(10)
t.left(176)
t.circle(240, 20)
p2 = t.position()
t.up()
t.goto(p[0]+60, p[1])
t.down()
t.left(30)
t.forward(20)
t.circle(-20, 100)
t.right(95)
t.forward(30)
t.up()
t.goto(p2[0]+80, p2[1])
t.down()
t.right(25)
t.circle(260, 18)
t.up()
t.goto(-74, 160)
t.down()
a = t.position()
j = 1
text = "小姐姐"
for txt in text:
t.write(txt, font=("Arial", 15, "bold"))
t.up()
t.goto(a[0]+(j*30), a[1])
t.down()
j += 1
time.sleep(0.05)
text = "可以做我女朋友吗~~~"
j = 1
t.up()
t.goto(-174, 135)
t.down()
a = t.position()
for txt in text:
t.write(txt, font=("Arial", 15, "bold"))
t.up()
t.goto(a[0]+(j*30), a[1])
t.down()
j += 1
time.sleep(0.05)
t.up()
t.goto(70, -50)
t.down()
t.pencolor("red")
t.setheading(0)
t.begin_fill()
t.color("red")
t.left(45)
t.forward(40)
t.circle(20, 180)
t.right(90)
t.circle(20, 180)
t.forward(40)
t.end_fill()
t.ht()
t.done()
—结束----
仅学习。