问答文章1 问答文章501 问答文章1001 问答文章1501 问答文章2001 问答文章2501 问答文章3001 问答文章3501 问答文章4001 问答文章4501 问答文章5001 问答文章5501 问答文章6001 问答文章6501 问答文章7001 问答文章7501 问答文章8001 问答文章8501 问答文章9001 问答文章9501

Python turtle海龟制图 求代码

发布网友 发布时间:2022-04-22 03:09

我来回答

2个回答

热心网友 时间:2022-04-18 09:50

# coding:utf-8
import turtle as t

# 绘制小猪佩奇
# =======================================

t.pensize(4)
t.hideturtle()
t.colormode(255)
t.color((255, 155, 192), "pink")
t.setup(840, 500)
t.speed(10)

# 鼻子
t.pu()
t.goto(-100, 100)
t.pd()
t.seth(-30)
t.begin_fill()
a = 0.4
for i in range(120):
if 0 <= i < 30 or 60 <= i < 90:
a = a + 0.08
t.lt(3) # 向左转3度
t.fd(a) # 向前走a的步长
else:
a = a - 0.08
t.lt(3)
t.fd(a)
t.end_fill()

t.pu()
t.seth(90)
t.fd(25)
t.seth(0)
t.fd(10)
t.pd()
t.pencolor(255, 155, 192)
t.seth(10)
t.begin_fill()
t.circle(5)
t.color(160, 82, 45)
t.end_fill()

t.pu()
t.seth(0)
t.fd(20)
t.pd()
t.pencolor(255, 155, 192)
t.seth(10)
t.begin_fill()
t.circle(5)
t.color(160, 82, 45)
t.end_fill()

# 头
t.color((255, 155, 192), "pink")
t.pu()
t.seth(90)
t.fd(41)
t.seth(0)
t.fd(0)
t.pd()
t.begin_fill()
t.seth(180)
t.circle(300, -30)
t.circle(100, -60)
t.circle(80, -100)
t.circle(150, -20)
t.circle(60, -95)
t.seth(161)
t.circle(-300, 15)
t.pu()
t.goto(-100, 100)
t.pd()
t.seth(-30)
a = 0.4
for i in range(60):
if 0 <= i < 30 or 60 <= i < 90:
a = a + 0.08
t.lt(3) # 向左转3度
t.fd(a) # 向前走a的步长
else:
a = a - 0.08
t.lt(3)
t.fd(a)
t.end_fill()

# 耳朵
t.color((255, 155, 192), "pink")
t.pu()
t.seth(90)
t.fd(-7)
t.seth(0)
t.fd(70)
t.pd()
t.begin_fill()
t.seth(100)
t.circle(-50, 50)
t.circle(-10, 120)
t.circle(-50, 54)
t.end_fill()

t.pu()
t.seth(90)
t.fd(-12)
t.seth(0)
t.fd(30)
t.pd()
t.begin_fill()
t.seth(100)
t.circle(-50, 50)
t.circle(-10, 120)
t.circle(-50, 56)
t.end_fill()

# 眼睛
t.color((255, 155, 192), "white")
t.pu()
t.seth(90)
t.fd(-20)
t.seth(0)
t.fd(-95)
t.pd()
t.begin_fill()
t.circle(15)
t.end_fill()

t.color("black")
t.pu()
t.seth(90)
t.fd(12)
t.seth(0)
t.fd(-3)
t.pd()
t.begin_fill()
t.circle(3)
t.end_fill()

t.color((255, 155, 192), "white")
t.pu()
t.seth(90)
t.fd(-25)
t.seth(0)
t.fd(40)
t.pd()
t.begin_fill()
t.circle(15)
t.end_fill()

t.color("black")
t.pu()
t.seth(90)
t.fd(12)
t.seth(0)
t.fd(-3)
t.pd()
t.begin_fill()
t.circle(3)
t.end_fill()

# 腮
t.color((255, 155, 192))
t.pu()
t.seth(90)
t.fd(-95)
t.seth(0)
t.fd(65)
t.pd()
t.begin_fill()
t.circle(30)
t.end_fill()

# 嘴
t.color(239, 69, 19)
t.pu()
t.seth(90)
t.fd(15)
t.seth(0)
t.fd(-100)
t.pd()
t.seth(-80)
t.circle(30, 40)
t.circle(40, 80)

