Python miscellaneous studies use turtle to draw bear 2 (with code)

First put a picture you want to draw

Another process diagram

 

It seems to be okay so far, it’s still pretty cute.

Then, I added eye highlights, which gave it a bit of a pitiful look.

 After adding the mouth

.......

"Do you see me happy?"

import turtle as t
# turtle.pos()
# home() #以当前海龟位置为坐标原点

t.pensize(4)  # 画笔线条宽度
t.colormode(255)  # 画笔颜色模式

t.screensize(800, 6000, "#F0F0F0")  # 画布宽、高、背景颜色
t.speed(9)  # 画笔移动速度

# 变形的脑袋
t.pu()  # 提起画笔,不绘图
t.goto(0, 0)  # 移动至指定坐标
t.pd()  # 画笔移动时绘制图形
t.seth(30)  # 设置画笔角度
t.color(204, 147, 86)
t.begin_fill()
t.circle(100, 100)
t.circle(400, 20)
t.circle(100, 100)
t.circle(400, 20)
t.circle(100, 100)
t.end_fill()

# 耳朵
t.pu()
t.goto(-20, 200)
t.pd()
t.seth(30)
t.color(204, 147, 86)
t.begin_fill()
t.circle(50)
t.end_fill()

t.pu()
t.goto(-200, 150)
t.pd()
t.seth(30)
t.color(204, 147, 86)
t.begin_fill()
t.circle(50)
t.end_fill()

# 身子
t.pu()
t.goto(-180, -20)
t.pd()
t.seth(-130)
t.color(204, 147, 86)
t.begin_fill()
t.circle(500, 50)
t.seth(0)
t.fd(500)
t.seth(100)
t.circle(1000, 30)
t.end_fill()

# 右胳膊
t.pu()
t.goto(-10, 40)
t.pd()
t.color(204, 147, 86)
t.begin_fill()
t.seth(-30)
t.circle(-500, 30)
t.seth(-95)
t.circle(-300, 50)
t.end_fill()

# 胳膊细线
t.pu()
t.goto(70, -100)
t.pd()
t.color(66, 25, 5)
t.begin_fill()
t.seth(-50)
t.circle(-500, 30)
t.end_fill()

t.pu()
t.goto(-200, -100)
t.pd()
t.color(66, 25, 5)
t.begin_fill()
t.seth(240)
t.circle(500, 30)
t.end_fill()

# 白色肚子
t.pu()
t.goto(-60, -130)
t.pd()
t.seth(-130)
t.color(252, 248, 200)
t.begin_fill()
t.seth(90)
t.setheading(-90 + 270)
a = 5
for i in range(120):
    if 0 <= i < 30 or 60 <= i < 90:
        a += 0.08
        t.lt(3)  # 向左转3度
        t.fd(a)  # 向前走a的步长
    else:
        a -= 0.08
        t.lt(3)
        t.fd(a)
t.end_fill()

# 眼睛
t.pu()
t.color(5, 7, 4)
t.goto(-180, 80)
t.pd()
t.begin_fill()
t.seth(90)
t.setheading(100 + 270)
a = 0.3
for i in range(120):
    if 0 <= i < 30 or 60 <= i < 90:
        a += 0.08
        t.lt(3)  # 向左转3度
        t.fd(a)  # 向前走a的步长
    else:
        a -= 0.08
        t.lt(3)
        t.fd(a)
t.end_fill()

t.pu()
t.goto(-50, 120)
t.pd()
t.begin_fill()
t.seth(90)
t.setheading(120 + 270)
a = 0.3
for i in range(120):
    if 0 <= i < 30 or 60 <= i < 90:
        a += 0.08
        t.lt(3)  # 向左转3度
        t.fd(a)  # 向前走a的步长
    else:
        a -= 0.08
        t.lt(3)
        t.fd(a)
t.end_fill()

# 眼睛高光
t.pu()
t.color(252, 248, 200)
t.goto(-185, 115)
t.pd()
t.begin_fill()
t.seth(90)
t.circle(5)
t.end_fill()

t.pu()
t.color(252, 248, 200)
t.goto(-60, 155)
t.pd()
t.begin_fill()
t.seth(90)
t.circle(5)
t.end_fill()


# 嘴巴
t.pu()
t.goto(-230, 40)
t.pd()
t.color(168, 127, 97)
t.begin_fill()
t.seth(-15)
t.circle(200, 80)
t.seth(-80)
t.circle(-200, 30)
t.seth(230)
t.circle(-200, 50)
t.seth(150)
t.circle(-200, 28)
t.end_fill()

# 嘴巴细线
t.pu()
t.goto(-10, 90)
t.pd()
t.color(217, 157, 146)
t.seth(-120)
t.circle(-170, 70)


t.mainloop()

Guess you like

Origin blog.csdn.net/weixin_49828565/article/details/126480073