最近初学python,完成老师布置的期中作业时回忆起了童年,所以花了一天画这只喵喵,期待洛克王国的手游

目录

【参考链接】:

【最终成果】:

【代码思想】:

【代码】:


【参考链接】:

1.Python绘图Turtle库详解

2.用Python turtle库 绘制皮卡丘

3.用python-turtle优雅的画椭圆

4.使用Python画小猪佩奇(turtle库)

5.几种提升turtle绘图速度的方法

思路参考皮卡丘,画椭圆参考3和4,4中循环的一段可以直接复制粘贴过来用,参数的调节(椭圆大小)可以参考3

【最终成果】:

【代码思想】:

把喵喵分解为,头,身子,尾巴,五官(耳朵,眼睛,胡须,嘴巴,面部浅绿色)

用到的元素主要有:弧线,椭圆,弧线由不同半径的圆形(circle命令)画出,

椭圆使用循环递归划出,链接为:

点的确定可以用,返回鼠标点击位置的函数

【代码】:

import turtle as t
t.hideturtle()#提笔去向(x,y)处
def mygoto(x,y):t.penup()t.goto(x,y)t.pendown()
#返回鼠标左键点击的位置
def click(x,y):print(x,y)
t.listen()
t.onscreenclick(click,1)
#画椭圆,定义t.seth改变倾斜度,a改变椭圆大小
def tuoyuan(a=0.01):for i in range(120):if 0 <= i < 30 or 60 <= i < 90:           a = a + 0.01t.lt(3)  # 向左转3度t.fd(a)  # 向前走a的步长else:a = a - 0.01t.lt(3)t.fd(a)
#在x,y处画半径为r的圆
def mycircle(x,y,r,yanse):t.color(yanse,yanse)t.begin_fill()mygoto(x,y)t.seth(0)t.circle(r)t.end_fill()#定义画布
t.screensize(500,600,'white')
t.setup(550,650,0,0)
t.speed(0)
t.delay(0)
#t.tracer(False)#猫猫耳朵(避免遮盖先画耳朵)
#左耳
t.pensize(7)
t.colormode(255)
t.color((4,60,4),(147,189,65))
t.begin_fill()
mygoto(-157,138)
t.goto(-114,231)
t.goto(-90,178)
t.goto(-157,138)
t.end_fill()t.color(181,83,64)
t.begin_fill()
mygoto(-127.0 ,206.0)
t.goto(-114,231)
t.goto(-103.0 ,211.0)
t.goto(-127.0 ,206.0)
t.end_fill()#右耳
t.color((4,60,4),(147,189,65))
t.begin_fill()
mygoto(-40 ,168)
t.goto(34.0 ,232.0)
t.goto(39.0, 219.0)
t.goto(16.0 ,93.0)
t.goto(-40.0 ,168.0)
t.end_fill()t.color(181,83,64)
t.begin_fill()
mygoto(11.0 ,211.0)
t.goto(34.0 ,232.0)
t.goto(34.0 ,191.0)
t.goto(11.0 ,211.0)
t.end_fill()#喵喵身体
t.pensize(7)
t.color((4,60,4),(147,189,65))
t.begin_fill()
mygoto(-140.0, 39.0)
t.goto(-189.0, -22.0)
t.circle(30,30)
t.goto(-139.0 ,-15.0)
t.goto(-133,12)
t.seth(-110)
t.circle(300,20)
t.seth(-80)
t.circle(300,5)
t.seth(10)
t.circle(300,5)
t.goto(-109,-99)
t.goto(-118.0 ,-89.0)
t.goto(-109,-99)
t.goto(-59.0 ,-115.0)
t.goto(-31.0 ,-138.0)
t.seth(80)
t.circle(260,20)
t.circle(50,60)
t.goto(0,-51)
t.seth(110)
t.circle(300,20)
#t.goto(-29,37)
t.goto(-140.0, 39.0)
t.end_fill()
mycircle(-135.0 ,-57.0,5,(220,251,122))#喵喵大脸
t.pensize(7)
mygoto(-180,100)#起笔位置
t.begin_fill()
t.color((4,60,4),(147,189,65))##上脸
t.seth(60)
t.fd(30)
print(t.position())
t.circle(-100,120)
print(t.position())
##下脸
mygoto(-180,100)
import turtle as t
t.seth(-80)
t.fd(20)
for i in range(20):t.lt(3)t.fd(3)
t.circle(150,60)
for i in range(20):t.lt(3)t.fd(1)
print(t.position())
t.fd(20)
t.color(147,189,65)
t.goto((8.21,125.98))
t.color((4,60,4),(147,189,65))t.end_fill()
#喵喵五官(眼睛,嘴巴,胡须,耳朵)
#面部
#笔
t.color((220,251,122),(220,251,122))
t.pensize(2)
#面部浅绿填充
t.begin_fill()
mygoto(-180,100)
t.goto(-144,146)
t.seth(0)
t.circle(-120,15)
t.seth(-60)
t.fd(15)
t.circle(20,90)
t.goto(-50,136)
t.circle(-20,90)
t.circle(-80,45)
t.circle(-20,120)
t.seth(-140)
t.circle(-30,100)
t.seth(-140)
t.circle(-40,100)
t.seth(-140)
t.circle(-10,140)
t.seth(160)
t.goto(-178,84)
t.seth(110)
t.goto(-180,100)
t.end_fill()#胡须
#右胡须
t.color((87,132,26),(220,251,122))
t.begin_fill()
mygoto(-31,86)
t.seth(0)
t.circle(300,10)
t.seth(175)
t.circle(300,10)
t.end_fill()t.color((87,132,26),(220,251,122))
t.begin_fill()
mygoto(-30,74)
t.seth(-13)
t.circle(300,10)
t.seth(175)
t.circle(300,10)
t.end_fill()
#左胡须
t.color((87,132,26),(220,251,122))
t.begin_fill()
mygoto(-166,110)
t.seth(170)
t.circle(200,10)
t.seth(-20)
t.circle(200,10)
t.end_fill()t.color((87,132,26),(220,251,122))
t.begin_fill()
mygoto(-170,98)
t.seth(170)
t.circle(200,10)
t.seth(-20)
t.circle(200,10)
t.end_fill()
#嘴
def zui(x0,y0,x,y):mycircle(x0,y0,2.5,(172,205,82))mygoto(x0,y0)t.color(4,60,4)t.seth(-45)t.fd(x)a=45for i in range(4):t.seth(a)t.fd(y)a=-at.seth(45)t.fd(x)
zui(-131,87,7,15)
print(t.position())
mycircle(-79,83,2.5,(172,205,82))
#眼睛
#笔
#左眼
t.color((4,75,5),(4,75,5))
t.begin_fill()
mygoto(-141,105)
t.seth(-15)
tuoyuan(0.4)
t.end_fill()
#左眼仁
mycircle(-141,123,1,'white')
mycircle(-137,110,4,(2,118,10))
#右眼
t.color((4,75,5),(4,75,5))
t.begin_fill()
mygoto(-50,90)
t.seth(0)
tuoyuan(0.45)
t.end_fill()
#右眼仁
mycircle(-53,110,1.3,'white')
mycircle(-49,97,5,(2,118,10))
#耳朵(避免遮盖移至最前方)#喵喵尾巴
#上尾巴
t.pensize(7)
t.color((4,60,4),(220,250,126))
t.begin_fill()
mygoto(-26.0, -89.0)
t.seth(-10)
t.fd(25)
t.seth(10)
t.circle(70,80)
t.goto(78,-16)
t.goto(64,-6)
t.seth(85)
t.fd(30)
t.circle(-40,100)#尾巴尖
print(t.position())
#中缝
t.pensize(3)
t.seth(-150)
t.circle(50,80)
t.rt(30)
t.circle(-150,45)
t.seth(190)
t.circle(-190,12)
t.goto(-26.0, -89.0)
t.end_fill()#下尾巴
t.begin_fill()
t.pensize(7)#逆中缝
t.pensize(3)
t.lt(180)
t.goto(-6.47,-100.96)
t.circle(190,12)
t.seth(215)
t.lt(180)
t.circle(150,45)
t.lt(30)
t.seth(215)
t.lt(255)
t.circle(-50,80)mygoto(116.82,59.04)
t.pensize(7)
t.color((4,60,4),(152,194,70))
t.seth(-150)
t.circle(20,100)
t.seth(-80)
t.circle(80,20)
t.seth(-85)
t.fd(30)
t.goto(101,-21)
t.goto(121,-40)
t.seth(-125)
t.fd(60)
t.goto(72,-90)
t.goto(74,-102)
t.seth(-150)
t.circle(-240,15)
t.seth(185)
t.circle(-30,50)
t.goto(-26.0, -89.0)
t.end_fill()t.mainloop()

