「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()
相关推荐
Biomamba生信基地2 分钟前
R语言基础| 功效分析
开发语言·python·r语言·医药
手可摘星河4 分钟前
php中 cli和cgi的区别
开发语言·php
神秘的土鸡6 分钟前
神经网络图像隐写术:用AI隐藏信息的艺术
人工智能·深度学习·神经网络
数据分析能量站7 分钟前
神经网络-LeNet
人工智能·深度学习·神经网络·机器学习
Jaly_W15 分钟前
用于航空发动机故障诊断的深度分层排序网络
人工智能·深度学习·故障诊断·航空发动机
CodeClimb17 分钟前
【华为OD-E卷-木板 100分(python、java、c++、js、c)】
java·javascript·c++·python·华为od
小嗷犬18 分钟前
【论文笔记】Cross-lingual few-shot sign language recognition
论文阅读·人工智能·多模态·少样本·手语翻译
夜幕龙25 分钟前
iDP3复现代码数据预处理全流程(二)——vis_dataset.py
人工智能·python·机器人
CT随28 分钟前
Redis内存碎片详解
java·开发语言
anlog37 分钟前
C#在自定义事件里传递数据
开发语言·c#·自定义事件