python turtle表白心爱的人

使用python中的turtle海龟库写表白代码

快去发给你心爱的人吧!

效果图:

在这里插入图片描述

代码:

import time
import turtle as t
t.speed(0)
t.pensize(4)

t.home()
t.left(30)
t.circle(100, 300)
p = t.position()

t.up()
t.goto(-30, 120)
t.down()
t.right(60)
t.circle(20)
t.up()
t.goto(-28, 115)
t.down()
t.begin_fill()
t.fillcolor("black")
t.circle(10)
t.end_fill()

t.begin_fill()
t.fillcolor("white")
t.circle(6)
t.end_fill()


t.up()
t.goto(-120, 120)
t.down()
t.circle(20)
t.up()
t.goto(-100, 125)
t.down()
t.begin_fill()
t.fillcolor("black")
t.circle(10)
t.end_fill()

t.up()
t.goto(-95, 120)
t.down()
t.begin_fill()
t.fillcolor("white")
t.circle(6)
t.end_fill()


t.up()
t.goto(-130, 60)
t.down()
t.begin_fill()
t.color("#FFB5C5")
t.circle(8)
t.end_fill()

t.up()
t.goto(5, 60)
t.down()
t.begin_fill()
t.color("#FFB5C5")
t.circle(8)
t.end_fill()


t.up()
t.goto(-60, 70)
t.down()
t.pencolor("black")
t.circle(5)


t.pencolor("black")
t.up()
t.goto(-80, 40)
t.down()
t.left(10)
t.circle(30, 160)


t.up()
t.goto(p[0], p[1])
t.down()
t.left(150)
t.circle(100, 70)
p2 = t.position()
t.up()
t.goto(p[0]+10, p[1]-20)
t.down()
t.right(40)
t.circle(40, 50)
t.forward(10)
t.left(100)
t.circle(40, 80)


t.up()
t.goto(p[0]+60, p[1]-10)
t.down()
t.left(130)
t.circle(80, 30)
t.left(100)
t.circle(40, 80)
t.up()
t.goto(p2[0]+120, p2[1])
t.down()
t.right(27)
t.circle(260, 25)

t.up()
t.goto(-74, 250)
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, 215)
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()

—结束—
仅学习。

猜你喜欢

转载自blog.csdn.net/qq_52722885/article/details/127788738