Python教程37:使用turtle画一个戴帽子的皮卡丘

news2024/9/22 11:34:48

---------------turtle源码集合---------------

Python教程36:海龟画图turtle写春联

Python源码35:海龟画图turtle画中国结

Python源码31:海龟画图turtle画七道彩虹

Python源码30:海龟画图turtle画紫色的小熊

Python源码29:海龟画图turtle画太极图

Python源码28:海龟画图turtle画熊猫

Python源码27:海龟画图turtle画动态圆舞曲

Python源码26:海龟画图turtle画向日葵

Python源码25:海龟画图turtle画小猪佩奇

Python源码24:使用海龟画图turtle画滑板

Python源码23:使用海龟画图turtle画小狗狗

Python源码22:使用海龟画图turtle画今天日期

Python源码21:使用海龟画图turtle画太阳,云朵,房子,绿树

Python源码20:使用海龟画图turtle画一个会动的星空

Python源码19:海龟画图turtle画螺旋的彩色的逐渐放大的文字

Python源码18:使用海龟画图turtle画捂脸表情

Python源码17:使用海龟画图turtle画五星红旗

Python源码16:使用海龟画图turtle画会动的时钟

Python源码15:使用海龟画图turtle画小黄人

Python源码14:使用海龟画图turtle画我的城堡

Python源码分享13:使用海龟画图turtle画一个会眨眼的皮卡丘

Python源码分享12:使用turtle画彩色六边形

Python源码分享11:使用海龟画图turtle画航天火箭

Python源码分享10:使用海龟画图turtle画哆啦A梦

Python源代码分享:02海龟画图五角星

Python源代码分享:03画一个奥运五环图

Python源代码分享:05使用turtle模块绘制一个彩色螺旋图案

Python源代码分享:07画满天繁星

Python源码分享08:使用turtle画一朵玫瑰花

Python源码分享10:使用海龟画图turtle画哆啦A梦

Python源码分享11:使用海龟画图turtle画航天火箭

Python源码分享12:使用turtle画彩色六边形
在这里插入图片描述

# @Author : 小红牛
# 微信公众号:WdPython
import turtle as t

# 设置背景颜色,窗口位置以及大小
t.colormode(255)  # 颜色模式
t.speed(0)
t.screensize(800, 700, "white")  # 画布大小背景颜色
t.setup(width=800, height=700, startx=None, starty=None)  # 绘图窗口的大小和起始坐标
# t.bgpic("di_2_800.gif")
t.title("皮卡丘!")  # 设置绘图窗口的标题
t.resizemode('noresize')  # 大小调整模式:auto,user,noresize
t.tracer(1)
t.hideturtle()


def mlingpen(x, y):
    t.penup()
    t.goto(x, y)
    t.pendown()


def mlingpkqface(x, y):
    mlingpen(x, y)
    t.pensize(3)
    t.pencolor("#923E24")
    t.fillcolor('#FBD624')
    t.begin_fill()
    t.seth(40)
    t.circle(100, 30)
    t.circle(40, 60)
    t.right(30)
    t.circle(160, 20)
    t.seth(-20)
    t.circle(300, 30)
    t.circle(30, 50)
    t.left(85)
    t.circle(300, 85)
    t.left(1)
    t.circle(300, 35)
    t.circle(30, 40)
    t.seth(40)
    t.circle(300, 32)
    t.right(150)
    t.circle(100, 30)
    t.circle(30, 60)
    t.left(180)
    t.circle(100, 60)
    t.right(30)
    t.circle(100, 60)
    t.circle(70, 120)
    t.circle(-120, 80)
    t.circle(35, 140)
    t.right(60)
    t.circle(300, 23)
    t.right(60)
    t.fd(10)
    t.left(90)
    t.fd(10)
    t.right(60)
    t.fd(10)
    t.left(90)
    t.circle(30, 23)
    t.right(60)
    t.fd(10)
    t.left(90)
    t.circle(90, 80)
    t.right(170)
    t.circle(70, 65)
    t.right(20)
    t.circle(-150, 20)
    t.circle(20, 90)
    t.right(200)
    t.circle(50, 50)
    t.goto(x, y)
    t.end_fill()
    t.penup()
    t.goto(-72, -25)
    t.pendown()
    t.pencolor("#923E24")
    t.fillcolor("#923E24")
    t.begin_fill()
    t.seth(-6)
    t.circle(120, 30)
    t.right(160)
    t.circle(-50, 65)
    t.end_fill()
    mlingpen(209.21, 135.02)
    t.pensize(3)
    t.pencolor("#000000")
    t.fillcolor('#000000')
    t.seth(145)
    t.begin_fill()
    t.circle(300, 12)
    t.left(50)
    t.circle(60, 59)
    t.left(88)
    t.circle(190, 30)
    t.end_fill()
    mlingpen(-253.14, -105.48)
    t.pensize(3)
    t.pencolor("#000000")
    t.fillcolor('#000000')
    t.seth(40)
    t.begin_fill()
    t.circle(300, 12)
    t.left(50)
    t.circle(60, 57)
    t.left(88)
    t.circle(190, 30)
    t.end_fill()


