Turtle库是Python语言中一个很流行的绘制图像的函数库,想象一个小乌龟,在一个横轴为x、纵轴为y的坐标系原点,(0,0)位置开始,它根据一组函数指令的控制,在这个平面坐标系中移动,从而在它爬行的路径上绘制了图形。
turtle基础知识参考:
https://gitchat.blog.csdn.net/article/details/90696190
https://blog.csdn.net/zhouheng2018/article/details/79809374#3-turtle空间坐标体系
奉上我的效果图

不得不说确实有不便之处,例如画不规则图案要经常试坐标,找距离,角度,耗费了很长时间,不过几何图形就方便很多了,下面上代码

#!/usr/bin/env python
# -*- coding:utf-8 -*-
from turtle import *
'''
绘制皮卡丘头部
'''
def face(x,y):"""画脸"""begin_fill()penup()# 将海龟移动到指定的坐标goto(x, y)pendown()# 设置海龟的方向setheading(40)circle(-150, 69)fillcolor("#FBD624")# 将海龟移动到指定的坐标penup()goto(53.14, 113.29)pendown()setheading(300)circle(-150, 30)setheading(295)circle(-140, 20)print(position())forward(5)setheading(260)circle(-80, 70)print(position())penup()goto(-74.43,-79.09)pendown()penup()# 将海龟移动到指定的坐标goto(-144,103)pendown()setheading(242)circle(110, 35)right(10)forward(10)setheading(250)circle(80, 115)print(position())penup()goto(-74.43,-79.09)pendown()setheading(10)penup()goto(-144, 103)pendown()penup()goto(x, y)pendown()end_fill()# 下巴penup()goto(-50, -82.09)pendown()pencolor("#DDA120")fillcolor("#DDA120")begin_fill()setheading(-12)circle(120, 25)setheading(-145)forward(30)setheading(180)circle(-20, 20)setheading(143)forward(30)end_fill()# penup()# # 将海龟移动到指定的坐标# goto(0, 0)# pendown()def eye():"""画眼睛"""# 左眼color("black","black")penup()goto(-110, 27)pendown()begin_fill()setheading(0)circle(24)end_fill()# 左眼仁color("white", "white")penup()goto(-105, 51)pendown()begin_fill()setheading(0)circle(10)end_fill()# 右眼color("black", "black")penup()goto(25, 40)pendown()begin_fill()setheading(0)circle(24)end_fill()# 右眼仁color("white", "white")penup()goto(17, 62)pendown()begin_fill()setheading(0)circle(10)end_fill()
def cheek():"""画脸颊"""# 右边color("#9E4406", "#FE2C21")penup()goto(-130, -50)pendown()begin_fill()setheading(0)circle(27)end_fill()# 左边color("#9E4406", "#FE2C21")penup()goto(53, -20)pendown()begin_fill()setheading(0)circle(27)end_fill()def nose():"""画鼻子"""color("black", "black")penup()goto(-40, 38)pendown()begin_fill()circle(7,steps = 3)end_fill()
def mouth():"""画嘴"""color("black", "#F35590")# 嘴唇penup()goto(-10, 22)pendown()begin_fill()setheading(260)forward(60)circle(-11, 150)forward(55)print(position())penup()goto(-38.46, 21.97)pendown()end_fill()# 舌头color("#6A070D", "#6A070D")begin_fill()penup()goto(-10.00, 22.00)pendown()penup()goto(-14.29, -1.7)pendown()penup()goto(-52, -5)pendown()penup()goto(-60.40, 12.74)pendown()penup()goto(-38.46, 21.97)pendown()penup()goto(-10.00, 22.00)pendown()end_fill()color("black","#FFD624")penup()goto(-78, 15)pendown()begin_fill()setheading(-25)for i in range(2):setheading(-25)circle(35, 70)end_fill()color("#AB1945", "#AB1945")penup()goto(-52, -5)pendown()begin_fill()setheading(40)circle(-33, 70)goto(-16,-1.7)penup()goto(-18,-17)pendown()setheading(155)circle(25, 70)end_fill()def ear():"""画耳朵"""# 左耳color("black","#FFD624")penup()goto(-145, 93)pendown()begin_fill()setheading(165)circle(-248,50)right(120)circle(-248,50)end_fill()color("black", "black")penup()goto(-240, 143)pendown()begin_fill()setheading(107)circle(-170, 25)left(80)circle(229, 15)left(120)circle(300, 15)end_fill()# 右耳color("black", "#FFD624")penup()goto(30, 136)pendown()begin_fill()setheading(64)circle(-248, 50)right(120)circle(-248, 50)end_fill()color("black", "black")penup()goto(160, 200)pendown()begin_fill()setheading(52)circle(170, 25)left(116)circle(229, 15)left(71)circle(-300, 15)end_fill()def setting():"""设置参数"""pensize(2)# 隐藏海龟hideturtle()speed(10)
def main():"""主函数"""setting()face(-132,115)eye()cheek()nose()mouth()ear()done()if __name__ == '__main__':main()

