• 03-小猪佩奇


    import turtle as t
    
    t.pensize(4)#设置画笔宽度
    #t.hideturtle()#隐藏画笔
    t.colormode(255)#颜色模式设为rgb模式
    t.speed(10)#设置画笔速度
    t.home()#初始化画笔位置(原点)、方向(东)
    
    def draw_nose():
        t.color((255, 155, 192), "pink")
        t.penup()
        t.goto(-100,100)
        t.pendown()
        t.seth(-30)
        t.begin_fill()
    
        #鼻子轮廓
        a=0.4
        for i in range(120):
            if 0<=i<30 or 60<=i<90:
                a+=0.08
                t.left(3)
                t.fd(a)
            else:
                a-=0.08
                t.left(3)
                t.fd(a)
        t.end_fill()
    
        #鼻孔
        t.penup()
        t.goto(-95,125)
        t.pendown()
        t.begin_fill()
        t.fillcolor(160,82,45)
        t.circle(5)
        t.end_fill()
    
        #第二个鼻孔
        t.penup()
        t.goto(-70,125)
        t.pendown()
        t.seth(10)
        t.begin_fill()
        t.fillcolor(160,82,45)
        t.circle(5)
        t.end_fill()
    
    
    #头部
    def draw_head():
        t.color((255, 155, 192), "pink")
        t.penup()
        t.goto(-70,166)
        t.seth(180)
        t.pendown()
    
        t.begin_fill()
        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.penup()
        t.goto(-100,100)
        t.seth(-30)
        t.pendown()
    
        a=0.4
        for i in range(60):
            if 0<=i<30:
                a+=0.08
                t.left(3)
                t.fd(a)
            else:
                a-=0.08
                t.left(3)
                t.fd(a)
    
        t.end_fill()
    
    
    #耳朵
    def draw_ear():
        t.color((255, 155, 192), "pink")
    
        #第一只耳朵
        t.penup()
        t.goto(6.5,157)
        t.seth(100)
        t.pendown()
    
        t.begin_fill()
        t.circle(-50,50)
        t.circle(-10,120)
        t.circle(-50,54)
        t.end_fill()
    
        #第二只耳朵
        t.penup()
        t.goto(59,137.5)
        t.seth(100)
        t.pendown()
    
        t.begin_fill()
        t.circle(-50,50)
        t.circle(-10,120)
        t.circle(-50,57)
        t.end_fill()
    
    
    def draw_eye():
        #第一只眼睛
        t.color((255, 155, 192), "white")
    
        t.penup()
        t.goto(-14.5,109)
        t.seth(0)
        t.pendown()
    
        t.begin_fill()
        t.circle(15)
        t.end_fill()
    
        t.penup()
        t.goto(-17.5,121)
        t.seth(0)
        t.pendown()
    
        t.color("black")
        t.circle(3)
    
        #第二只眼睛
        t.color((255, 155, 192), "white")
    
        t.penup()
        t.goto(22.5,96)
        t.seth(0)
        t.pendown()
    
        t.begin_fill()
        t.circle(15)
        t.end_fill()
    
        t.penup()
        t.goto(19.5,108)
        t.seth(0)
        t.pendown()
    
        t.color("black")
        t.circle(3)
    
    def draw_gill():
        t.color(255,155,192)
        t.penup()
        t.goto(84.5,13)
        t.seth(0)
        t.pendown()
    
        t.begin_fill()
        t.circle(30)
        t.end_fill()
    
    def draw_mouth():
        t.color(255,60,20)
        t.penup()
        t.goto(-15.6,28)
        t.seth(-80)
        t.pendown()
    
        t.circle(30,40)
        t.circle(40,80)
    
    def draw_body():
        t.color("red",(255,100,70))
    
        t.penup()
        t.goto(-32,-9.5)
        t.seth(-130)
        t.pendown()
    
        t.begin_fill()
        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.seth(-135)
        t.circle(-80,63)
        t.circle(-150,24)
    
        t.end_fill()
    
    def draw_hand():
        t.color(255,155,192)
    #左手
        t.penup()
        t.goto(-57.5,-48)
        t.seth(-160)
        t.pendown()
    
        t.circle(300,15)
    
        t.penup()
        t.goto(-127,-69)
        t.seth(-10)
        t.pendown()
    
        t.circle(-20,90)
    
    #右手
        t.penup()
        t.goto(126.5,-62)
        t.seth(-20)
        t.pendown()
    
        t.circle(300,15)
    
        t.penup()
        t.goto(193,-68.5)
        t.seth(-120)
        t.pendown()
    
        t.circle(20,90)
    
    def draw_foot():
        #左脚
        t.pensize(10)
        t.pencolor(240, 128, 128)
    
        t.penup()
        t.goto(-0.5,-176.5)
        t.seth(-90)
        t.pendown()
    
        t.fd(40)
    
        t.seth(-180)
        t.pencolor("black")
        t.pensize(15)
        t.fd(20)
    
    #右脚
        t.pensize(10)
        t.pencolor(240, 128, 128)
    
        t.penup()
        t.goto(69.5,-176.5)
        t.seth(-90)
        t.pendown()
    
        t.fd(40)
    
        t.seth(-180)
        t.pencolor("black")
        t.pensize(15)
        t.fd(20)
    
    
    def main():
        draw_nose()
        draw_head()
        draw_ear()
        draw_eye()
        draw_gill()
        draw_mouth()
        draw_body()
        draw_hand()
        draw_foot()
    
    if __name__=="__main__":
        main()
        t.done()
  • 相关阅读:
    《vue.js2.0从入门到放弃》学习之路
    动画统计图
    超简单的走马灯效果
    关于css那些常用却有点记不住的属性
    圣杯布局跟双飞翼布局
    最简单的http服务器(C#)
    sql union用法和sql union all用法,sql union效率
    存储过程函数中如何定义表变量,删除表变量内容
    C# 通过分析netstat an所得信息 查看本机所监听的端口 及判断某端口是否可用
    Microsoft .NET Framework 各版可再发行组件包
  • 原文地址:https://www.cnblogs.com/zhanghua-322/p/11444028.html
Copyright © 2020-2023  润新知