def mlingpkqyingyinying():
    t.penup()
    t.seth(0)
    t.pensize(1)
    t.pencolor("#DDA120")
    t.fillcolor('#DDA120')
    t.begin_fill()
    t.left(220)
    mlingpen(-179, -90)
    t.circle(97, 60)
    t.circle(69, 122)
    t.circle(-120, 80)
    t.circle(33, 135)
    t.left(90)
    t.circle(-25, 150)
    t.left(175)
    t.circle(-60, 140)
    t.left(175)
    t.circle(-60, 100)
    t.right(5)
    t.circle(85, 60)
    t.goto(-179, -90)
    t.end_fill()
    t.penup()
    t.penup()
    t.seth(0)
    mlingpen(115.87, -170.16)
    t.pencolor("#eca9a9")
    t.fillcolor('#eca9a9')
    t.begin_fill()
    t.left(45)
    t.circle(300, 20)
    t.circle(8, 155)
    t.left(3)
    t.circle(300, 20)
    t.circle(9, 155)
    t.goto(115.87, -170.16)
    t.end_fill()
    t.penup()


def mlingpkqjiao():
    mlingpen(-215, -160)
    t.pensize(3)
    t.pencolor("#FBD624")
    t.fillcolor('#FBD624')
    t.begin_fill()
    t.seth(-30)
    t.circle(30, 70)
    t.left(20)
    t.circle(-50, 150)
    t.circle(10, 160)
    t.circle(80, 80)
    t.left(5)
    t.circle(75, 110)
    t.goto(-210, -160)
    t.penup()
    t.end_fill()
    mlingpen(-149, -191)
    t.pensize(3)
    t.pencolor("#923E24")
    t.fillcolor('#FBD624')
    t.begin_fill()
    t.seth(0)
    t.left(40)
    t.circle(148, 55)
    t.right(38)
    t.fd(20)
    t.left(128)
    t.fd(15)
    t.right(88)
    t.fd(15)
    t.left(128)
    t.fd(15)
    t.right(88)
    t.fd(15)
    t.left(128)
    t.fd(15)
    t.right(45)
    t.circle(130, 60)
    t.circle(23, 75)
    t.end_fill()
    mlingpen(-149, -180)
    t.pensize(3)
    t.pencolor("#eca9a9")
    t.fillcolor('#eca9a9')
    t.begin_fill()
    t.seth(0)
    t.left(45)
    t.circle(148, 45)
    t.left(45)
    t.circle(15, 110)
    t.right(18)
    t.circle(130, 40)
    t.circle(17, 100)
    t.end_fill()


