m0_71511310 2022-06-23 19:49 采纳率: 100%
浏览 50
已结题

Python turtle库代码修改

问题遇到的现象和发生背景

img


想把这个效果增加身上有洞洞的样子,像下图

img

from turtle import *

#大致外观
setup(600,600)
pensize(3)
speed(20)
color('black','yellow')
penup()
goto(-120,120)
pendown()
begin_fill()
seth(-45) #Turtle中的turtle.seth(angle)函数表示小乌龟启动时运动的方向
for i in range(0,4):
for i in range(0,5):
circle(15,90)
circle(-15,90)
right(90)
end_fill()

#眼睛
pensize(1)
color('black','white')
penup()
goto(-70,30)
pendown()
begin_fill()
circle(30)
end_fill()

#1眼睛
color('white','blue')
penup()
goto(-40,43)
pendown()
begin_fill()
circle(10)
end_fill()

#2眼睛
color('white','black')
penup()
goto(-35,46)
pendown()
begin_fill()
circle(5)
end_fill()

#左眉毛1
pensize(3)
color('black')
penup()
goto(-68,82)
pendown()
fd(6)

#左眉毛2
pensize(3)
color('black')
penup()
goto(-50,88)
pendown()
right(45)
fd(6)

#左眉毛3
pensize(3)
color('black')
penup()
goto(-30,82)
pendown()
right(30)
fd(6)

#右眼睛
pensize(1)
color('black','white')
penup()
goto(3,67)
pendown()
begin_fill()
circle(30)
end_fill()

#右1眼睛
color('white','blue')
penup()
goto(3,56)
pendown()
begin_fill()
circle(10)
end_fill()

#右2眼睛
color('white','black')
penup()
goto(7,54)
pendown()
begin_fill()
circle(5)
end_fill()

#右眉毛1
pensize(3)
color('black')
penup()
goto(10,82)
pendown()
left(50)
fd(6)

#右眉毛2
pensize(3)
color('black')
penup()
goto(30,88)
pendown()
right(20)
fd(6)

#右眉毛3
pensize(3)
color('black')
penup()
goto(50,82)
pendown()
right(15)
fd(6)

#嘴巴
pensize(1)
color('black','IndianRed3')
penup()
goto(-86,-20)
pendown()
left(65)
begin_fill()
right(33)
circle(70,150)

circle(120,80)

fd(10)
left(130)
circle(-184,45)
end_fill()

#舌头
color('black', 'orange red')
penup()
goto(-66,-50)
pendown()
right(130)
circle(-140,46)

#鼻子
penup()
goto(-15,10)
pendown()
fd(40)
circle(5,180)
fd(40)

#裤子
color('black','white')
penup()
goto(-123,-85)
pendown()
begin_fill()
left(100)
fd(20)

left(93)
fd(225)

left(95)
fd(20)

left(85)
fd(225)
end_fill()

#二层裤子
color('black','orange4')
penup()
goto(-123,-106)
pendown()
begin_fill()
left(90)
fd(30)
left(90)
fd(225)
left(90)
fd(30)
left(90)
fd(225)
end_fill()

#裤缝
color('black')
pensize(8)
for i in range(0,4):
penup()
goto(-83+(i*60),-120)
pendown()
fd(30)

#裤腿1
color('black','orange3')
pensize(1)
penup()
goto(-63,-137)
pendown()
begin_fill()
left(90)
fd(10)
left(30)
circle(15,120)
left(30)
fd(10)
left(90)
fd(30)
end_fill()

#裤腿2
color('black','orange3')
pensize(1)
penup()
goto(23,-137)
pendown()
begin_fill()
left(90)
fd(10)
left(30)
circle(15,120)
left(30)
fd(10)
left(90)
fd(30)
end_fill()

#腿1
color('black')
penup()
goto(-53,-155)
pendown()
left(90)
fd(65)
fd(30)
left(90)
fd(20)
penup()
goto(-43,-155)
pendown()
right(90)
fd(60)
circle(20,90)
fillcolor('black')
begin_fill()
fd(5)
circle(-7,180)
fd(35)
right(90)
fd(24)
end_fill()

#腿2
color('black')
penup()
goto(33,-152)
pendown()
right(180)
fd(55)
fd(30)
left(90)
fd(20)
penup()
goto(43,-152)
pendown()
right(90)
fd(65)
circle(20,90)
fillcolor('black')
begin_fill()
circle(-7,180)
fd(32)
right(90)
fd(22)
end_fill()

#左手
color('black','yellow')
penup()
goto(-120,-10)
pendown()
begin_fill()
left(45)
fd(100)
circle(-15,80)
fd(5)
circle(5,180)
fd(20)
#第2个手指
right(150)
fd(35)
circle(5,180)
fd(40)

