科普:皮卡丘是日本任天堂公司开发的掌机游戏系列《口袋妖怪》中登场精灵中的一种,为口袋妖怪里代表性的角色。

随着其周边动画宠物小精灵(即神奇宝贝)动画的热播,这只神奇宝贝的魅力逐渐开始被低年龄层的玩家所接受,随之带动的是女性玩家,标志着这股皮卡丘风潮的到来。

今天我将和大家一起用python脚本来绘制萌萌哒皮卡丘。。。

1. 首先来看看python皮卡丘代码绘制成品

2. 分解python代码讲解

2.1 下载并加载库

turtle库(相当于给你一支画笔,你可以在画布上用数学逻辑控制的代码完成绘图)

random库from turtle import *

import turtle as t

from random import *

2.2 接下来挑选中间的一段代码进行讲解,其它代码放在最后总代码中,有疑问可以在公众号后台咨询我,也可以通过文末我的联系方式和我讨论。"""画嘴"""

color("black", "#F35590") #设置颜色

# 下嘴弧度并填充颜色

penup() #提起画笔,用于另起一个地方绘制时使用

goto(-100, 72) #移动到绝对坐标(-100,72)处

pendown() #放下画笔,移到指定点(-100,72)后继续绘制

begin_fill() #填充图形前,调用该方法

setheading(260) #设置当前朝向为260度

forward(60) #沿着当前方向前进指定距离

circle(-11, 150) #绘制一个指定半径(-11),角度(150)的弧形

forward(55) #沿着当前方向前进指定距离

print(position()) #打印当前位置

penup()

goto(-128.46, 71.97)

pendown()

end_fill() #填充图形结束和begin_fill配对使用

#嘴中最上方的阴影部分

color("#6A070D", "#6A070D") #设置填充颜色

begin_fill() #用上行代码设定的颜色开始填充

penup() #抬起画笔

goto(-99.00, 72.00) #移动到绝对位置(-99.00, 72.00)

pendown() #放下画笔

penup() #抬起画笔

goto(-104.29, 48.3) #移动到绝对位置(-104.29, 48.3)

pendown() #放下画笔

penup() #抬起画笔

goto(-142, 45) #移动到绝对位置(-142, 45)

pendown() #放下画笔

penup() #抬起画笔

goto(-150.40, 62.74) #移动到绝对位置(-150.40, 62.74)

pendown() #放下画笔

penup()

goto(-128.46, 71.97)

pendown()

penup()

goto(-99.00, 72.00)

pendown()

end_fill()

#注:不停地放下和抬起画笔其实就是围城一个待填充特定颜色的区域

#上嘴唇

color("black","#FFD624")

penup()

goto(-168, 65)

pendown()

begin_fill()

setheading(-25)

for i in range(2):

setheading(-25)

circle(35, 70)

end_fill()

#嘴中第二个阴影部分

color("#AB1945", "#AB1945")

penup()

goto(-142, 45)

pendown()

begin_fill()

setheading(40)

circle(-33, 70)

goto(-104,48.3)

penup()

goto(-108,33)

pendown()

setheading(155)

circle(25, 70)

end_fill()

3. 全部代码

注:代码中的假期愉快可以替换成任何你想替换的文字# coding:utf-8

from turtle import *

import turtle as t

from random import *

def 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(1)

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()

# 左脸

t.begin_fill()

t.fillcolor("pink")

print('左脸')

t.seth(330)

t.circle(50, -90)

infoPrt()

# 左酒窝

t.seth(30)

t.circle(-15, 120)

t.seth(-70)

t.circle(-30, 90)

t.end_fill()

# 左手

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.begin_fill()

t.fillcolor("pink")

t.pu()

t.setpos(t.xcor()-40,t.ycor()+110)

t.pd()

t.circle(27, 360)

t.end_fill()

#x-20 ,y+50

"""画嘴"""

color("black", "#F35590")

# 下嘴弧度并填充颜色

penup()

goto(-100, 72)

pendown()

begin_fill()

setheading(260)

forward(60)

circle(-11, 150)

forward(55)

print(position())

penup()

goto(-128.46, 71.97)

pendown()

end_fill()

#嘴中最上方的阴影部分

color("#6A070D", "#6A070D")

begin_fill()

penup()

goto(-99.00, 72.00)

pendown()

penup()

goto(-104.29, 48.3)

pendown()

penup()

goto(-142, 45)

pendown()

penup()

goto(-150.40, 62.74)

pendown()

penup()

goto(-128.46, 71.97)

pendown()

penup()

goto(-99.00, 72.00)

pendown()

end_fill()

#上嘴唇

color("black","#FFD624")

penup()

goto(-168, 65)

pendown()

begin_fill()

setheading(-25)

for i in range(2):

setheading(-25)

circle(35, 70)

end_fill()

#嘴中第二个阴影部分

color("#AB1945", "#AB1945")

penup()

goto(-142, 45)

pendown()

begin_fill()

setheading(40)

circle(-33, 70)

goto(-104,48.3)

penup()

goto(-108,33)

pendown()

setheading(155)

circle(25, 70)

end_fill()

# 左眼

t.pu()

t.color("black")

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.screensize(50,50,bg='yellow')

# 输出文字