def mlingpkqcap():
    mlingpen(-210, 95)
    t.pensize(4)
    t.pencolor("#000000")
    t.fillcolor('#CD0000')
    t.begin_fill()
    t.seth(290)
    t.circle(45, 80)
    t.circle(345, 30)
    t.circle(45, 90)
    t.left(2)
    t.fd(120)
    t.left(45)
    t.circle(200, 60)
    t.goto(-210, 95)
    t.end_fill()
    t.left(175)
    t.circle(-290, 50)
    t.pencolor("#000000")
    t.pensize(3)
    t.pencolor("#000000")
    t.fillcolor('#ffffff')
    mlingpen(-160, 272)
    t.begin_fill()
    t.goto(-80, 260)
    t.goto(-45, 200)
    t.left(186)
    t.circle(230, 41)
    t.goto(-210, 200)
    t.goto(-180, 270)
    t.goto(-160, 272)
    t.end_fill()
    mlingpen(-175, 265)
    t.seth(0)
    t.begin_fill()
    t.circle(13)
    t.end_fill()
    t.penup()
    mlingpen(-125, 222)
    t.pensize(7)
    t.pencolor("#6ba65a")
    t.goto(-140, 225)
    t.pensize(9)
    t.goto(-155, 170)
    t.left(45)
    t.circle(-130, 30)
    t.pensize(3)
    mlingpen(-205, 96)
    t.pensize(3)
    t.pencolor("#ffffff")
    t.seth(286)
    t.circle(39, 74)
    t.left(9)
    t.circle(331, 32)
    t.circle(45, 80)
    t.pensize(3)


def mlingpkqeye():
    t.color("#000000", "#702c00")
    mlingpen(-110, 24)
    t.begin_fill()
    t.seth(0)
    t.circle(24)
    t.end_fill()
    mlingpen(-110, 31)
    t.color("black", "black")
    t.begin_fill()
    t.circle(20)
    t.end_fill()
    t.color("white", "white")
    mlingpen(-105, 53)
    t.begin_fill()
    t.circle(8)
    t.end_fill()
    t.color("#000000", "#702c00")
    mlingpen(0, 62)
    t.begin_fill()
    t.seth(0)
    t.circle(24)
    t.end_fill()
    mlingpen(2, 70)
    t.color("black", "black")
    t.begin_fill()
    t.circle(20)
    t.end_fill()
    mlingpen(5, 92)
    t.color("white", "white")
    t.begin_fill()
    t.circle(8)
    t.penup()
    t.end_fill()
    t.hideturtle()


def mlingpkqcheek1():
    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()
    mlingpen(53, -20)
    t.pendown()
    t.begin_fill()
    t.setheading(0)
    t.circle(27)
    t.end_fill()


def mlingweiba(x, y):
    mlingpen(x, y)
    t.pensize(3)
    t.pencolor("#923E24")
    t.fillcolor('#CD853F')
    t.begin_fill()
    t.seth(40)
    t.fd(200)
    t.seth(-80)
    t.fd(150)
    t.seth(210)
    t.fd(150)
    t.left(90)
    t.fd(100)
    t.right(95)
    t.fd(100)
    t.left(110)
    t.fd(70)
    t.right(110)
    t.fd(80)
    t.left(110)
    t.fd(30)
    t.right(110)
    t.fd(32)
    t.right(106)
    t.circle(100, 25)
    t.right(15)
    t.circle(-300, 2)
    t.seth(30)
    t.fd(40)
    t.left(100)
    t.fd(70)
    t.right(100)
    t.fd(80)
    t.left(100)
    t.fd(46)
    t.seth(66)
    t.circle(200, 38)
    t.right(10)
    t.fd(10)
    t.end_fill()
    mlingpen(202, 250)
    t.pensize(3)
    t.pencolor("#923E24")
    t.fillcolor('#FBD624')
    t.begin_fill()
    t.seth(220)
    t.fd(120)
    t.circle(75, 120)
    t.left(50)
    t.fd(110)
    t.end_fill()


def mlingpkqcheek2(x, y, fx):
    mlingpen(x, y)
    t.seth(fx)
    t.pencolor("#840101")
    t.fillcolor('#CD0000')
    t.begin_fill()
    n = 1.8
    for i in range(120):
        if 0 <= i < 30 or 60 <= i < 90:
            n -= 0.05
            t.left(3)
            t.fd(n)
        else:
            n += 0.05
            t.left(3)
            t.fd(n)
    t.end_fill()


def mlingpkqmouth():
    mlingpen(-60, 20)
    t.pensize(3)
    t.pencolor("#923E24")
    t.seth(-48)
    t.begin_fill()
    t.circle(15, 110)
    t.right(90)
    t.circle(15, 110)
    t.seth(0)
    mlingpen(-50, 45)
    t.circle(5, 180)


