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

2024-01-09 21:04

本文主要是介绍Python教程37:使用turtle画一个戴帽子的皮卡丘,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

---------------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.8for i in range(120):if 0 <= i < 30 or 60 <= i < 90:n -= 0.05t.left(3)t.fd(n)else:n += 0.05t.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自动化办公 编程工具
在这里插入图片描述

这篇关于Python教程37:使用turtle画一个戴帽子的皮卡丘的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!


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

相关文章

使用SpringBoot整合Sharding Sphere实现数据脱敏的示例

《使用SpringBoot整合ShardingSphere实现数据脱敏的示例》ApacheShardingSphere数据脱敏模块,通过SQL拦截与改写实现敏感信息加密存储,解决手动处理繁琐及系统改... 目录痛点一:痛点二:脱敏配置Quick Start——Spring 显示配置:1.引入依赖2.创建脱敏

基于Python实现一个简单的题库与在线考试系统

《基于Python实现一个简单的题库与在线考试系统》在当今信息化教育时代,在线学习与考试系统已成为教育技术领域的重要组成部分,本文就来介绍一下如何使用Python和PyQt5框架开发一个名为白泽题库系... 目录概述功能特点界面展示系统架构设计类结构图Excel题库填写格式模板题库题目填写格式表核心数据结构

Python使用smtplib库开发一个邮件自动发送工具

《Python使用smtplib库开发一个邮件自动发送工具》在现代软件开发中,自动化邮件发送是一个非常实用的功能,无论是系统通知、营销邮件、还是日常工作报告,Python的smtplib库都能帮助我们... 目录代码实现与知识点解析1. 导入必要的库2. 配置邮件服务器参数3. 创建邮件发送类4. 实现邮件

Go语言中Recover机制的使用

《Go语言中Recover机制的使用》Go语言的recover机制通过defer函数捕获panic,实现异常恢复与程序稳定性,具有一定的参考价值,感兴趣的可以了解一下... 目录引言Recover 的基本概念基本代码示例简单的 Recover 示例嵌套函数中的 Recover项目场景中的应用Web 服务器中

基于Python构建一个高效词汇表

《基于Python构建一个高效词汇表》在自然语言处理(NLP)领域,构建高效的词汇表是文本预处理的关键步骤,本文将解析一个使用Python实现的n-gram词频统计工具,感兴趣的可以了解下... 目录一、项目背景与目标1.1 技术需求1.2 核心技术栈二、核心代码解析2.1 数据处理函数2.2 数据处理流程

CnPlugin是PL/SQL Developer工具插件使用教程

《CnPlugin是PL/SQLDeveloper工具插件使用教程》:本文主要介绍CnPlugin是PL/SQLDeveloper工具插件使用教程,具有很好的参考价值,希望对大家有所帮助,如有错... 目录PL/SQL Developer工具插件使用安装拷贝文件配置总结PL/SQL Developer工具插

SpringBoot3中使用虚拟线程的完整步骤

《SpringBoot3中使用虚拟线程的完整步骤》在SpringBoot3中使用Java21+的虚拟线程(VirtualThreads)可以显著提升I/O密集型应用的并发能力,这篇文章为大家介绍了详细... 目录1. 环境准备2. 配置虚拟线程方式一:全局启用虚拟线程(Tomcat/Jetty)方式二:异步

Python远程控制MySQL的完整指南

《Python远程控制MySQL的完整指南》MySQL是最流行的关系型数据库之一,Python通过多种方式可以与MySQL进行交互,下面小编就为大家详细介绍一下Python操作MySQL的常用方法和最... 目录1. 准备工作2. 连接mysql数据库使用mysql-connector使用PyMySQL3.

使用Python实现base64字符串与图片互转的详细步骤

《使用Python实现base64字符串与图片互转的详细步骤》要将一个Base64编码的字符串转换为图片文件并保存下来,可以使用Python的base64模块来实现,这一过程包括解码Base64字符串... 目录1. 图片编码为 Base64 字符串2. Base64 字符串解码为图片文件3. 示例使用注意

使用Python实现获取屏幕像素颜色值

《使用Python实现获取屏幕像素颜色值》这篇文章主要为大家详细介绍了如何使用Python实现获取屏幕像素颜色值,文中的示例代码讲解详细,感兴趣的小伙伴可以跟随小编一起学习一下... 一、一个小工具,按住F10键,颜色值会跟着显示。完整代码import tkinter as tkimport pyau