大家都知道皮卡丘是贼可爱的样子,但是如何用Python来实现这样一个可爱的形象呢,来,先上效果图


实现的代码奉上:
第一个图片的代码:

# coding:utf-8
import turtle as tdef infoPrt():print('coordinate: ' + str(t.pos()))print('angle: ' + str(t.heading()))t.pensize(3)
t.hideturtle()
t.colormode(255)
t.color("black")
t.setup(700, 650)
t.speed(10)
t.st()
#t.dot()
t.pu()
#t.goto(-150,100)
t.goto(-210,86)
t.pd()
infoPrt()# 头
print('头')
t.seth(85)
t.circle(-100,50)
#t.seth(78)
#t.circle(-100,25)infoPrt()t.seth(25)
t.circle(-170,50)
infoPrt()# 右耳
print('右耳')
t.seth(40)
#t.circle(-250,52)
t.circle(-250,30)
infoPrt()# 右耳尖
t.begin_fill()
# 左
t.circle(-250,22)
#t.fillcolor("pink")
# 右
t.seth(227)
t.circle(-270, 15)prePos = t.pos()
infoPrt()
# 下
t.seth(105)
t.circle(100, 32)
t.end_fill()t.pu()
t.setpos(prePos)
t.pd()
t.seth(212)
t.circle(-270, 28)prePos = t.pos()
t.pu()
t.goto(t.xcor()+5,t.ycor()-2)
t.pd()# 躯干
print('躯干')
t.seth(280)
t.circle(500, 30)
infoPrt()# 臀部
print('臀部')
t.seth(120)
#t.circle(150, -55)
t.circle(150, -11)
p_tail=t.pos()
t.circle(150, -44)
p_butt=t.pos()
infoPrt()# 尾巴
t.pu()
t.setpos(p_tail)
t.pd()t.begin_fill()
t.seth(50)
t.fd(25)
t.seth(-50)
t.fd(30)
p_tail1=t.pos
t.seth(-140)
t.fd(36)
t.end_fill()
t.seth(39)
# 右尾和h1
t.fd(72)
# 右尾和v1
t.seth(125)
t.fd(48)
# 右尾和h2
t.seth(40)
t.fd(53)
# 右尾和v2
t.seth(88)
t.fd(45)
# 右尾和h3
t.seth(35)
t.fd(105)
# 右尾和v3
t.seth(105)
t.circle(850, 8)
#t.fd(105)
t.seth(215)
#t.fd(125)
t.circle(850, 11)
t.seth(280)
t.fd(110)
t.seth(220)
t.fd(50)
t.seth(309)
t.fd(56)# 底盘
print('底盘')
t.pu()
t.setpos(p_butt)
t.pd()
t.seth(20)
t.circle(120, -45)
infoPrt()t.seth(330)
t.circle(-150, -30)
infoPrt()prePos = t.pos()
t.pu()
t.goto(t.xcor()+20,t.ycor())
t.pd()t.seth(230)
t.circle(-70, 120)
p_bot=t.pos()# 两脚-right
t.pu()
t.setpos(p_butt)
t.setpos(t.xcor()+5,t.ycor()+5)
t.pd()
t.seth(-86)
t.fd(30)
t.seth(-93)
t.fd(33)
t.seth(-225)
t.circle(-150, 22)
# 两脚-left
t.pu()
t.setpos(p_bot)
t.setpos(t.xcor()+85,t.ycor()-43)
t.pd()
t.seth(-105)
t.fd(50)
t.seth(-225)
t.circle(-150, 22)# 左躯干
print('躯干')
t.pu()
t.setpos(p_bot)
t.pd()
t.seth(90)
t.circle(450, 13)
p_lfhd = t.pos()
t.circle(450, 5)
t.pu()
t.circle(450, 5)
t.pd()
t.circle(450, 6)
infoPrt()# 左脸
print('左脸')
t.seth(330)
t.circle(50, -90)
infoPrt()# 左酒窝
t.seth(30)
t.circle(-15, 120)
t.seth(-70)
t.circle(-30, 90)# 左手
t.pu()
t.setpos(p_lfhd)
t.pd()
t.seth(160)
t.circle(150, 30)
infoPrt()t.seth(180)
t.circle(-30, 150)
t.fd(67)t.pu()
t.setpos(t.xcor()-40,t.ycor()-60)
t.pd()
t.seth(200)
t.circle(-5, 180)# 右手
t.pu()
t.setpos(p_lfhd)
t.setpos(t.xcor()+180,t.ycor()+5)
t.pd()
t.seth(200)
t.circle(-50, 100)
t.pu()
t.circle(-50, 15)
t.pd()
t.circle(-50, 65)
t.pu()
t.setpos(t.xcor()+10,t.ycor()-45)
t.pd()
#t.seth(270)
#t.circle(-30, -180)
t.seth(80)
t.fd(10)
t.seth(165)
t.circle(10, 60)
t.seth(90)
t.fd(5)
t.seth(165)
t.circle(10, 60)
t.seth(95)
t.fd(5)
t.seth(185)
t.circle(10, 60)
t.seth(105)
t.fd(10)
t.seth(230)
t.fd(20)
t.seth(145)
t.fd(10)
t.seth(285)
t.fd(20)# 右酒窝
t.pu()
t.setpos(t.xcor()-40,t.ycor()+110)
t.pd()
t.circle(27, 360)# 嘴
t.pu()
t.setpos(t.xcor()-30,t.ycor()+28)
t.pd()
t.seth(280)
t.circle(-130, 30)
t.seth(270)
t.circle(-6, 160)
t.seth(130)
t.circle(-130, 30)
t.pu()
t.setpos(t.xcor()-5,t.ycor()+5)
t.pd()
t.seth(160)
t.circle(-20, -70)
t.seth(160)
t.circle(-30, -60)
t.pu()
t.setpos(t.xcor(),t.ycor()-28)
t.pd()
t.seth(200)
t.circle(50, 58)# 左眼
t.pu()
t.setpos(t.xcor()-40,t.ycor()+90)
t.pd()
t.circle(5)
t.pu()
t.setpos(t.xcor()+5,t.ycor()+10)
t.pd()
t.begin_fill()
t.seth(190)
t.circle(15, 130)
t.seth(310)
t.circle(10, 15)
t.seth(0)
t.circle(17, 133)
t.seth(90)
t.circle(10, 15)
t.end_fill()
t.pu()
t.setpos(t.xcor()+2,t.ycor()-15)
t.pd()
t.color("white")
t.begin_fill()
t.circle(5)
t.end_fill()# 右眼
t.pu()
t.setpos(t.xcor()+85,t.ycor()+15)
t.pd()
t.color("black")
t.circle(5)
t.pu()
t.setpos(t.xcor()+5,t.ycor()+10)
t.pd()
t.begin_fill()
t.seth(190)
t.circle(20, 130)
t.seth(310)
t.circle(10, 15)
t.seth(0)
t.circle(22, 133)
t.seth(90)
t.circle(13, 15)
t.end_fill()
t.pu()
t.setpos(t.xcor()-7,t.ycor()-15)
t.pd()
t.color("white")
t.begin_fill()
t.circle(7)
t.end_fill()# 左耳
t.color("black")
t.pu()
t.goto(-210,86)
t.setpos(t.xcor()+15,t.ycor()+38)
t.pd()
t.seth(90)
t.circle(-250,30)t.begin_fill()
# 左
t.circle(-250,18)# 右
t.seth(270)
t.circle(-270, 12)prePos = t.pos()
# 下
t.seth(180)
t.circle(100, 30)
t.end_fill()t.pu()
t.setpos(prePos)
t.pd()
t.seth(270)
t.circle(-270, 18)t.done()

