小海龟

2022-06-10  本文已影响0人  子非鱼意
from turtle import *
import random

speed(100)
"""
雪花
"""


def snow(snow_count):
    hideturtle()
    speed(500)
    pensize(2)
    for i in range(snow_count):
        pencolor("snow")
        pu()
        goto(random.randint(-600, 350), random.randint(1, 270))
        pd()
        dens = random.randint(8, 12)
        snowsize = random.randint(10, 14)
        for _ in range(dens):
            forward(snowsize)  # 向当前画笔方向移动snowsize像素长度
            backward(snowsize)  # 向当前画笔相反方向移动snowsize像素长度
            right(360 / dens)  # 顺时针移动360 / dens度


"""
背景草地雪山
"""
bgcolor("skyblue")

# 草地
penup()
goto(-800, -100)
pendown()
color("limegreen")
begin_fill()
for i in range(2):
    forward(1600)
    right(90)
    forward(400)
    right(90)
end_fill()

# 左边的山
penup()
goto(-400, -100)
pendown()
color("dimgray")
begin_fill()
for i in range(3):
    forward(300)
    left(120)
end_fill()

# 右边的山
penup()
goto(100, -100)
pendown()
begin_fill()
for i in range(3):
    forward(300)
    left(120)
end_fill()

# 中间的山
penup()
goto(-160, -100)
pendown()
color("gray")
begin_fill()
for i in range(3):
    forward(400)
    left(120)
end_fill()

# 中间的山 雪
penup()
goto(-35, 120)
pendown()
color("white")
begin_fill()
left(35)
forward(60)
right(90)
forward(30)
left(100)
forward(45)
right(85)
forward(65)
left(160)
forward(150)
end_fill()

# 左边的山 雪
penup()
goto(-215, 100)
pendown()
color("snow")
begin_fill()
forward(70)
left(120)
forward(75)
left(150)
forward(45)
right(90)
forward(45)
left(120)
end_fill()

# 右边的山 雪
penup()
goto(203, 80)
pendown()
begin_fill()
forward(95)
right(120)
forward(80)
right(150)
forward(50)
left(70)
end_fill()

left(50)

# 太阳
penup()
goto(-500, 350)
pendown()
color("yellow")
begin_fill()
circle(125)
end_fill()

# 相同的树
def tree():
    # 树干
    color("saddlebrown")
    begin_fill()
    for i in range(2):
        forward(40)
        left(90)
        forward(10)
        left(90)
    end_fill()

    # 转向
    forward(10)
    left(90)
    forward(5)

    # 离开树
    color("forestgreen")
    begin_fill()
    circle(25)
    end_fill()

    right(90)


# 第一个树
penup()
goto(-25, -200)
pendown()
tree()

# 第二个树
penup()
goto(200, -150)
pendown()
tree()

# 第三个树
penup()
goto(300, -250)
pendown()
tree()

# 第四个树
penup()
goto(-300, -250)
pendown()
tree()

# 第五个树
penup()
goto(-200, -100)
pendown()
tree()

"""
冰墩墩
"""
# 左手
penup()
goto(177, 112)
pencolor("lightgray")
pensize(3)
fillcolor("white")
begin_fill()
pendown()
setheading(80)
circle(-45, 200)
circle(-300, 23)
end_fill()

# 左手内
penup()
goto(182, 95)
pencolor("black")
pensize(1)
fillcolor("black")
begin_fill()
setheading(95)
pendown()
circle(-37, 160)
circle(-20, 50)
circle(-200, 30)
end_fill()
# 轮廓
# 头顶
penup()
goto(-73, 230)
pencolor("lightgray")
pensize(3)
fillcolor("white")
begin_fill()
pendown()
setheading(20)
circle(-250, 35)
# 左耳
setheading(50)
circle(-42, 180)
# 左侧
setheading(-50)
circle(-190, 30)
circle(-320, 45)
# 左腿
circle(120, 30)
circle(200, 12)
circle(-18, 85)
circle(-180, 23)
circle(-20, 110)
circle(15, 115)
circle(100, 12)
# 右腿
circle(15, 120)
circle(-15, 110)
circle(-150, 30)
circle(-15, 70)
circle(-150, 10)
circle(200, 35)
circle(-150, 20)
# 右手
setheading(-120)
circle(50, 30)
circle(-35, 200)
circle(-300, 23)
# 右侧
setheading(86)
circle(-300, 26)
# 右耳
setheading(122)
circle(-53, 160)
end_fill()

# 右耳内
penup()
goto(-130, 180)
pencolor("black")
pensize(1)
fillcolor("black")
begin_fill()
pendown()
setheading(120)
circle(-28, 160)
setheading(210)
circle(150, 20)
end_fill()

# 左耳内
penup()
goto(90, 230)
setheading(40)
begin_fill()
pendown()
circle(-30, 170)
setheading(125)
circle(150, 23)
end_fill()