printer = t.Turtle()

printer.hideturtle()

printer.penup()

printer.goto(-350,-100)

printer.write("假\n\n",move = True, align="left", font=("楷体", 30, "bold"))

printer.goto(-350,-150)

printer.write("期\n\n",move = True, align="left", font=("楷体", 30, "bold"))

printer.goto(-350,-200)

printer.write("愉\n\n",move = True, align="left", font=("楷体", 30, "bold"))

printer.goto(-350,-250)

printer.write("快!\n\n",move = True, align="left", font=("楷体", 30, "bold"))

t.hideturtle()

t.done()

python绘制皮卡丘 dongdong_用python绘制皮卡丘相关推荐

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

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

  2. 用代码写出浪漫__合集(python、matplotlib、Matlab、java绘制爱心、玫瑰花、前端特效玫瑰、爱心)

    活动地址:CSDN21天学习挑战赛 用代码写出浪漫合集(爱心.玫瑰花)       本文目录: ​一.前言 二.用python.matplotlib.Matlab.java绘制爱心 (1)爱心图形1( ...

  3. python turtle画滑稽_使用python的turtle函数绘制一个滑稽表情的方法

    Turtle库是Python语言中一个很流行的绘制图像的函数库,想象一个小乌龟,在一个横轴为x.纵轴为y的坐标系原点,(0,0)位置开始,它根据一组函数指令的控制,在这个平面坐标系中移动,从而在它爬行 ...

  4. python采用Basemap绘制完美中国地图(包括绘制边界框,随机点等)

    python采用Basemap绘制完美中国地图(包括绘制边界框,随机点等) 1. 效果图 2. 原理 2.1 依赖模块及安装 2.2 工程目录 2.3 依赖文件latlng.txt 经纬度 3 源码 ...

  5. python实现matlab中的diff,Python实现matlab数据绘制

    自从使用python脚本后,经常用来调试数据的matlab终于有了一个简单易用的替代方案,相比matlab的.m语言,我更喜欢用python来解决.毕竟在python当中,相比.m主意很多编程工作都可 ...

  6. python如何实现matlab_Python实现matlab数据绘制

    自从使用python脚本后,经常用来调试数据的matlab终于有了一个简单易用的替代方案,相比matlab的.m语言,我更喜欢用python来解决.毕竟在python当中,相比.m主意很多编程工作都可 ...

  7. python画统计图代码_Python使用统计函数绘制简单图形实例代码

    前言 Matplotlib 是 Python 的绘图库. 它可与 NumPy 一起使用,提供了一种有效的 MatLab 开源替代方案. 它也可以和图形工具包一起使用,如 PyQt 和 wxPython ...

  8. python蟒蛇代码_011 实例2-Python蟒蛇绘制

    一."Python蟒蛇绘制"问题分析 1.1 Python蟒蛇绘制 用程序绘制一条蟒蛇 貌似很有趣,可以来试试 先学会蟒蛇绘制,再绘朵玫瑰花送给TA 设计蟒蛇的基本形状: 问题1: ...

  9. python架构图教程_Python 五分钟绘制漂亮的系统架构图

    Diagrams  是一个基于Python绘制云系统架构的模块,它能够通过非常简单的描述就能可视化架构,并支持以下6个云产品的图标: AWS.Azure.GCP.K8s.阿里云 和 Oracle 云 ...

最新文章

  1. JDBC—02—JDBC的使用;
  2. 分页池内存持续增长_Java技术学习之对虚拟机(JVM)内存模型的分析
  3. 《Python编程从入门到实践》学习笔记8(第9章:类)
  4. 【转】C# HttpWebRequest提交数据方式
  5. 【web前端干货】JavaScript是什么?JavaScript有哪些特点?
  6. python装饰器实现用户密码认证(简单初形)
  7. 乐玩自动化测试模块_深圳大数据测试培训推荐班
  8. supervisor 启动ElasticSearch报错问题
  9. Axure RP 8汉化
  10. 高端物理学名词_物理专业名词
  11. 逻辑回归及美团逻辑回归总结
  12. el-dialog 圆角 白边问题
  13. 交互设计师作品集网站整理
  14. Java 基础知识随笔1
  15. UOS安装mysql
  16. 实用功能#用Python给你的微信升升级吧
  17. mac 无法打开“XXXXXXX.app”,因为无法确认开发者的身份。
  18. 02 【版本控制命令】
  19. 【视频课】10大真实金融量化交易案例,20多小时Python进阶课!
  20. 微软亚洲研究院推出“人立方”人物关系搜索

热门文章

  1. APP分析之海豚睡眠
  2. 解决win11桌面右键创建只有一个带盾牌的文件夹问题
  3. 95平方奶油色系住宅设计 超暖心!
  4. 抖音引流效果怎么样?三种有效方法,抖音获客小技巧
  5. 【AI视野·今日Robot 机器人论文速览 第三十三期】Thu, 21 Apr 2022
  6. 原生js获取元素高度
  7. springboot的应用(springboot+定时任务+发邮件)
  8. 计算机辅助设计是运用计算机,计算机辅助设计在艺术设计中的应用
  9. Excel怎么快速将多个工作表反向排列
  10. 优秀的拆分(位运算)