def mlingpkqshou1():
    mlingpen(-130, -30)
    t.pensize(3)
    t.pencolor("#923E24")
    t.fillcolor('#FBD624')
    t.seth(100)
    t.begin_fill()
    t.circle(130, 30)
    t.right(100)
    t.fd(10)
    t.left(90)
    t.fd(10)
    t.right(60)
    t.fd(10)
    t.left(90)
    t.fd(10)
    t.right(30)
    t.fd(10)
    t.left(90)
    t.fd(10)
    t.right(30)
    t.fd(10)
    t.left(90)
    t.fd(10)
    t.right(50)
    t.circle(70, 150)
    t.end_fill()

    mlingpen(-138, -67)
    t.pensize(2)
    t.pencolor("#DDA120")
    t.fillcolor('#DDA120')
    t.left(90)
    t.begin_fill()
    t.circle(40, 40)
    t.left(10)
    t.circle(-60, 70)
    t.left(40)
    t.circle(30, 40)
    t.left(83)
    t.circle(70, 110)
    t.end_fill()


def mlingpkqshou2():
    mlingpen(0, -40)
    t.pensize(3)
    t.pencolor("#923E24")
    t.fillcolor('#FBD624')
    t.seth(200)
    t.begin_fill()
    t.circle(55, 90)
    t.fd(10)
    t.left(90)
    t.fd(10)
    t.right(60)
    t.fd(10)
    t.left(90)
    t.fd(10)
    t.right(90)
    t.fd(10)
    t.left(90)
    t.fd(10)
    t.right(60)
    t.fd(10)
    t.left(90)
    t.fd(10)
    t.right(50)
    t.circle(60, 80)
    t.end_fill()


def mlingpkqball():
    mlingpen(-30, -250)
    t.pensize(3)
    t.pencolor("#000000")
    t.fillcolor('#CD0000')
    t.seth(0)
    t.begin_fill()
    t.circle(80)
    t.end_fill()
    mlingpen(-110, -170)
    t.seth(-90)
    t.pencolor("#000000")
    t.fillcolor('#ffffff')
    t.begin_fill()
    t.circle(80, 180)
    t.end_fill()
    t.pensize(12)
    mlingpen(-105, -170)
    t.pencolor("#000000")
    t.goto(44, -170)
    t.pensize(3)
    mlingpen(-4, -170)
    t.pencolor("#000000")
    t.fillcolor('#000000')
    t.begin_fill()
    t.circle(28)
    t.end_fill()
    mlingpen(-11, -170)
    t.pencolor("#000000")
    t.fillcolor('#ffffff')
    t.begin_fill()
    t.circle(20)
    t.end_fill()
    mlingpen(-21, -170)
    t.pencolor("#000000")
    t.fillcolor('#ffffff')
    t.begin_fill()
    t.circle(10)
    t.end_fill()


def main():
    mlingweiba(50, 120)
    mlingpkqface(30, 0)
    mlingpkqyingyinying()
    mlingpkqcap()
    mlingpkqcheek2(-140, -10, 300)
    mlingpkqcheek2(60, 50, 80)
    mlingpkqshou1()
    mlingpkqjiao()
    mlingpkqball()
    mlingpkqshou2()
    mlingpkqmouth()
    mlingpkqeye()


t.color('#321320')
t.penup()
t.goto(260, -40)
t.pendown()
t.write('我\n是\n一\n只\n电\n气\n鼠\n', align="center", font=("楷体", 15, "normal"))
t.penup()
t.goto(290, 215)
t.pendown()
t.write('皮\n卡\n丘\n', align="center", font=("楷体", 18, "normal"))

if __name__ == '__main__':
    main()
    t.done()
    t.hideturtle()

完毕!!感谢您的收看

----------★★历史博文集合★★----------
我的零基础Python教程,Python入门篇 进阶篇 视频教程 Py安装py项目 Python模块 Python爬虫 Json Xpath 正则表达式 Selenium Etree CssGui程序开发 Tkinter Pyqt5 列表元组字典数据可视化 matplotlib 词云图 Pyecharts 海龟画图 Pandas Bug处理 电脑小知识office自动化办公 编程工具
在这里插入图片描述

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1369441.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

