程序员的第一个冰墩墩
我只是想要一个冰墩墩~~~
注:五环位置和beijin2022标识位置根据个人喜好进行了一定的修改!
这里使用的海龟绘图 海龟基本使用指南~
turtle.title # 项目名
turtle.speed() # 画画速度
turtle.penup() # 提笔
turtle.goto(坐标) # 到达位置
turtle.pencolor('color') # 画笔颜色
turtle.pensize() # 画笔粗度
turtle.fillcolor('color') # 填充颜色
turtle.begin_fill() # 进行填充
turtle.pendown() # 落笔
turtle.setheading() # 落笔朝向
turtle.circle() # 画圆
代码查看
# TIME : 2022年2月9日16:05:21
# Author : 三岁
# Description : pyBingDwnDwn
# name : pyBingDwnDwn.py
import turtle as t
t.title('pyBingDwnDwn') # 图片名
t.speed(100) # 速度
# 轮廓
# 头顶
t.penup() # 提笔
t.goto(-73, 230) # 到达位置
t.pencolor('lightgray') # 画笔颜色
t.pensize(3) # 画笔粗度
t.fillcolor('white') # 填充颜色
t.begin_fill() # 进行填充
t.pendown() # 落笔
t.setheading(20) # 落笔朝向
t.circle(-250, 35) # 画圆
# 左耳
t.setheading(50)
t.circle(-42, 180)
# 左侧
t.setheading(-50)
t.circle(-190, 30)
t.circle(-320, 45)
# 左腿
t.circle(120, 30)
t.circle(200, 12)
t.circle(-18, 85)
t.circle(-180, 23)
t.circle(-20, 110)
t.circle(15, 115)
t.circle(100, 12)
# 右腿
t.circle(15, 120)
t.circle(-15, 110)
t.circle(-150, 30)
t.circle(-15, 70)
t.circle(-150, 10)
t.circle(200, 35)
t.circle(-150, 20)
# 右手
t.setheading(-120)
t.circle(50, 30)
t.circle(-35, 200)
t.circle(-300, 23)
# 右侧
t.setheading(86)
t.circle(-300, 26)
# 右耳
t.setheading(122)
t.circle(-53, 160)
t.end_fill()
# 右内耳
t.penup()
t.goto(-130, 180)
t.pencolor('black')
t.pensize(1)
t.fillcolor('black')
t.begin_fill()
t.pendown()
t.setheading(120)
t.circle(-28, 160)
t.setheading(210)
t.circle(150, 20)
t.end_fill()
# 左内耳
t.penup()
t.goto(90, 230)
t.setheading(40)
t.begin_fill()
# t.fillcolor('black')
t.pendown()
t.circle(-30, 170)
t.setheading(125)
t.circle(150, 23)
t.end_fill()
# 右手内
t.penup()
t.goto(-180, -55)
t.fillcolor('black')
t.begin_fill()
t.setheading(-120)
t.pendown()
t.circle(50, 30)
t.circle(-27, 200)
t.circle(-300, 20)
t.setheading(-90)
t.circle(300, 14)
t.end_fill()
# 左手
t.penup()
t.goto(177, 112)
t.pencolor('lightgray')
t.pensize(3)
t.fillcolor('black')
t.begin_fill()
t.pendown()
t.setheading(80)
t.circle(-45, 200)
t.circle(-300, 25)
t.end_fill()
# 左手内
t.penup()
t.goto(182, 95)
t.pencolor('black')
t.pensize(1)
t.fillcolor('black')
t.begin_fill()
t.setheading(95)
t.pendown()
t.circle(-37, 160)
t.circle(-20, 50)
t.circle(-200, 30)
t.end_fill()
# 左腿内
t.penup()
t.goto(108, -168)
t.fillcolor("black")
t.begin_fill()
t.pendown()
t.setheading(-115)
t.circle(110, 15)
t.circle(200, 10)
t.circle(-18, 80)
t.circle(-180, 13)
t.circle(-20, 90)
t.circle(15, 60)
t.setheading(42)
t.circle(-200, 29)
t.end_fill()
# 右内腿
t.penup()
t.goto(-38, -210)
t.fillcolor("black")
t.begin_fill()
t.pendown()
t.setheading(-155)
t.circle(15, 100)
t.circle(-10, 110)
t.circle(-100, 30)
t.circle(-15, 65)
t.circle(-100, 10)
t.circle(200, 15)
t.setheading(-14)
t.circle(-200, 27)
t.end_fill()
# 右眼
# 眼圈
t.penup()
t.goto(-64, 120)
t.begin_fill()
t.pendown()
t.setheading(40)
t.circle(-35, 152)
t.circle(-100, 50)
t.circle(-35, 130)
t.circle(-100, 50)
t.end_fill()
# 眼珠
t.penup()
t.goto(-47, 55)
t.fillcolor('white')
t.begin_fill()
t.pendown()
t.setheading(0)
t.circle(25, 360)
t.end_fill()
t.penup()
t.goto(-45, 62)
t.pencolor('darkslategray')
t.fillcolor('darkslategray')
t.begin_fill()
t.pendown()
t.setheading(0)
t.circle(19, 360)
t.end_fill()
t.penup()
t.goto(-45, 68)
t.fillcolor('black')
t.begin_fill()
t.pendown()
t.setheading(0)
t.circle(10, 360)
t.end_fill()
t.penup()
t.goto(-47, 86)
t.pencolor('white')
t.fillcolor('white')
t.begin_fill()
t.pendown()
t.setheading(0)
t.circle(5, 360)
t.end_fill()
# 左眼
# 眼圈
t.penup()
t.goto(51, 82)
t.fillcolor('black')
t.begin_fill()
t.pendown()
t.setheading(120)
t.circle(-32, 152)
t.circle(-100, 55)
t.circle(-25, 120)
t.circle(-120, 45)
t.end_fill()
# 眼珠
t.penup()
t.goto(79, 60)
t.fillcolor('white')
t.begin_fill()
t.pendown()
t.setheading(0)
t.circle(24, 360)
t.end_fill()
t.penup()
t.goto(79, 64)
t.pencolor('darkslategray')
t.fillcolor('darkslategray')
t.begin_fill()
t.pendown()
t.setheading(0)
t.circle(19, 360)
t.end_fill()
t.penup()
t.goto(79, 70)
t.fillcolor('black')
t.begin_fill()
t.pendown()
t.setheading(0)
t.circle(10, 360)
t.end_fill()
t.penup()
t.goto(79, 88)
t.pencolor('white')
t.fillcolor('white')
t.begin_fill()
t.pendown()
t.setheading(0)
t.circle(5, 360)
t.end_fill()
# 鼻子
t.penup()
t.goto(37, 80)
t.fillcolor('black')
t.begin_fill()
t.pendown()
t.circle(-8, 130)
t.circle(-22, 100)
t.circle(-8, 130)
t.end_fill()
# 嘴
t.penup()
t.goto(-15, 48)
t.setheading(-36)
t.begin_fill()
t.pendown()
t.circle(60, 70)
t.setheading(-132)
t.circle(-45, 100)
t.end_fill()
# 圈圈
t.penup()
t.goto(-135, 120)
t.pensize(5)
t.pencolor('cyan') # 蓝青色
t.pendown()
t.setheading(60)
t.circle(-165, 150)
t.circle(-130, 78)
t.circle(-250, 30)
t.circle(-138, 105)
t.penup()
t.goto(-131, 116)
t.pencolor('slateblue') # 蓝色
t.pendown()
t.setheading(60)
t.circle(-160, 144)
t.circle(-120, 78)
t.circle(-242, 30)
t.circle(-135, 105)
t.penup()
t.goto(-127, 112)
t.pencolor('orangered') # 橙色
t.pendown()
t.setheading(60)
t.circle(-155, 136)
t.circle(-116, 86)
t.circle(-220, 30)
t.circle(-134, 103)
t.penup()
t.goto(-123, 108)
t.pencolor('gold') # 金色
t.pendown()
t.setheading(60)
t.circle(-150, 136)
t.circle(-104, 86)
t.circle(-220, 30)
t.circle(-126, 102)
t.penup()
t.goto(-120, 104)
t.pencolor('greenyellow') # 黄绿色
t.pendown()
t.setheading(60)
t.circle(-145, 136)
t.circle(-90, 83)
t.circle(-220, 30)
t.circle(-120, 100)
# 爱心
t.penup()
t.goto(220, 115)
t.pencolor('brown')
t.pensize(1)
t.fillcolor('brown')
t.begin_fill()
t.pendown()
t.setheading(36)
t.circle(-8, 180)
t.circle(-60, 24)
t.setheading(110)
t.circle(-60, 24)
t.circle(-8, 180)
t.end_fill()
# 五环
t.penup()
t.goto(-7, -145)
t.pendown()
t.pencolor('blue') # 蓝色
t.circle(6)
t.penup()
t.goto(8, -145)
t.pendown()
t.pencolor('black') # 黑色
t.circle(6)
t.penup()
t.goto(21, -145)
t.pendown()
t.pencolor('brown') # 褐色
t.circle(6)
t.penup()
t.goto(0, -150)
t.pendown()
t.pencolor('red') # 红色
t.circle(6)
t.penup()
t.goto(14, -150)
t.pendown()
t.pencolor('green') # 绿色
t.circle(6)
t.penup()
t.pencolor('black')
t.goto(-21, -135)
t.write('BEIJING 2022', font=('Arial', 10, 'bold italic'))
t.hideturtle() # 海龟画柄消失
t.done()
基于以上代码我们就可以获得一个可以动的冰墩墩啦~~~
如果怕环境无法安排可以使用我们的qpt打包系统进行打包
安装qpt:
python -m pip install qpt -i https://mirrors.bfsu.edu.cn/pypi/web/simple
# pyname : dabao.py
# 导入QPT
from qpt.executor import CreateExecutableModule as CEM
# -----关于路径的部分,强烈建议使用绝对路径避免出现问题-----
module = CEM(work_dir="./pyBingDwnDwn",
launcher_py_path="./pyBingDwnDwn/pyBingDwnDwn.py",
save_path="./out",
hidden_terminal=True,
icon="bingdwndwn.png")
# 开始打包
module.make()
最后就可以获得一个冰墩墩为图案的exe文件啦~
具体使用可以参考:github.com/GT-zhangace…