turtle库画洛克王国喵喵相关推荐

  1. 用Python Turtle库画一个萌化的蜘蛛侠

    你是从什么时候开始喜欢上漫威电影的?美国队长,钢铁侠,雷神? 我先入坑的是因为看了蜘蛛侠,小时候看完就幻想着什么时候自己也能成为一个英雄,我觉得第一代蜘蛛侠刻画得是最好的,也是给我印象最深刻的一代蜘蛛 ...

  2. pythonturtle画彩虹蟒蛇_python如何用turtle库画蟒蛇?

    我是梁晨le. 学习py的第二天,今天学习了引用turtle库画蟒蛇. 一个画蟒蛇的例子学会怎么运用python去画图.接下来讲一些从中学习到的知识,并记录下来. 1/首先是引用turtle库,有三种 ...

  3. 用python的Turtle库画一个笑脸

    用python的Turtle库画一个笑脸 最近刚了解到python的turtle库,就简单的尝试一下,画一个笑脸. 效果图: 效果图看起来和原图的差别还是有点大,但是没关系,这只是一个尝试而已. 附上 ...

  4. 使用python的turtle库画表情包

    使用python的turtle库画表情包 话不多说,先上效果图,然后是代码 代码如下: import turtleturtle.penup() turtle.goto(-80,20) turtle.c ...

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

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

  6. 编写代码、打印图4-2所示的图形python_Python之turtle库画各种有趣的图及源码(更新中)_一个超会写Bug的程序猿的博客-CSDN博客...

    原文作者:一个超会写Bug的安太狼 原文标题:Python之turtle库画各种有趣的图及源码(更新中) 发布时间:2021-02-09 03:35:11 Turtle库是Python语言中一个很流行 ...

  7. 用turtle库画旋转太极图

    之前写过一篇用Python的turtle库画太极图的文章,当时画出来的太极图是静态的,现在就想着能不能让太极转起来,废话不多话,直接上代码 import turtle import timeangle ...

  8. 用Python的turtle库画太极图

    作为一名中医药大学的学生,对太极图那是情有独钟,这不,我刚开始学Python不久,便想着用turtle库画一个太极图,对turtle库的使用还不熟练,代码量可能有点多-- 后来又尝试了让太极转动起来: ...

  9. 使用turtle库画一朵玫瑰

    使用turtle库画一朵玫瑰 import turtle import turtle # 设置初始位置 turtle.penup() turtle.left(90) turtle.fd(200) tu ...