linux 系统安全及应用

一、账号安全基本措施 1.系统账号清理 1.将用户设置为无法登录 /sbin/nologin shell——/sbin/nologin却比较特殊&#xff0c;所谓“无法登陆”指的仅是这个用户无法使用bash或其他shell来登陆系统而已&#xff0c;并不是说这个账号就无法使用系统资源。举例来说&#xff0c;…

JAVA基础学习笔记-day15-File类与IO流

JAVA基础学习笔记-day15-File类与IO流 1. java.io.File类的使用1.1 概述1.2 构造器1.3 常用方法1、获取文件和目录基本信息2、列出目录的下一级3、File类的重命名功能4、判断功能的方法5、创建、删除功能 2. IO流原理及流的分类2.1 Java IO原理2.2 流的分类2.3 流的API 3. 节点…

SNP浅谈SAP系统增强及二次开发

SAP 系统增强和二次开发是指在 SAP 系统的基础上&#xff0c;对现有功能进行扩展和增强&#xff0c;以满足特定业务需求。增强和二次开发可以通过不同的方法实现&#xff0c;包括&#xff1a; ■ 数据集成&#xff1a;通过创建数据接口&#xff0c;实现 SAP 系统与其他系统之间…

视频智能分析/边缘计算AI智能分析网关V4区域入侵检测算法如何配置?

边缘计算AI智能分析网关&#xff08;V4版&#xff09;部署了近40种AI算法模型&#xff0c;支持对接入的视频图像进行人、车、物、行为等实时检测分析&#xff0c;并上报识别结果&#xff0c;并能进行语音告警播放。算法配置后&#xff0c;即可对监控视频流进行实时检测&#xf…

基于 Canvas 的多行文本溢出方案

说到文本溢出&#xff0c;大家应该都不陌生&#xff0c;中文网络上的文章翻来覆去就是下面3种方法&#xff1a; 单行文本溢出 这是日常开发中用的最多的&#xff0c;核心代码如下&#xff1a; p {width: 300px;overflow: hidden; white-space: nowrap; /*文本不会换行*/text…

基于模块自定义扩展字段的后端逻辑实现(二)

目录 一&#xff1a;创建表 二&#xff1a;代码逻辑 上一节我们详细讲解了自定义扩展字段的逻辑实现和表的设计&#xff0c;这一节我们以一个具体例子演示下&#xff0c;如何实现一个订单模块的自定义扩展数据。 一&#xff1a;创建表 订单主表: CREATE TABLE t_order ( …

rime中州韵小狼毫 中英互绎 滤镜

英文在日常生活中已经随处可见&#xff0c;我们一般中英互译需要使用专业的翻译软件来实现。但如果我们在输入法中&#xff0c;在输入中文的时候&#xff0c;可以顺便瞟一眼对应的英文词汇&#xff0c;或者在输入英文的时候可以顺便了解对应的中文词汇&#xff0c;那将为我们的…

1.8 day6 IO进程线程

使用有名管道实现两个进程之间的通信 进程A #include <myhead.h> int main(int argc, const char *argv[]) {//创建两个文件描述符用于打开两个管道int fd1-1;int fd2-1;//创建一个子进程int pid-1;if((fd1open("./mkfifo1",O_RDWR))-1){perror("open er…

OpenAI ChatGPT-4开发笔记2024-03:Chat之Tool和Tool_Call(含前function call)

Updates on Function Calling were a major highlight at OpenAI DevDay. In another world,原来的function call都不再正常工作了&#xff0c;必须全部重写。 function和function call全部由tool和tool_choice取代。2023年11月之前关于function call的代码都准备翘翘。 干嘛…

小梅哥Xilinx FPGA学习笔记22——ip核之FIFO

目录 一&#xff1a;章节说明 1.1 FIFO IP简介 1.2 FIFO Generato IP 核信号框图 1.3 实验任务 二&#xff1a;FIFO 写模块设计 2.1 简介 2.2 模块框图 2.3 模块端口与功能描述 2.4 写模块代码 三 FIFO 读模块设计 3.1 简介 3.2 模块框图 3.3 模块端口与功…

