这篇文章主要介绍了python皮卡丘字符打印代码,具有一定借鉴价值,需要的朋友可以参考下。希望大家阅读完这篇文章后大有收获,下面让小编带着大家一起了解一下。
文 | 潮汐
来源:Python 技术「ID: pythonall」
今天是周六,祝大家周末愉快,昨天晚上小表弟来家里玩,给他看了皮卡丘动画片,突发奇想给他用 Python 画一个皮卡丘,也让他提前感受 Python 技术的强大与好玩之处,于是就有了今天的文章。
Python 画皮卡丘1
import turtle as t
def face(x, y):
"""画脸"""
t.begin_fill()
t.penup()
# 将海龟移动到指定的坐标
t.goto(x, y)
t.pendown()
# 设置海龟的方向
t.setheading(40)
t.circle(-150, 69)
t.fillcolor("#FBD624")
# 将海龟移动到指定的坐标
t.penup()
t.goto(53.14, 113.29)
t.pendown()
t.setheading(300)
t.circle(-150, 30)
t.setheading(295)
t.circle(-140, 20)
print(t.position())
t.forward(5)
t.setheading(260)
t.circle(-80, 70)
print(t.position())
t.penup()
t.goto(-74.43, -79.09)
t.pendown()
t.penup()
# 将海龟移动到指定的坐标
t.goto(-144, 103)
t.pendown()
t.setheading(242)
t.circle(110, 35)
t.right(10)
t.forward(10)
t.setheading(250)
t.circle(80, 115)
print(t.position())
t.penup()
t.goto(-74.43, -79.09)
t.pendown()
t.setheading(10)
t.penup()
t.goto(-144, 103)
t.pendown()
t.penup()
t.goto(x, y)
t.pendown()
t.end_fill()
# 下巴
t.penup()
t.goto(-50, -82.09)
t.pendown()
t.pencolor("#DDA120")
t.fillcolor("#DDA120")
t.begin_fill()
t.setheading(-12)
t.circle(120, 25)
t.setheading(-145)
t.forward(30)
t.setheading(180)
t.circle(-20, 20)
t.setheading(143)
t.forward(30)
t.end_fill()
# penup()
# # 将海龟移动到指定的坐标
# goto(0, 0)
# pendown()
def eye():
"""画眼睛"""
# 左眼
t.color("black", "black")
t.penup()
t.goto(-110, 27)
t.pendown()
t.begin_fill()
t.setheading(0)
t.circle(24)
t.end_fill()
# 左眼仁
t.color("white", "white")
t.penup()
t.goto(-105, 51)
t.pendown()
t.begin_fill()
t.setheading(0)
t.circle(10)
t.end_fill()
# 右眼
t.color("black", "black")
t.penup()
t.goto(25, 40)
t.pendown()
t.begin_fill()
t.setheading(0)
t.circle(24)
t.end_fill()
# 右眼仁
t.color("white", "white")
t.penup()
t.goto(17, 62)
t.pendown()
t.begin_fill()
t.setheading(0)
t.circle(10)
t.end_fill()
def cheek():
"""画脸颊"""
# 右边
t.color("#9E4406", "#FE2C21")
t.penup()
t.goto(-130, -50)
t.pendown()
t.begin_fill()
t.setheading(0)
t.circle(27)
t.end_fill()
# 左边
t.color("#9E4406", "#FE2C21")
t.penup()
t.goto(53, -20)
t.pendown()
t.begin_fill()
t.setheading(0)
t.circle(27)
t.end_fill()
def nose():
"""画鼻子"""
t.color("black", "black")
t.penup()
t.goto(-40, 38)
t.pendown()
t.begin_fill()
t.circle(7, steps=3)
t.end_fill()