「Python绘图」绘制小猪佩奇

python 绘制小猪佩奇

一、预期结果

二、核心代码

import turtle
print("开始绘制小猪佩奇")
pen = turtle.Turtle()
pen.pensize(4)
#pen.hideturtle()

pen.speed(1000)

pen.color("#ff9bc0","pink")
pen.setheading(-30)
pen.pu()
pen.goto(-100,100)
pen.begin_fill()
pen.pd()
a=0.4
print("绘制鼻子")
for  i  in  range(120):
    if  0<=i<30  or  60<=i<90:
        a=a+0.08
        pen.lt(3)
        pen.fd(a)
    else:
        a=a-0.08
        pen.lt(3)
        pen.fd(a)
pen.end_fill()
pen.pu()
pen.seth(90)
pen.fd(25)
pen.setheading(0)
pen.fd(10)
pen.begin_fill()
pen.pd()
pen.circle(5)
pen.color("#A0522D")
pen.end_fill()
pen.pu()
pen.seth(0)
pen.fd(20)
pen.pd()
pen.pencolor("#ff9bc0")
pen.begin_fill()
pen.circle(5)
pen.color("#A0522D")
pen.end_fill()

print("绘制头部")
pen.color("#ff9bc0","pink")
pen.pu()
pen.seth(90)
pen.fd(41)
pen.seth(0)
pen.pd()
pen.begin_fill()
pen.seth(0)
pen.circle(-300,30)
pen.circle(-100,60)
pen.circle(-80,100)
pen.circle(-150,20)
pen.circle(-60,95)
pen.seth(161)
pen.circle(-300,15)
pen.pu()
pen.goto(-100,100)
pen.pd()
pen.seth(-30)
a=0.4



for  i  in  range(60):
    if  0<=i<30:
        a=a+0.08
        pen.lt(3)
        pen.fd(a)
    else:
        a=a-0.08
        pen.lt(3)
        pen.fd(a)
pen.end_fill()

print("绘制耳朵")
pen.color("#ff9bc0","pink")
pen.pu()
pen.seth(90)
pen.fd(-7)
pen.seth(0)
pen.fd(70)
pen.pd()
pen.begin_fill()
pen.seth(100)
pen.circle(-50,50)
pen.circle(-10,120)
pen.circle(-50,54)
pen.end_fill()
pen.pu()
pen.seth(90)
pen.fd(-12)
pen.seth(0)
pen.fd(30)
pen.pd()
pen.begin_fill()
pen.seth(100)
pen.circle(-50,50)
pen.circle(-10,120)
pen.circle(-50,56)
pen.end_fill()

pen.color("#ff9bc0","white")
pen.pu()
print("绘制眼睛")
pen.seth(90)
pen.fd(-20)
pen.seth(0)
pen.fd(-95)
pen.pd()
pen.begin_fill()
pen.circle(15)
pen.end_fill()
pen.color("black")
pen.pu()
pen.seth(90)
pen.fd(12)
pen.seth(0)
pen.fd(-3)
pen.pd()
pen.begin_fill()
pen.circle(3)
pen.end_fill()
pen.color("#ff9bc0","white")
pen.pu()
pen.seth(90)
pen.fd(-25)
pen.seth(0)
pen.fd(40)
pen.pd()
pen.begin_fill()
pen.circle(15)
pen.end_fill()
pen.color("black")
pen.pu()
pen.seth(90)
pen.fd(12)
pen.seth(0)
pen.fd(-3)
pen.pd()
pen.begin_fill()
pen.circle(3)
pen.end_fill()


print("绘制脸")
pen.color("#ff9bc0")
pen.pu()
pen.seth(90)
pen.fd(-95)
pen.seth(0)
pen.fd(65)
pen.pd()
pen.begin_fill()
pen.circle(30)
pen.end_fill()

print("绘制嘴巴")
pen.color("#EF4513")
pen.pu()
pen.seth(90)
pen.fd(15)
pen.seth(0)
pen.fd(-100)
pen.pd()
pen.seth(-80)
pen.circle(30,40)
pen.circle(40,80)