第二个动态图的代码:

import turtle as tdef nose():t.penup()t.seth(90)t.fd(100)t.pendown()t.begin_fill()t.fillcolor('black')t.seth(45)t.fd(25)t.seth(135)t.circle(25,90)t.seth(315)t.fd(25)t.end_fill()def eyes(seth,fd,c):t.penup()t.seth(seth)t.fd(fd)t.pendown()t.begin_fill()t.fillcolor('black')t.circle(50)t.end_fill()t.penup()t.circle(50, c)t.pendown()t.begin_fill()t.fillcolor('white')t.circle(20)t.end_fill()def face(seth,fd):t.penup()t.seth(seth)t.fd(fd)t.pendown()t.begin_fill()t.fillcolor('red')t.circle(70)t.end_fill()def lip():t.penup()t.seth(135)t.fd(250)t.pendown()t.seth(-300)t.circle(30, -65)t.begin_fill()t.fillcolor('Firebrick')t.seth(165)t.fd(140)t.seth(195)t.fd(140)t.seth(-360)t.circle(30, -65)t.penup()t.seth(-60)t.circle(30, 65)t.pendown()t.seth(-70)t.fd(240)t.circle(55, 140)t.seth(70)t.fd(240)t.end_fill()t.seth(-110)t.fd(80)t.begin_fill()t.fillcolor('Firebrick1')t.seth(120)t.circle(120, 123)t.seth(-70)t.fd(165)t.circle(55, 140)t.seth(72)t.fd(165)t.end_fill()def setting():t.pensize(4)t.hideturtle()t.setup(1000, 600)t.speed(10)t.screensize(bg='yellow')def main():setting()nose()eyes(160, 250, 60)eyes(-9.5, 530, 230)face(195, 600)face(-11, 720)lip()t.done()if __name__ =='__main__':main()

如果没有装python ,没有关系,我这里将.py的文件用pyinstaller模块加载成.exe文件了,具体方法是
将py文件打包成exe文件在windows上运行
但是,有一个问题是这个.exe的文件想要打开必须需要他文件夹里面其他文件的支持,因此,我把真个文件都整在一个文件夹里面
里面有两个文件夹,他们分别代表是上面图,然后分别打开文件找到
直接运行就行。
最后奉上,这个文件夹的连接链接:https://pan.baidu.com/s/1ltOWKKpSt14RfR8uaVgRKg
提取码:jmz3