#第3个手指
right(150)
fd(30)
circle(5,180)
fd(30)

#第4个手指
right(140)
fd(30)
circle(5,180)
fd(45)
circle(15,90)

right(40)
right(70)
fd(110)
end_fill()

#右手
color('black','yellow')
penup()
goto(90,-10)
pendown()
begin_fill()
left(90)
fd(100)
circle(-15,80)
fd(5)
circle(5,180)
fd(20)
#第2个手指
right(150)
fd(35)
circle(5,180)
fd(40)

#第3个手指

right(150)
fd(30)
circle(5,180)
fd(30)

#第4个手指

right(140)
fd(30)
circle(5,180)
fd(45)
circle(15,90)

right(40)
right(70)
fd(98)
end_fill()

penup()
goto(-120,160)
pendown()
color("red")
write("666", font=('Arial', 40, 'normal'))
hideturtle()
done()

  • 写回答

3条回答 默认 最新

  • 溪风沐雪 2022-06-24 10:43
    关注

    意思是要在上边这张图上的脸上按第二章图的位置加一些斑点吗

    img

    from turtle import *
    
    #大致外观
    setup(600,600)
    pensize(3)
    speed(20)
    color('black','yellow')
    penup()
    goto(-120,120)
    pendown()
    begin_fill()
    seth(-45) #Turtle中的turtle.seth(angle)函数表示小乌龟启动时运动的方向
    for i in range(0,4):
        for i in range(0,5):
            circle(15,90)
            circle(-15,90)
        right(90)
    end_fill()
    
    #斑点左上1
    pensize(1)
    color("#959405")
    penup()
    goto(-100,80)
    pendown()
    begin_fill()
    circle(10)
    end_fill()
    #斑点左上2
    penup()
    goto(-100,50)
    pendown()
    begin_fill()
    circle(7)
    end_fill()
    #斑点右上1
    penup()
    goto(60,80)
    pendown()
    begin_fill()
    circle(10)
    end_fill()
    #斑点左下1、2
    penup()
    goto(-105,-43)
    pendown()
    begin_fill()
    circle(10)
    end_fill()
    penup()
    goto(-90,-70)
    pendown()
    begin_fill()
    circle(7)
    end_fill()
    #斑点右下1、2
    penup()
    goto(60,-40)
    pendown()
    begin_fill()
    circle(7)
    end_fill()
    penup()
    goto(50,-70)
    pendown()
    begin_fill()
    circle(10)
    end_fill()
    
    #眼睛
    pensize(1)
    color('black','white')
    penup()
    goto(-70,30)
    pendown()
    begin_fill()
    circle(30)
    end_fill()
    
    #1眼睛
    color('white','blue')
    penup()
    goto(-40,43)
    pendown()
    begin_fill()
    circle(10)
    end_fill()
    
    #2眼睛
    color('white','black')
    penup()
    goto(-35,46)
    pendown()
    begin_fill()
    circle(5)
    end_fill()
    
    #左眉毛1
    pensize(3)
    color('black')
    penup()
    goto(-68,82)
    pendown()
    fd(6)
    
    #左眉毛2
    pensize(3)
    color('black')
    penup()
    goto(-50,88)
    pendown()
    right(45)
    fd(6)
    
    #左眉毛3
    pensize(3)
    color('black')
    penup()
    goto(-30,82)
    pendown()
    right(30)
    fd(6)
    
    #右眼睛
    pensize(1)
    color('black','white')
    penup()
    goto(3,67)
    pendown()
    begin_fill()
    circle(30)
    end_fill()
    
    #右1眼睛
    color('white','blue')
    penup()
    goto(3,56)
    pendown()
    begin_fill()
    circle(10)
    end_fill()
    
    #右2眼睛
    color('white','black')
    penup()
    goto(7,54)
    pendown()
    begin_fill()
    circle(5)
    end_fill()
    
    #右眉毛1
    pensize(3)
    color('black')
    penup()
    goto(10,82)
    pendown()
    left(50)
    fd(6)
    
    #右眉毛2
    pensize(3)
    color('black')
    penup()
    goto(30,88)
    pendown()
    right(20)
    fd(6)
    
    #右眉毛3
    pensize(3)
    color('black')
    penup()
    goto(50,82)
    pendown()
    right(15)
    fd(6)
    
    #嘴巴
    pensize(1)
    color('black','IndianRed3')
    penup()
    goto(-86,-20)
    pendown()
    left(65)
    begin_fill()
    right(33)
    circle(70,150)
    
    fd(10)
    left(130)
    circle(-184,45)
    end_fill()
    
    #舌头
    color('black', 'orange red')
    penup()
    goto(-66,-50)
    pendown()
    right(130)
    circle(-140,46)
    
    #鼻子
    penup()
    goto(-15,10)
    pendown()
    fd(40)
    circle(5,180)
    fd(40)
    
    #裤子
    color('black','white')
    penup()
    goto(-123,-85)
    pendown()
    begin_fill()
    left(100)
    fd(20)
    
    left(93)
    fd(225)
    
    left(95)
    fd(20)
    
    left(85)
    fd(225)
    end_fill()
    
    #二层裤子
    color('black','orange4')
    penup()
    goto(-123,-106)
    pendown()
    begin_fill()
    left(90)
    fd(30)
    left(90)
    fd(225)
    left(90)
    fd(30)
    left(90)
    fd(225)
    end_fill()
    
    #裤缝
    color('black')
    pensize(8)
    for i in range(0,4):
        penup()
        goto(-83+(i*60),-120)
        pendown()
        fd(30)
    
    #裤腿1
    color('black','orange3')
    pensize(1)
    penup()
    goto(-63,-137)
    pendown()
    begin_fill()
    left(90)
    fd(10)
    left(30)
    circle(15,120)
    left(30)
    fd(10)
    left(90)
    fd(30)
    end_fill()
    
    #裤腿2
    color('black','orange3')
    pensize(1)
    penup()
    goto(23,-137)
    pendown()
    begin_fill()
    left(90)
    fd(10)
    left(30)
    circle(15,120)
    left(30)
    fd(10)
    left(90)
    fd(30)
    end_fill()
    
    #腿1
    color('black')
    penup()
    goto(-53,-155)
    pendown()
    left(90)
    fd(65)
    fd(30)
    left(90)
    fd(20)
    penup()
    goto(-43,-155)
    pendown()
    right(90)
    fd(60)
    circle(20,90)
    fillcolor('black')
    begin_fill()
    fd(5)
    circle(-7,180)
    fd(35)
    right(90)
    fd(24)
    end_fill()
    
    #腿2
    color('black')
    penup()
    goto(33,-152)
    pendown()
    right(180)
    fd(55)
    fd(30)
    left(90)
    fd(20)
    penup()
    goto(43,-152)
    pendown()
    right(90)
    fd(65)
    circle(20,90)
    fillcolor('black')
    begin_fill()
    circle(-7,180)
    fd(32)
    right(90)
    fd(22)
    end_fill()
    
    #左手
    color('black','yellow')
    penup()
    goto(-120,-10)
    pendown()
    begin_fill()
    left(45)
    fd(100)
    circle(-15,80)
    fd(5)
    circle(5,180)
    fd(20)
    #第2个手指
    right(150)
    fd(35)
    circle(5,180)
    fd(40)
    
    #第3个手指
    right(150)
    fd(30)
    circle(5,180)
    fd(30)
    
    #第4个手指
    right(140)
    fd(30)
    circle(5,180)
    fd(45)
    circle(15,90)
    
    right(40)
    right(70)
    fd(110)
    end_fill()
    
    #右手
    color('black','yellow')
    penup()
    goto(90,-10)
    pendown()
    begin_fill()
    left(90)
    fd(100)
    circle(-15,80)
    fd(5)
    circle(5,180)
    fd(20)
    #第2个手指
    right(150)
    fd(35)
    circle(5,180)
    fd(40)
    
    #第3个手指
    right(150)
    fd(30)
    circle(5,180)
    fd(30)
    
    #第4个手指
    right(140)
    fd(30)
    circle(5,180)
    fd(45)
    circle(15,90)
    
    right(40)
    right(70)
    fd(98)
    end_fill()
    
    penup()
    goto(-120,160)
    pendown()
    color("red")
    write("666", font=('Arial', 40, 'normal'))
    hideturtle()
    done()
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论 编辑记录
    1人已打赏
查看更多回答(2条)

报告相同问题?

问题事件

  • 系统已结题 7月2日
  • 已采纳回答 6月24日
  • 赞助了问题酬金5元 6月24日
  • 创建了问题 6月23日

悬赏问题

  • ¥15 mars2d在vue3中的引入问题
  • ¥50 h5唤醒支付宝并跳转至向小荷包转账界面
  • ¥15 算法题:数的划分,用记忆化DFS做WA求调
  • ¥15 chatglm-6b应用到django项目中,模型加载失败
  • ¥15 CreateBitmapFromWicBitmap内存释放问题。
  • ¥30 win c++ socket
  • ¥15 C# datagridview 栏位进度
  • ¥15 vue3页面el-table页面数据过多
  • ¥100 vue3中融入gRPC-web
  • ¥15 kali环境运行volatility分析android内存文件,缺profile