用python画一只可爱的皮卡丘实例


Posted in Python onNovember 21, 2019

效果图

用python画一只可爱的皮卡丘实例

#!/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画一只可爱的皮卡丘实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持三水点靠木。

Python 相关文章推荐
python模拟登录百度贴吧(百度贴吧登录)实例
Dec 18 Python
详解Python中的type()方法的使用
May 21 Python
Python中列表元素转为数字的方法分析
Jun 14 Python
深入理解Django自定义信号(signals)
Oct 15 Python
通过shell+python实现企业微信预警
Mar 07 Python
Python I/O与进程的详细讲解
Mar 08 Python
Python使用微信itchat接口实现查看自己微信的信息功能详解
Aug 22 Python
Python动态导入模块:__import__、importlib、动态导入的使用场景实例分析
Mar 30 Python
Python实现仿射密码的思路详解
Apr 23 Python
python进度条显示之tqmd模块
Aug 22 Python
Python Unittest原理及基本使用方法
Nov 06 Python
刚学完怎么用Python实现定时任务,转头就跑去撩妹!
Jun 05 Python
Python 私有化操作实例分析
Nov 21 #Python
使用python的turtle绘画滑稽脸实例
Nov 21 #Python
使用Python的Turtle绘制哆啦A梦实例
Nov 21 #Python
Python 类的魔法属性用法实例分析
Nov 21 #Python
python画蝴蝶曲线图的实例
Nov 21 #Python
Python 静态方法和类方法实例分析
Nov 21 #Python
Python 用turtle实现用正方形画圆的例子
Nov 21 #Python
You might like
关于IIS php调用com组件的权限问题
2012/01/11 PHP
php 魔术方法详解
2014/11/11 PHP
PHP编程之设置apache虚拟目录
2016/07/08 PHP
thinkphp 抓取网站的内容并且保存到本地的实例详解
2017/08/25 PHP
基于JQuery的cookie插件
2010/04/07 Javascript
JavaScript实现的内存数据库LokiJS介绍和入门实例
2014/11/17 Javascript
javascript 中__proto__和prototype详解
2014/11/25 Javascript
谈谈jQuery Ajax用法详解
2015/11/27 Javascript
jQuery基于BootStrap样式实现无限极地区联动
2016/08/26 Javascript
JSON与XML的区别对比及案例应用
2016/11/11 Javascript
BootStrap 页签切换失效的解决方法
2017/08/17 Javascript
基于DOM节点删除之empty和remove的区别(详解)
2017/09/11 Javascript
Layui table 组件的使用之初始化加载数据、数据刷新表格、传参数
2017/09/11 Javascript
jquery ajaxfileupload异步上传插件
2017/11/21 jQuery
vue项目实现记住密码到cookie功能示例(附源码)
2018/01/31 Javascript
JavaScript使用localStorage存储数据
2019/09/25 Javascript
通过实例了解JS执行上下文运行原理
2020/06/17 Javascript
JavaScript如何实现监听键盘输入和鼠标监点击
2020/07/20 Javascript
JS性能优化实现方法及优点进行
2020/08/30 Javascript
JavaScript 实现下雪特效的示例代码
2020/09/09 Javascript
Python实现的十进制小数与二进制小数相互转换功能
2017/10/12 Python
python SMTP实现发送带附件电子邮件
2018/05/22 Python
Python 确定多项式拟合/回归的阶数实例
2018/12/29 Python
Python使用turtle库绘制小猪佩奇(实例代码)
2020/01/16 Python
python实现人工蜂群算法
2020/09/18 Python
Python绘图实现台风路径可视化代码实例
2020/10/23 Python
全面介绍python中很常用的单元测试框架unitest
2020/12/14 Python
11月红领巾广播稿
2014/01/17 职场文书
考试不及格的检讨书
2014/01/22 职场文书
舞蹈兴趣小组活动总结
2014/07/07 职场文书
解除劳动合同通知书范本
2015/04/16 职场文书
个人廉政承诺书
2015/04/28 职场文书
二审代理词范文
2015/05/25 职场文书
反腐倡廉学习心得体会范文
2015/08/15 职场文书
vue中div禁止点击事件的实现
2022/04/02 Vue.js
vue判断按钮是否可以点击
2022/04/09 Vue.js