print("绘制身体")
pen.color("red","#FF6347")
pen.pu()
pen.seth(90)
pen.fd(-20)
pen.seth(0)
pen.fd(-78)
pen.pd()
pen.begin_fill()
pen.seth(-130)
pen.circle(100,10)
pen.circle(300,30)
pen.seth(0)
pen.fd(230)
pen.seth(90)
pen.circle(300,30)
pen.circle(100,3)
pen.color("#FF9BC0","#FF6464")
pen.seth(-135)
pen.circle(-80,63)
pen.circle(-150,24)
pen.end_fill()



print("绘制胳膊")
pen.color("#FF9BC0")
pen.pu()
pen.seth(90)
pen.fd(-40)
pen.seth(0)
pen.fd(-27)
pen.pd()
pen.seth(-160)
pen.circle(300,15)
pen.pu()
pen.seth(90)
pen.fd(15)
pen.seth(0)
pen.fd(0)
pen.pd()
pen.seth(-10)
pen.circle(-20,90)
pen.pu()
pen.seth(90)
pen.fd(30)
pen.seth(0)
pen.fd(237)
pen.pd()
pen.seth(-20)
pen.circle(-300,15)
pen.pu()
pen.seth(90)
pen.fd(20)
pen.seth(0)
pen.fd(0)
pen.pd()
pen.seth(-170)
pen.circle(20,90)


print("绘制腿和脚")
pen.pensize(10)
pen.color("#F08080")
pen.pu()
pen.seth(90)
pen.fd(-75)
pen.seth(0)
pen.fd(-180)
pen.pd()
pen.seth(-90)
pen.fd(40)
pen.seth(-180)
pen.color("black")
pen.pensize(15)
pen.fd(20)
pen.pensize(10)
pen.color("#F08080")
pen.pu()
pen.seth(90)
pen.fd(40)
pen.seth(0)
pen.fd(90)
pen.pd()
pen.seth(-90)
pen.fd(40)
pen.seth(-180)
pen.color("black")
pen.pensize(15)
pen.fd(20)


print("绘制尾巴")
pen.pensize(4)
pen.color("#FF9BC0")
pen.pu()
pen.seth(90)
pen.fd(70)
pen.seth(0)
pen.fd(95)
pen.pd()
pen.seth(0)
pen.circle(70,20)
pen.circle(10,330)
pen.circle(70,30)
# pen.mainloop()
# 隐藏画笔
pen.hideturtle()

print("绘制完成")
turtle.done()
相关推荐
汤米粥5 分钟前
小皮PHP连接数据库提示could not find driver
开发语言·php
冰淇淋烤布蕾8 分钟前
EasyExcel使用
java·开发语言·excel
艾思科蓝-何老师【H8053】8 分钟前
【ACM出版】第四届信号处理与通信技术国际学术会议(SPCT 2024)
人工智能·信号处理·论文发表·香港中文大学
拾荒的小海螺14 分钟前
JAVA:探索 EasyExcel 的技术指南
java·开发语言
秀儿还能再秀28 分钟前
机器学习——简单线性回归、逻辑回归
笔记·python·学习·机器学习
weixin_4526006936 分钟前
《青牛科技 GC6125:驱动芯片中的璀璨之星,点亮 IPcamera 和云台控制(替代 BU24025/ROHM)》
人工智能·科技·单片机·嵌入式硬件·新能源充电桩·智能充电枪
学术搬运工36 分钟前
【珠海科技学院主办,暨南大学协办 | IEEE出版 | EI检索稳定 】2024年健康大数据与智能医疗国际会议(ICHIH 2024)
大数据·图像处理·人工智能·科技·机器学习·自然语言处理
马剑威(威哥爱编程)39 分钟前
哇喔!20种单例模式的实现与变异总结
java·开发语言·单例模式
白-胖-子1 小时前
【蓝桥等考C++真题】蓝桥杯等级考试C++组第13级L13真题原题(含答案)-统计数字
开发语言·c++·算法·蓝桥杯·等考·13级
右恩1 小时前
AI大模型重塑软件开发:流程革新与未来展望
人工智能