python七夕浪漫表白源码

yipeiwu_com6年前Python基础

本文实例为大家分享了python七夕浪漫表白的具体代码,供大家参考,具体内容如下

from turtle import *
from time import sleep
 
def go_to(x, y):
  up()
  goto(x, y)
  down()
 
 
def big_Circle(size): #函数用于绘制心的大圆
  speed(1)
  for i in range(150):
    forward(size)
    right(0.3)
 
def small_Circle(size): #函数用于绘制心的小圆
  speed(1)
  for i in range(210):
    forward(size)
    right(0.786)
 
def line(size):
  speed(1)
  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(1)
  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(400, -300)
  write("author:520Python", move=True, align="left", font=("宋体", 30, "normal"))
  done()
 
main()

效果如下:

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持【听图阁-专注于Python设计】。

相关文章

Python输出汉字字库及将文字转换为图片的方法

Python输出汉字字库及将文字转换为图片的方法

用python输出汉字字库 问题1:假设我们知道汉字编码范围是0x4E00到0x9FA5,怎么从十六进制的编码转成人类可读的字呢? 问题2:怎么把unicode编码的字写入文件呢,如果直...

对Python 除法负数取商的取整方式详解

python除法负数商的取整方式与C++不同 python: 5 / -2 = -3 若想和C++行为相同,可以使用 int(operator.truediv(num1, num2...

flask session组件的使用示例

一、简介 flask中session组件可分为内置的session组件还有第三方flask-session组件,内置的session组件功能单一,而第三方的flask-sessoin可...

详解pandas的外部数据导入与常用方法

外部数据导入 导入excel文件 pandas导入excel用read_excel()方法: import pandas as pd excel_file1 = pd.read_...

pandas DataFrame数据转为list的方法

首先使用np.array()函数把DataFrame转化为np.ndarray(),再利用tolist()函数把np.ndarray()转为list,示例代码如下: # -*- co...