欢迎来到代码驿站!

Python代码

当前位置:首页 > 软件编程 > Python代码

使用Python画出小人发射爱心的代码

时间:2021-06-23 09:20:12|栏目:Python代码|点击:

我就废话不多说了,直接上代码吧!

#2.14
from turtle import *
from time import sleep
 
def go_to(x, y):
  up()
  goto(x, y)
  down()
 
def head(x,y,r):
  go_to(x,y)
  speed(1)
  circle(r)
  leg(x,y)
 
def leg(x,y):
 
  right(90)
  forward(180)
  right(30)
  forward(100)
  left(120)
  go_to(x,y-180)
  forward(100)
  right(120)
  forward(100)
  left(120)
  hand(x,y)
 
 
def hand(x,y):
  go_to(x,y-60)
  forward(100)
  left(60)
  forward(100)
  go_to(x, y - 90)
  right(60)
  forward(100)
  right(60)
  forward(100)
  left(60)
  eye(x,y)
 
def eye(x,y):
  go_to(x-50,y+130)
  right(90)
  forward(50)
  go_to(x+40,y+130)
  forward(50)
  left(90)
 
 
def big_Circle(size):
  speed(20)
  for i in range(150):
    forward(size)
    right(0.3)
def line(size):
  speed(1)
  forward(51*size)
 
def small_Circle(size):
  speed(10)
  for i in range(210):
    forward(size)
    right(0.786)
 
 
 
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 main():
  pensize(2)
  color('red', 'pink')
  head(-120, 100, 100)
  heart(250, -80, 1)
  go_to(200, -300)
  write("To: 智慧与美貌并存的", move=True, align="left", font=("楷体", 20, "normal"))
  done()
 
main()

运行结果:

上一篇:python等差数列求和公式前 100 项的和实例

栏    目:Python代码

下一篇:win10安装tensorflow-gpu1.8.0详细完整步骤

本文标题:使用Python画出小人发射爱心的代码

本文地址:http://www.codeinn.net/misctech/146653.html

推荐教程

广告投放 | 联系我们 | 版权申明

重要申明:本站所有的文章、图片、评论等,均由网友发表或上传并维护或收集自网络,属个人行为,与本站立场无关。

如果侵犯了您的权利,请与我们联系,我们将在24小时内进行处理、任何非本站因素导致的法律后果,本站均不负任何责任。

联系QQ:914707363 | 邮箱:codeinn#126.com(#换成@)

Copyright © 2020 代码驿站 版权所有