用Python turtle库 绘制皮卡丘相关推荐

  1. Python -- 大作业 — 使用turtle库画皮卡丘

    使用python的turtle库画皮卡丘 一.使用环境 在这里,我使用的是python 3.8.5版本的IDLE(也可以使用其他3.0以上版本,PyCharm也是可以的). 二.内容介绍 1.主要方法 ...

  2. Python Turtle库绘制小黄脸表情包

    Python Turtle库绘制小黄脸表情包 下面只有一个表情的代码 #!/usr/bin/env python # -*- coding:utf-8 -*- __author__: "TC ...

  3. Python turtle库绘制复杂漫威蜘蛛侠Spiderman

    演示效果 点击播放:Python123平台 济南大学_盛亚琪_spiderman (https://www.python123.io/index/turtles/5c95d01e24577506dc7 ...

  4. python画皮卡丘全身立体_超酷!用 Python 教你绘制皮卡丘和哆啦A梦

    本文利用 Python 绘制两个卡通角色,并带大家熟悉一下绘图程序包 turtle 的一些用法,先看一下 最终皮卡丘的绘制效果录制_2020_08_01_22_15_39_710.gif 在使用之前请 ...

  5. python random库画多彩蟒蛇,Python Turtle库绘制蟒蛇

    使用Python Turtle库来绘制蟒蛇 import turtle引入了海龟绘图体系 使用setup函数,设定了一个宽650像素和高350像素的窗体,其位置左上角坐标是200,200 说明位置在距 ...

  6. 使用python turtle库绘制一个三角形_使用turtle库绘制一个叠加等边三角形,图形效果如下:...

    原博文 2020-09-14 23:11 − import turtle turtle.setup(650,350,200,200) turtle.penup() turtle.pensize(1) ...

  7. 用Python turtle库绘制蟒蛇

    Python的函数库 Python语言与C语言Java类似,可以大量使用外部函数库包含在安装包中的函数库:. 比如math, random, turtle等其他函数库,其他函数库用户根据代码需求自行安 ...

  8. Python turtle库绘制同心圆

    今天了解了Python中用于绘制图像的turtle库 然后发现这真的是一个很好玩的库 放上大神的有关绘图的文章 https://blog.csdn.net/zengxiantao1994/articl ...

  9. 用python函数画德国国旗代码_每日一程-11.利用Python turtle库绘制国旗

    Author: Notus(hehe_xiao@qq.com) Create: 2019-02-19 Update: 2019-02-19 利用turtle模块绘制五星红旗 原理不算太复杂,只是需要稍 ...

最新文章

  1. Android环境变量的设置(详细图解版)
  2. luogu P3398 仓鼠找sugar(树链剖分、求树上两条路径有没有交点,爽!)
  3. R语言paste函数、paste0函数将多个输入组合成字符串实战
  4. 关于微信小程序登录授权
  5. Linux 操作系统原理 — 内存 — 基于局部性原理实现的内/外存交换技术
  6. 分布式事务是啥?常用的解决方案有哪些?
  7. python预测股票价格tushare_用tushare对股票进行简单分析
  8. Android开发中依赖注入的应用
  9. 既然开发了 飞鸽传书 就一定要帮助人
  10. 数据科学 IPython 笔记本 8.4 简单的折线图
  11. python怎么改变button的颜色_python – 改变Kivy中Button的背景颜色
  12. 微信小程序 View:flex 布局
  13. autosize px转dp_干货集中营
  14. 纷杂的Spring-boot-starter: 5 应用安全与spring-boot-starter-security
  15. HAR with Python WebDriver and BrowserMob Proxy
  16. 在Abaqus中怎么施加初始应力
  17. 如何制定一份测试工程师年度计划
  18. Hermez官方文档翻译(四)开发者-SDK (有自己测试验证demo)
  19. 华为p50鸿蒙系统5G5G,华为P50最新确认:2K屏+鸿蒙系统+5220mAh,这才是华为的实力...
  20. 腾讯视频弹幕屏蔽js

热门文章

  1. 特别关注:“网络同居”热背后的心理学分析
  2. 天翼云,不要来,千万不要来!开始统计工时,安装监控软件,减少福利!
  3. python实现scp功能_如何在Python中进行scp?
  4. H5+Vue2: input(number/tel)唤起数字键盘,踩坑日记
  5. 《网络架构系列2-Http详解》
  6. BPFT1.7,全名BaiduPanFilesTransfers免费的百度网盘批量转存工具【精】
  7. android开源项目---RoundedImageView制作圆角矩形,椭圆形以其圆形控件
  8. 奇怪,发不出去,只能截图发了
  9. 名校认证证书、免费课程……留学生不会告诉你的10个宝藏自学网站
  10. 如何批量将 jpeg、png、gif、bmp、webp 转换为 svg 格式