最新文章

  1. Exchange笔记之使用OWA加密访问邮箱
  2. vba excel 开发游戏_为什么要学习VBA?
  3. IoT:template
  4. python如何做散点图-matplotlib在python上绘制3D散点图实例详解
  5. sharding-jdbc整合mybatis
  6. ubuntu上网慢的问题
  7. Apollo进阶课程⑲丨Apollo感知之旅——感知算法
  8. 如何让HTML在手机上实现直接拨打电话以及发送短信?
  9. click group实例
  10. 【绿豆识别】基于matlab形态学绿豆计数【含Matlab源码 1113期】
  11. MIT操作系统神课 - 6.828
  12. (七)电量分析 —— 优化耗电
  13. Ubuntu安装显卡驱动
  14. 利用计算机对调查问卷进行,关于电脑需求调查问卷
  15. win7系统计算机怎么排列图标,Win7系统桌面图标的三种排序方式
  16. python eof是什么_EOF错误python
  17. 图像处理的alpha通道(RGBA图像)
  18. android 卡片投影渐变,受Duolingo启发的ViewPager卡片效果
  19. 一个ios工程师必须具备的八大知识技能点
  20. Python爬虫之App爬虫视频下载

热门文章

  1. Vue可爱清新记事本
  2. 算法刷题总结 (二) 回溯与深广搜算法
  3. C语言:输入某年某月某日,判断这一天是这一年的第几天?(含结构体)
  4. python:URL转短(长链接转短链接)
  5. Java堆转储Dump文件的几种方法,java高级程序员面试笔试
  6. 常用的英语短语短句(持续更新中)
  7. error C2226: 语法错误 : 意外的“HFONT”类型
  8. python3.9.1 百度云
  9. 脑力风暴之小毛驴历险记(1)----好多胡萝卜(上)
  10. JVM--调优--04--案例02--大SQL导致内存溢出