⽤Python画⼀颗⼼、⼩⼈发射爱⼼(附源码)前⾔
distributes
本⽂的⽂字及图⽚来源于⽹络,仅供学习、交流使⽤,不具有任何商业⽤途,如有问题请及时以作处理。
PS:如有需要Python学习资料的⼩伙伴可以点击下⽅链接⾃⾏获取
先画⼀个爱⼼,
网页设计制作教学
源代码:
#!/usr/bin/env python
# -*- coding:utf-8 -*-
import turtle
import time
# 画⼼形圆弧
def hart_arc():
for i in range(200):
turtle.right(1)
turtle.forward(2)
def move_pen_position(x, y):
turtle.hideturtle()    # 隐藏画笔(先)
turtle.up()    # 提笔
<(x, y)    # 移动画笔到指定起始坐标(窗⼝中⼼为0,0)
turtle.down()  # 下笔
labview字符串转数字turtle.showturtle()    # 显⽰画笔
# 初始化
turtle.setup(width=800, height=500)    # 窗⼝(画布)⼤⼩
turtle.pensize(3)      # 画笔粗细
turtle.speed(1)    # 描绘速度
# 初始化画笔起始坐标
move_pen_position(x=0,y=-180)  # 移动画笔位置
turtle.left(140)    # 向左旋转140度
turtle.begin_fill()    # 标记背景填充位置
# 画⼼形直线(左下⽅)
turtle.forward(224)    # 向前移动画笔,长度为224
# 画爱⼼圆弧
hart_arc()      # 左侧圆弧
turtle.left(120)    # 调整画笔⾓度
hart_arc()      # 右侧圆弧
# 画⼼形直线(右下⽅)
turtle.forward(224)
# 点击窗⼝关闭程序
window = turtle.Screen() itonclick()
⼩⼈发射爱⼼源码程序运⾏截图
import turtle as t
from time import sleep def go_to(x, y):
t.up()
<(x, y)
t.down()
def head(x, y, r):
go_to(x, y)
t.speed(20)
t.circle(r)
leg(x, y)
def leg(x, y):
t.right(90)
t.forward(180)
t.right(30)
t.forward(100)
t.left(120)
go_to(x, y - 180)
t.forward(100)
python代码画图案t.right(120)
t.forward(100)
t.left(120)
hand(x, y)
def hand(x, y):
go_to(x, y - 60)
t.forward(100)
t.left(60)
t.forward(100)
go_to(x, y - 90)
t.right(60)
t.forward(100)
t.right(60)
t.forward(100)
t.left(60)
eye(x, y)
def eye(x, y):
go_to(x - 50, y + 130)
t.right(90)
t.forward(50)
go_to(x + 40, y + 130)
t.forward(50)
t.left(90)
def big_Circle(size):
t.speed(20)
for i in range(150):
t.forward(size)
t.right(0.3)
def line(size):
t.speed(20)
t.forward(51 * size)
def small_Circle(size):
t.speed(20)
for i in range(210):
t.forward(size)
t.right(0.786)
def heart(x, y, size):
go_to(x, y)
t.left(150)
t.begin_fill()
line(size)
big_Circle(size)
small_Circle(size)
t.left(120)
small_Circle(size)
big_Circle(size)
line(size)
def main():
免费奖励自己的网站原神t.pensize(2)
head(-120, 100, 100)
heart(250, -80, 1)
go_to(100, -300)
t.write("To: Python青灯教育", move=True, align="left", font=("楷体", 20, "normal"))    t.done()
web安全攻防电子版
main()

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。