# 身体
t.color("red", (255, 99, 71))
t.pu()
t.seth(90)
t.fd(-20)
t.seth(0)
t.fd(-78)
t.pd()
t.begin_fill()
t.seth(-130)
t.circle(100, 10)
t.circle(300, 30)
t.seth(0)
t.fd(230)
t.seth(90)
t.circle(300, 30)
t.circle(100, 3)
t.color((255, 155, 192), (255, 100, 100))
t.seth(-135)
t.circle(-80, 63)
t.circle(-150, 24)
t.end_fill()

# 手
t.color((255, 155, 192))
t.pu()
t.seth(90)
t.fd(-40)
t.seth(0)
t.fd(-27)
t.pd()
t.seth(-160)
t.circle(300, 15)
t.pu()
t.seth(90)
t.fd(15)
t.seth(0)
t.fd(0)
t.pd()
t.seth(-10)
t.circle(-20, 90)

t.pu()
t.seth(90)
t.fd(30)
t.seth(0)
t.fd(237)
t.pd()
t.seth(-20)
t.circle(-300, 15)
t.pu()
t.seth(90)
t.fd(20)
t.seth(0)
t.fd(0)
t.pd()
t.seth(-170)
t.circle(20, 90)

# 脚
t.pensize(10)
t.color((240, 128, 128))
t.pu()
t.seth(90)
t.fd(-75)
t.seth(0)
t.fd(-180)
t.pd()
t.seth(-90)
t.fd(40)
t.seth(-180)
t.color("black")
t.pensize(15)
t.fd(20)

t.pensize(10)
t.color((240, 128, 128))
t.pu()
t.seth(90)
t.fd(40)
t.seth(0)
t.fd(90)
t.pd()
t.seth(-90)
t.fd(40)
t.seth(-180)
t.color("black")
t.pensize(15)
t.fd(20)

# 尾巴
t.pensize(4)
t.color((255, 155, 192))
t.pu()
t.seth(90)
t.fd(70)
t.seth(0)
t.fd(95)
t.pd()
t.seth(0)
t.circle(70, 20)
t.circle(10, 330)
t.circle(70, 30)
t.done()

热心网友 时间:2022-04-18 11:08

建议在知乎上问,知乎上高手多。
虽然我会用turtle,但画一个叮当猫什么的,还是比较复杂
声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com
cpa改分电话可信吗 有人今年收到这样的短信吗? 温馨提示 通知:你此次报考的湖南中级会 ...会计从业资格证,今天有陌生号码打电话说我没过,是真的吗?我都考三... 坠入星河的温柔仙句 惊艳所有人的优美文案 坠入星河的温柔仙句 温柔很仙的宝藏文案 温柔到心坎里的文案句子(温柔且治愈的短句子) 实习期劳务合同简易版 ...企业受伤,如果辞职是否还有补偿?医疗费谁出? 毛晓彤十大经典电视剧 这个锦尚天舞舞蹈里面的音乐是什么?急求 http://m.iqiyi.com/w_19rr... 小明洗碗看图写话150个字 turtle画图工具在哪里打开 耐热玻璃的概述 帮妈妈洗碗这篇看图写话怎么写 python语言程序设计:使用海龟绘图绘制奥运五环 好卓手机助手怎么样 帮妈妈洗碗等用这些词语放学看见水招书包干净道家... 玻璃耐高温吗 我也来帮忙看图写话做家务辛苦摆碗筷美滋滋 如何辨别耐高温玻璃的真假? 耐高温玻璃与钢化玻璃、硼硅玻璃、石英玻璃的区别... 二年级看图说话:帮妈妈收碗筷 洗碗看图写话120个字左右 用pycharm海龟绘图为什么窗口显示不出来? 耐热玻璃到底是种什么玻璃啊? 女孩帮妈妈洗碗看图写话一年级 耐高温玻璃的定义 python海龟绘图怎么让海龟斜着 帮妈妈洗碗看图写话 看图写话中小红帮妈妈洗碗 看图写句子帮妈妈洗碗应该怎么写 用和什么不一样造句 免费的小程序模板可以推荐用吗? 看图写话妈妈正在洗碗小朋友在拖地 透明耐高温材料有哪些啊? 温度最好是260℃以上的。... 关于python的turtle海龟画图模块的问题 看图写话吃饭时帮妈妈摆碗筷 耐高温玻璃 为什么visual的python调不出海龟画图界面,运行程... 什么和什么不能一起吃? 三星s手机助手怎么用? 烧烤炉耐高温玻璃用的是那种玻璃? 和什么食物 不能同时吃 看图说话我和妈妈收碗筷 怎么验证玻璃杯是高硼硅耐热玻璃杯 谁知道什么和什么不能一起吃 腾讯手机助手怎样 6000℃耐高温材料是什么? 与什么不同 用英语怎么说 一年级看图写话姐姐洗碗