猫史档案馆


【Python作品分享】小猪佩奇【作品秀】

用户:無一郎無一郎查看:0 回复:1 评论:0 创建时间:2019-07-15T21:48:48


【作品展示】

center_image

 

【作品介绍】

可以快速画出一只小猪佩奇

 

【作品源代码】

import turtle
import turtle as t


# coding:utf-8

t.screensize(400, 300, "blue")
# 设置画笔的大小
t.pensize(4)
# 设置GBK颜色范围为0-255
t.colormode(255)
# 设置画笔颜色和填充颜色(pink)
t.color((255,155,192),"pink")
# 设置主窗口的大小为840*500
t.setup(840,500)
# 设置画笔速度为10
t.speed(10)
# 鼻子
# 提笔
t.penup()
# 画笔前往坐标(-100,100)
t.goto((-100), 100)
# 下笔
t.pendown()
# 笔的角度为-30°
t.setheading((-30))
# 外形填充的开始标志
t.begin_fill()
a = 0.4
for i in range(120):
    if (0<=i<30 or 60<=i<90):
        a = (a + 0.08)
        # 向左转3度
        t.left(3)
        #    向前走a的步长
        t.forward(a)
    else:
        a = (a - 0.08)
        t.left(3)
        t.forward(a)
# 依据轮廓填充
t.end_fill()
# 提笔
t.penup()
# 笔的角度为90度
t.setheading(90)
# 向前移动25
t.forward(25)
# 转换画笔的角度为0
t.setheading(0)
t.forward(10)
t.pendown()
# 设置画笔颜色
t.pencolor(255, 155, 192)
t.setheading(10)
t.begin_fill()
# 画一个半径为5的圆
t.circle(5)
# 设置画笔和填充颜色
t.color(160,82,45)
t.end_fill()
t.penup()
t.setheading(0)
t.forward(20)
t.pendown()
t.pencolor(255, 155, 192)
t.setheading(10)
t.begin_fill()
t.circle(5)
t.color(160,82,45)
t.end_fill()
# 头
t.color((255,155,192),"pink")
t.penup()
t.setheading(90)
t.forward(41)
t.setheading(0)
t.forward(0)
t.pendown()
t.begin_fill()
t.setheading(180)
# 顺时针画一个半径为300,圆心角为30°的园
t.circle(300, (-30))
t.circle(100, (-60))
t.circle(80, (-100))
t.circle(150, (-20))
t.circle(60, (-95))
t.setheading(161)
t.circle((-300), 15)
t.penup()
t.goto((-100), 100)
t.pendown()
t.setheading((-30))
a = 0.4
for i in range(60):
    if (0<=i<30 or 60<=i<90):
        a = (a + 0.08)
        # 向左转3度
        t.left(3)
        #    向前走a的步长
        t.forward(a)
    else:
        a = (a - 0.08)
        t.left(3)
        t.forward(a)
t.end_fill()
# 耳朵
t.color((255,155,192),"pink")
t.penup()
t.setheading(90)
t.forward((-7))
t.setheading(0)
t.forward(70)
t.pendown()
t.begin_fill()
t.setheading(100)
t.circle((-50), 50)
t.circle((-10), 120)
t.circle((-50), 54)
t.end_fill()
t.penup()
t.setheading(90)
t.forward((-12))
t.setheading(0)
t.forward(30)
t.pendown()
t.begin_fill()
t.setheading(100)
t.circle((-50), 50)
t.circle((-10), 120)
t.circle((-50), 56)
t.end_fill()
# 眼睛
t.color((255,155,192),"white")
t.penup()
t.setheading(90)
t.forward((-20))
t.setheading(0)
t.forward((-95))
t.pendown()
t.begin_fill()
t.circle(15)
t.end_fill()
t.color("black")
t.penup()
t.setheading(90)
t.forward(12)
t.setheading(0)
t.forward((-3))
t.pendown()
t.begin_fill()
t.circle(3)
t.end_fill()
t.color((255,155,192),"white")
t.penup()
t.setheading(90)
t.forward((-25))
t.setheading(0)
t.forward(40)
t.pendown()
t.begin_fill()
t.circle(15)
t.end_fill()
t.color("black")
t.penup()
t.setheading(90)
t.forward(12)
t.setheading(0)
t.forward((-3))
t.pendown()
t.begin_fill()
t.circle(3)
t.end_fill()
# 腮
t.color((255,155,192))
t.penup()
t.setheading(90)
t.forward((-95))
t.setheading(0)
t.forward(65)
t.pendown()
t.begin_fill()
t.circle(30)
t.end_fill()
# 嘴
t.color(239,69,19)
t.penup()
t.setheading(90)
t.forward(15)
t.setheading(0)
t.forward((-100))
t.pendown()
t.setheading((-80))
t.circle(30, 40)
t.circle(40, 80)
# 身体
t.color("red",(255,99,71))
t.penup()
t.setheading(90)
t.forward((-20))
t.setheading(0)
t.forward((-78))
t.pendown()
t.begin_fill()
t.setheading((-130))
t.circle(100, 10)
t.circle(300, 30)
t.setheading(0)
t.forward(230)
t.setheading(90)
t.circle(300, 30)
t.circle(100, 3)
t.color((255,155,192),(255,100,100))
t.setheading((-135))
t.circle((-80), 63)
t.circle((-150), 24)
t.end_fill()
# 手
t.color((255,155,192))
t.penup()
t.setheading(90)
t.forward((-40))
t.setheading(0)
t.forward((-27))
t.pendown()
t.setheading((-160))
t.circle(300, 15)
t.penup()
t.setheading(90)
t.forward(15)
t.setheading(0)
t.forward(0)
t.pendown()
t.setheading((-10))
t.circle((-20), 90)
t.penup()
t.setheading(90)
t.forward(30)
t.setheading(0)
t.forward(237)
t.pendown()
t.setheading((-20))
t.circle((-300), 15)
t.penup()
t.setheading(90)
t.forward(20)
t.setheading(0)
t.forward(0)
t.pendown()
t.setheading((-170))
t.circle(20, 90)
# 脚
t.pensize(10)
t.color((240,128,128))
t.penup()
t.setheading(90)
t.forward((-75))
t.setheading(0)
t.forward((-180))
t.pendown()
t.setheading((-90))
t.forward(40)
t.setheading((-180))
t.color("black")
t.pensize(15)
t.forward(20)
t.pensize(10)
t.color((240,128,128))
t.penup()
t.setheading(90)
t.forward(40)
t.setheading(0)
t.forward(90)
t.pendown()
t.setheading((-90))
t.forward(40)
t.setheading((-180))
t.color("black")
t.pensize(15)
t.forward(20)
# 尾巴
t.pensize(4)
t.color((255,155,192))
t.penup()
t.setheading(90)
t.forward(70)
t.setheading(0)
t.forward(95)
t.pendown()
t.setheading(0)
t.circle(70, 20)
t.circle(10, 330)
t.circle(70, 30)
turtle.done()

 

【提示】

部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:

https://python.codemao.cn


回复

上一页1 页 / 共 1下一页
幸福其实很简单幸福其实很简单

厉害

 

点赞0


评论