首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

用Python替我表白你!

七夕总要搞点事,来自正在学python的单身狗的怒号!

从CSDN搞来一个程序丢给你们,姜太公钓鱼,愿者上钩

效果如下:

程序源码在下面:

from turtle import *

from time import sleep

def go_to(x, y):

up()

goto(x, y)

down()

def big_Circle(size):#函数用于绘制心的大圆

speed(3)

for i in range(150):

forward(size)

right(0.3)

def small_Circle(size):#函数用于绘制心的小圆

speed(3)

for i in range(210):

forward(size)

right(0.786)

def line(size):

speed(3)

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(3)

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)#使画笔的方向朝向x轴正方向

heart(-80, -100, 1.5)#画出第二颗心

arrow()#画出穿过两颗心的直线

arrowHead()#画出箭的箭头

go_to(200, -200)

write("春风十里不如你", move=True, align="left", font=("宋体", 30, "normal"))

done()

  • 发表于:
  • 原文链接https://kuaibao.qq.com/s/20180816G0VIN400?refer=cp_1026
  • 腾讯「腾讯云开发者社区」是腾讯内容开放平台帐号(企鹅号)传播渠道之一,根据《腾讯内容开放平台服务协议》转载发布内容。
  • 如有侵权,请联系 cloudcommunity@tencent.com 删除。

扫码

添加站长 进交流群

领取专属 10元无门槛券

私享最新 技术干货

扫码加入开发者社群
领券