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 Django 添加首页尾页上一页下一页代码实例

Python Django 添加首页尾页上一页下一页代码实例

添加首页和尾页: views.py: from django.shortcuts import render from app01 import models def book_l...

对python中for、if、while的区别与比较方法

如下所示: if应用举例: #if 若条件成立,只执行一次 #if 条件:如果条件成立,执行条件后的代码块内容,不成立,直接跳过代码块 #判断如果年龄age小于18,输出未成年 #=...

python 实现目录复制的三种小结

复制目录: 包含多层子目录 方法: 递归, 深度遍历,广度遍历 深度遍历&广度遍历: 思路: 1.获得源目录子级目录,并设置目标目录的子级路径 1.1在此就创建两个栈(或者队列),将原目...

matplotlib绘制多个子图(subplot)的方法

在matplotlib下,一个Figure对象可以包含多个子图(Axes),可以使用subplot()快速绘制,其调用形式如下: subplot(numRows, numCols,...

在Python中操作字符串之rstrip()方法的使用

 rstrip()方法返回所有字符都被去除的字符串(缺省为空格字符)结束字符串的副本。 语法 以下是rstrip()方法的语法: str.rstrip([chars])...