用python的turtle模块实现给女票画个小心心
晚上自习无聊
正好拿自己的平板电脑用python写了个小程序,运用turtle模块画一个小心心,并在心上画女票名字的首字母缩写,单纯只为红颜一笑。
代码贴出来,很简单
importturtle
importtime
defliujia():
foriinrange(200):
turtle.right(1)
turtle.forward(1)
turtle.color('red','pink')
turtle.pensize(2)
turtle.speed(10)
turtle.goto(0,0)
turtle.begin_fill()
turtle.left(140)
turtle.forward(112)
liujia()
turtle.left(120)
liujia()
turtle.forward(112)
turtle.end_fill()
turtle.pensize(5)
turtle.up()
turtle.goto(-50,142.7)
turtle.left(50)
turtle.down()
turtle.forward(60)
turtle.left(90)
turtle.forward(25)
turtle.up()
turtle.goto(37.5,142.7)
turtle.down()
turtle.forward(25)
turtle.up()
turtle.goto(50,142.7)
turtle.right(90)
turtle.down()
turtle.forward(60)
foriinrange(20):
turtle.right(7.8)
turtle.forward(0.3)
turtle.forward(8)
turtle.up()
turtle.goto(100,-10)
turtle.write("ILoveyou")
虽然丑丑的,但是她笑了啊
代码这样应该好理解了吧,各位老铁,不要再问怎么改名字了,网上学一下turtle库怎么使用,很简单的
importturtle
importtime
Name=['L','J']
defdraw_circle():
foriinrange(200):
turtle.right(1)
turtle.forward(1)
defdraw_love():
turtle.color('red','pink')
turtle.pensize(2)
turtle.speed(1000)
turtle.goto(0,0)
turtle.begin_fill()
turtle.left(140)
turtle.forward(112)
draw_circle()
turtle.left(120)
draw_circle()
turtle.forward(112)
turtle.end_fill()
defdraw_name():
turtle.pensize(5)
turtle.up()
turtle.goto(-50,142.7)
ifName[0]=='L':
turtle.left(50)
turtle.down()
turtle.forward(60)
turtle.left(90)
turtle.forward(25)
turtle.up()
turtle.goto(37.5,142.7)
ifName[1]=='J':
turtle.down()
turtle.forward(25)
turtle.up()
turtle.goto(50,142.7)
turtle.right(90)
turtle.down()
turtle.forward(60)
foriinrange(20):
turtle.right(7.8)
turtle.forward(0.3)
turtle.forward(8)
turtle.up()
turtle.goto(100,-10)
turtle.write("ILoveyou")
draw_love()
draw_name()
以上这篇用python的turtle模块实现给女票画个小心心就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持毛票票。
声明:本文内容来源于网络,版权归原作者所有,内容由互联网用户自发贡献自行上传,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任。如果您发现有涉嫌版权的内容,欢迎发送邮件至:czq8825#qq.com(发邮件时,请将#更换为@)进行举报,并提供相关证据,一经查实,本站将立刻删除涉嫌侵权内容。