# 右手内
penup()
goto(-180, -55)
fillcolor("black")
begin_fill()
setheading(-120)
pendown()
circle(50, 30)
circle(-27, 200)
circle(-300, 20)
setheading(-90)
circle(300, 14)
end_fill()

# 左腿内
penup()
goto(108, -168)
fillcolor("black")
begin_fill()
pendown()
setheading(-115)
circle(110, 15)
circle(200, 10)
circle(-18, 80)
circle(-180, 13)
circle(-20, 90)
circle(15, 60)
setheading(42)
circle(-200, 29)
end_fill()
# 右腿内
penup()
goto(-38, -210)
fillcolor("black")
begin_fill()
pendown()
setheading(-155)
circle(15, 100)
circle(-10, 110)
circle(-100, 30)
circle(-15, 65)
circle(-100, 10)
circle(200, 15)
setheading(-14)
circle(-200, 27)
end_fill()

# 右眼
# 眼圈
penup()
goto(-64, 120)
begin_fill()
pendown()
setheading(40)
circle(-35, 152)
circle(-100, 50)
circle(-35, 130)
circle(-100, 50)
end_fill()
# 眼珠
penup()
goto(-47, 55)
fillcolor("white")
begin_fill()
pendown()
setheading(0)
circle(25, 360)
end_fill()
penup()
goto(-45, 62)
pencolor("darkslategray")
fillcolor("darkslategray")
begin_fill()
pendown()
setheading(0)
circle(19, 360)
end_fill()
penup()
goto(-45, 68)
fillcolor("black")
begin_fill()
pendown()
setheading(0)
circle(10, 360)
end_fill()
penup()
goto(-47, 86)
pencolor("white")
fillcolor("white")
begin_fill()
pendown()
setheading(0)
circle(5, 360)
end_fill()

# 左眼
# 眼圈
penup()
goto(51, 82)
fillcolor("black")
begin_fill()
pendown()
setheading(120)
circle(-32, 152)
circle(-100, 55)
circle(-25, 120)
circle(-120, 45)
end_fill()
# 眼珠
penup()
goto(79, 60)
fillcolor("white")
begin_fill()
pendown()
setheading(0)
circle(24, 360)
end_fill()
penup()
goto(79, 64)
pencolor("darkslategray")
fillcolor("darkslategray")
begin_fill()
pendown()
setheading(0)
circle(19, 360)
end_fill()
penup()
goto(79, 70)
fillcolor("black")
begin_fill()
pendown()
setheading(0)
circle(10, 360)
end_fill()
penup()
goto(79, 88)
pencolor("white")
fillcolor("white")
begin_fill()
pendown()
setheading(0)
circle(5, 360)
end_fill()

# 鼻子
penup()
goto(37, 80)
fillcolor("black")
begin_fill()
pendown()
circle(-8, 130)
circle(-22, 100)
circle(-8, 130)
end_fill()

# 嘴
penup()
goto(-15, 48)
setheading(-36)
begin_fill()
pendown()
circle(60, 70)
setheading(-132)
circle(-45, 100)
end_fill()

# 彩虹圈
penup()
goto(-135, 120)
pensize(5)
pencolor("cyan")
pendown()
setheading(60)
circle(-165, 150)
circle(-130, 78)
circle(-250, 30)
circle(-138, 105)
penup()
goto(-131, 116)
pencolor("slateblue")
pendown()
setheading(60)
circle(-160, 144)
circle(-120, 78)
circle(-242, 30)
circle(-135, 105)
penup()
goto(-127, 112)
pencolor("orangered")
pendown()
setheading(60)
circle(-155, 136)
circle(-116, 86)
circle(-220, 30)
circle(-134, 103)
penup()
goto(-123, 108)
pencolor("gold")
pendown()
setheading(60)
circle(-150, 136)
circle(-104, 86)
circle(-220, 30)
circle(-126, 102)
penup()
goto(-120, 104)
pencolor("greenyellow")
pendown()
setheading(60)
circle(-145, 136)
circle(-90, 83)
circle(-220, 30)
circle(-120, 100)
penup()

# 爱心
penup()
goto(220, 115)
pencolor("brown")
pensize(1)
fillcolor("brown")
begin_fill()
pendown()
setheading(36)
circle(-8, 180)
circle(-60, 24)
setheading(110)
circle(-60, 24)
circle(-8, 180)
end_fill()

# 五环
penup()
goto(-5, -180)
pendown()
pencolor("blue")
circle(6)
penup()
goto(10, -180)
pendown()
pencolor("black")
circle(6)
penup()
goto(25, -180)
pendown()
pencolor("brown")
circle(6)
penup()
goto(2, -185)
pendown()
pencolor("lightgoldenrod")
circle(6)
penup()
goto(16, -185)
pendown()
pencolor("green")
circle(6)
penup()

pencolor("black")
goto(-100, -160)
write("2022北京冬奥会,欢迎您的到来", font=("YaHei", 10, "bold italic"))

snow(30)
done()
上一篇下一篇

猜你喜欢

热点阅读