其他分享
首页 > 其他分享> > 冰墩墩代码实现

冰墩墩代码实现

作者:互联网

最近很火的抖音冰墩墩代码,欢迎取用。

import turtle as tws

tws.title('冰墩墩')

tws.speed(10)  # 速度

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

# 左手内
tws.penup()
tws.goto(182, 95)
tws.pencolor("black")
tws.pensize(1)
tws.fillcolor("black")
tws.begin_fill()
tws.setheading(95)
tws.pendown()
tws.circle(-37, 160)
tws.circle(-20, 50)
tws.circle(-200, 30)
tws.end_fill()

# 轮廓
# 头顶
tws.penup()
tws.goto(-73, 230)
tws.pencolor("lightgray")
tws.pensize(3)
tws.fillcolor("white")
tws.begin_fill()
tws.pendown()
tws.setheading(20)
tws.circle(-250, 35)

# 左耳
tws.setheading(50)
tws.circle(-42, 180)

# 左侧
tws.setheading(-50)
tws.circle(-190, 30)
tws.circle(-320, 45)

# 左腿
tws.circle(120, 30)
tws.circle(200, 12)
tws.circle(-18, 85)
tws.circle(-180, 23)
tws.circle(-20, 110)
tws.circle(15, 115)
tws.circle(100, 12)

# 右腿
tws.circle(15, 120)
tws.circle(-15, 110)
tws.circle(-150, 30)
tws.circle(-15, 70)
tws.circle(-150, 10)
tws.circle(200, 35)
tws.circle(-150, 20)


# 右手
tws.setheading(-120)
tws.circle(50, 30)
tws.circle(-35, 200)
tws.circle(-300, 23)

# 右侧
tws.setheading(86)
tws.circle(-300, 26)

# 右耳
tws.setheading(122)
tws.circle(-53, 160)
tws.end_fill()

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

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

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

# 左腿内
tws.penup()
tws.goto(108, -168)
tws.fillcolor("black")
tws.begin_fill()
tws.pendown()
tws.setheading(-115)
tws.circle(110, 15)
tws.circle(200, 10)
tws.circle(-18, 80)
tws.circle(-180, 13)
tws.circle(-20, 90)
tws.circle(15, 60)
tws.setheading(42)
tws.circle(-200, 29)
tws.end_fill()

# 右腿内
tws.penup()
tws.goto(-38, -210)
tws.fillcolor("black")
tws.begin_fill()
tws.pendown()
tws.setheading(-155)
tws.circle(15, 100)
tws.circle(-10, 110)
tws.circle(-100, 30)
tws.circle(-15, 65)
tws.circle(-100, 10)
tws.circle(200, 15)
tws.setheading(-14)
tws.circle(-200, 27)
tws.end_fill()

# 右眼
# 眼圈
tws.penup()
tws.goto(-64, 120)
tws.begin_fill()
tws.pendown()
tws.setheading(40)
tws.circle(-35, 152)
tws.circle(-100, 50)
tws.circle(-35, 130)
tws.circle(-100, 50)
tws.end_fill()

# 眼珠
tws.penup()
tws.goto(-47, 55)
tws.fillcolor("white")
tws.begin_fill()
tws.pendown()
tws.setheading(0)
tws.circle(25, 360)
tws.end_fill()
tws.penup()
tws.goto(-45, 62)
tws.pencolor("darkslategray")
tws.fillcolor("darkslategray")
tws.begin_fill()
tws.pendown()
tws.setheading(0)
tws.circle(19, 360)
tws.end_fill()
tws.penup()
tws.goto(-45, 68)
tws.fillcolor("black")
tws.begin_fill()
tws.pendown()
tws.setheading(0)
tws.circle(10, 360)
tws.end_fill()
tws.penup()
tws.goto(-47, 86)
tws.pencolor("white")
tws.fillcolor("white")
tws.begin_fill()
tws.pendown()
tws.setheading(0)
tws.circle(5, 360)
tws.end_fill()

# 左眼
# 眼圈
tws.penup()
tws.goto(51, 82)
tws.fillcolor("black")
tws.begin_fill()
tws.pendown()
tws.setheading(120)
tws.circle(-32, 152)
tws.circle(-100, 55)
tws.circle(-25, 120)
tws.circle(-120, 45)
tws.end_fill()


# 眼珠
tws.penup()
tws.goto(79, 60)
tws.fillcolor("white")
tws.begin_fill()
tws.pendown()
tws.setheading(0)
tws.circle(24, 360)
tws.end_fill()
tws.penup()
tws.goto(79, 64)
tws.pencolor("darkslategray")
tws.fillcolor("darkslategray")
tws.begin_fill()
tws.pendown()
tws.setheading(0)
tws.circle(19, 360)
tws.end_fill()
tws.penup()
tws.goto(79, 70)
tws.fillcolor("black")
tws.begin_fill()
tws.pendown()
tws.setheading(0)
tws.circle(10, 360)
tws.end_fill()
tws.penup()
tws.goto(79, 88)
tws.pencolor("white")
tws.fillcolor("white")
tws.begin_fill()
tws.pendown()
tws.setheading(0)
tws.circle(5, 360)
tws.end_fill()

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

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

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

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

# 五环
tws.penup()
tws.goto(-5, -170)
tws.pendown()
tws.pencolor("blue")
tws.circle(6)
tws.penup()
tws.goto(10, -170)
tws.pendown()
tws.pencolor("black")
tws.circle(6)
tws.penup()
tws.goto(25, -170)
tws.pendown()
tws.pencolor("brown")
tws.circle(6)
tws.penup()
tws.goto(2, -175)
tws.pendown()
tws.pencolor("lightgoldenrod")
tws.circle(6)
tws.penup()
tws.goto(16, -175)
tws.pendown()
tws.pencolor("green")
tws.circle(6)
tws.penup()
#文字
tws.pencolor("black")
tws.goto(-16, -160)
tws.write("BEIJING 2022", font=('Arial', 10, 'bold italic'))
tws.hideturtle()
tws.done()

标签:goto,penup,实现,代码,setheading,tws,circle,冰墩,fill
来源: https://blog.csdn.net/zwslovexyj/article/details/122844303