【自学笔记】01Java基础-07面向对象基础-03常量、枚举类、抽象类、多态详解

记录java基础学习中有关常量、枚举类、抽象类和多态的内容。 1 常量 什么是常量&#xff1f; 常量是使用了public static final修饰的成员变量&#xff0c;必须有初始化值&#xff0c;而且执行的过程中其值不能被改变。 常量名的命名规范&#xff1a;英文单词全部大写&#x…

Transformer架构的局限已凸显,被取代还有多久?

江山代有才人出&#xff0c;各领风骚数百年。这句话无论是放在古往今来的人类身上&#xff0c;还是放在当今人工智能领域的大模型之上&#xff0c;都是最贴切不过的。无论是一个时代的伟人&#xff0c;还是统治一个领域的技术&#xff0c;最终都会有新的挑战者将其替代。Transf…

springBoot容器功能

一、添加组件 1、Configuration 1.1基本使用 新建一个MyConfig类 , 演示Configuration Bean的作用 &#xff0c; 即相当于spring中的beanx.xml&#xff0c; Bean 就是bean标签 此方法&#xff0c;默认是单实例&#xff0c; 即获取多少次都是同一个对象 自定义名字&#xff0…

令人绝望的固化和突破-2024-

这是继续写给自己求生之路的记录。 所有成熟稳定的行业都是相对固化的&#xff0c;上升通道及其严苛。 博客 我刚写博客的2015-2017这3年&#xff0c;其实还能带动一些学生&#xff0c;然后部分学生心中有火&#xff0c;眼里有光&#xff0c;也有信心自己做好&#xff0c;还有…

利用“与非”运算实现布尔代数中的与,或,非三种运算

什么是“与非”运算&#xff1f; 要想明白“与非”运算&#xff0c;首先要明白“与”运算和“非”运算。 “与”运算在离散数学中叫做合取式&#xff0c;也就是A和B相同时为1的时候结果才为1&#xff0c;其余情况都为0 下面是“与”运算的真值表 “非”运算在离散数学中叫做否…

2023年阿里云云栖大会:前沿技术发布与未来展望

在2023年的阿里云云栖大会上&#xff0c;我见证了云计算和人工智能领域的又一历史性时刻。这次大会不仅是对未来科技趋势的一次深入探索&#xff0c;更是阿里云技术实力和创新能力的集中展示。 首先&#xff0c;千亿级参数规模的大模型通义千问2.0的发布&#xff0c;无疑将人工…

实战演练 | Navicat 中编辑器设置的配置

Navicat 是一款功能强大的数据库管理工具&#xff0c;为开发人员和数据库管理员提供稳健的环境。其中&#xff0c;一个重要功能是 SQL 编辑器&#xff0c;用户可以在 SQL 编辑器中编写和执行 SQL 查询。Navicat 的编辑器设置可让用户自定义编辑器环境&#xff0c;以满足特定的团…

软件测试|MySQL逻辑运算符使用详解

简介 在MySQL中&#xff0c;逻辑运算符用于处理布尔类型的数据&#xff0c;进行逻辑判断和组合条件。逻辑运算符主要包括AND、OR、NOT三种&#xff0c;它们可以帮助我们在查询和条件语句中进行复杂的逻辑操作。本文将详细介绍MySQL中逻辑运算符的使用方法和示例。 AND运算符 …

GPT Prompts Hub:2024年最新ChatGPT提示词项目,革新对话结构!

&#x1f31f; GPT Prompts Hub &#x1f31f; 欢迎来到 “GPT Prompts Hub” 存储库&#xff01;探索并分享高质量的 ChatGPT 提示词。培养创新性内容&#xff0c;提升对话体验&#xff0c;激发创造力。我们极力鼓励贡献独特的提示词。 在 “GPT Prompts Hub” 项目中&#…

解决不同请求需要的同一实体类参数不同(分组校验validation)

问题概述 新增目录是自动生成id&#xff0c;不需要id参数&#xff1b;更新目录需要id&#xff0c;不能为空 pom.xml中已有spring-boot-starter-validation依赖 <!--validation(完成属性限制&#xff0c;参数校验)--><dependency><groupId>org.springframew…