谢谢关注

python 实现一个皮卡丘的动画图相关推荐

  1. 怎么用python画一个皮卡丘,用python画皮卡丘的代码

    python皮卡丘编程代码 import turtledef getPosition(x, y): (x) (y) print(x, y)class Pikachu: def __init__(sel ...

  2. html5做一个皮卡丘,画一只会动的皮卡丘(上)

    实现的皮卡丘样式以下图: 本篇内容List: tip1--全局样式初始化,配置 tip2--实现鼻子 tip3--实现眼睛 tip4--实现脸颊 tip5--嘴巴实现 1.先进行页面总体的样式配置 这 ...

  3. python canvas画弧度_编程作战丨如何利用python绘制可爱皮卡丘?

    好莱坞真人电影<精灵宝可梦:大侦探皮卡丘>预告片已经发布了,正片将于今年5月10日上映. 如果要做一个「童年梦想排行榜」的话,相信「拥有一只皮卡丘」这个梦想一定会名列前茅! 毕竟,谁不想揉 ...

  4. python打印皮卡丘步骤_编程作战丨如何利用python绘制可爱皮卡丘?

    好莱坞真人电影<精灵宝可梦:大侦探皮卡丘>预告片已经发布了,正片将于今年5月10日上映. 如果要做一个「童年梦想排行榜」的话,相信「拥有一只皮卡丘」这个梦想一定会名列前茅! 毕竟,谁不想揉 ...

  5. python画卡通皮卡丘_实现童年Pokémon,教你用Python画一只属于自己的皮卡丘

    原标题:实现童年Pokémon,教你用Python画一只属于自己的皮卡丘 大数据文摘出品 作者:李雷.蒋宝尚 还记得小时候疯狂收集和交换神奇宝贝卡片的经历吗? 还记得和小伙伴拿着精灵球,一起召唤小精灵 ...

  6. python海龟图画皮卡丘_用python画一只皮卡丘

    不知道大家前段儿时间 有没有看电影<大侦探皮卡丘> 点击播放 GIF 0.1M 肯定很多人都已经被 皮卡丘的可爱 迷得神魂颠倒 那么今天 我们就来用python 画一只皮卡丘吧~ 开发工具 ...

  7. python画只皮卡丘

    今天没事敲了一下python发现好久都没用过海龟画图了,今个画了一只简单版的皮卡丘 下附代码: #接下来请欣赏像素风皮卡丘 import turtle as a def wz(x,y):#设置一个以海 ...

  8. 用python画动态皮卡丘_如何利用python绘制可爱皮卡丘?

    这个非常简单,主要用到turtle这个模块,一个绘图函数库,可以快速绘制平面二维图形,下面我简单介绍一下实现过程,主要分为鼻子.眼睛.脸.嘴巴这4个部分,实验环境win10+python3.6+pyc ...

  9. 几行Python代码画皮卡丘

    导语: 哈喽吖~   小编相信大家都不会拒绝一只会皮卡皮卡!皮卡丘~的小可爱吧,今天小编用python给大家码一个

最新文章

  1. Android TextView 设置文字上下距离以及文字水平间距
  2. java 1099_【LeetCode(Java) - 1099】小于 K 的两数之和
  3. python codecs模块
  4. 中国的TD-LTE-Advanced被国际电联确立为4G标准!
  5. as 关联 android源码,android studio 2.x以上关联源码
  6. mysql文件怎么导入_mysql怎么导入sql文件
  7. zoj 1670 Jewels from Heaven
  8. PostgreSQL的日志文件和数据加载
  9. HiveServer2中使用jdbc客户端用户运行mapreduce
  10. Anaconda安装,linux操作系统学习
  11. logback读取src/test/resource下的配置文件
  12. 详解Android动画之Tween Animation
  13. vue3.0项目创建
  14. _IO, _IOR, _IOW, _IOWR 宏的用法与解析
  15. 分布式NoSQL数据库的Spring整合实践
  16. 创建可维护的自动化验收测试
  17. 弹簧优化设计MATLAB,基于MATLAB的弹簧优化设计.pdf
  18. 常见视频封装格式(1) — AVI
  19. 简单易用的运动控制卡(八):直线插补和手轮运动
  20. cmd修改计算机睡眠、休眠时间,批量命令

热门文章

  1. 超详细的 github 账号申请与 git 安装教程
  2. 广东有线U宽频的一些东西
  3. python编写的七夕
  4. java输入枚举型_Java 枚举型为什么是静态的,以及是怎么实现的?
  5. mysql安装时卡在starting server的解决方法
  6. 资源教程下载网类织梦网站模板
  7. 新垣结衣夫妇的baby长啥样,用 BabyGAN 预测试试
  8. 人们为什么要在微博、Facebook 等上发布自己的状态信息或者人生感悟?
  9. setscale方法的用法_BigDecimal.setScale用法总结
  10. Java代码实现PDF中表格导出到Excel