我是编程的初学者,我正试图从吉卜力电影中绘制龙猫,但身体无法正确填充。
这里是the drawing,我想用this colors做,但是我得到的是this is。这是我的代码:
from turtle import *
"""corps"""
import turtle
def corps():
speed("fast")
color('black'),width(2)
begin_fill()
up()
#right side down
goto(0,-200)
down()
right(90)
forward(4)
circle(5,90)
forward(70)
circle(130,90)
forward(140)
circle(50,20)
up()
#left side down
right(-160)
goto(0,-200)
down()
forward(4)
circle(-5,90)
forward(70)
circle(-130,90)
forward(140)
circle(-50,20)
up()
#right side up
right(70)
goto(205,-79)
down()
forward(5)
circle(20,70)
circle(100,10)
circle(500,10)
circle(200,30)
circle(3800,3)
right(33)
forward(30)
circle(100,23)
circle(5,115)
circle(200,15)
right(63)
forward(70)
up()
#left side up
goto(-205,-79)
down()
forward(5)
circle(-20,70)
circle(-100,10)
circle(-500,10)
circle(-200,30)
circle(-3800,3)
right(-33)
forward(30)
circle(-100,23)
circle(-5,115)
circle(-200,15)
right(-63)
forward(65)
turtle.fillcolor('#66615D')
end_fill()
up()
#belly
begin_fill()
turtle.fillcolor('#A99E82')
goto(0,-200)
down()
circle(200)
end_fill()
corps()
done()
这一定很难看,但是我才刚刚开始学习如何编码。
我不知道是否有一种有效的方法可以像数学之类的东西用乌龟画画,但是我是随机做的。
答案 0 :(得分:0)
@RogerAsbey在这一点上是正确的(+1):
如果您可以连续绘制轮廓线,它将填充 均匀地
因此,让我们重新编写代码来做到这一点。您仍然可以在不显眼的部分中考虑它,但只需确保其中一个流到下一个而不是跳来跳去:
from turtle import *
speed("fastest")
width(2)
color('#36302A', '#545049')
begin_fill()
up()
goto(0, -200)
right(90)
down()
# right side lower
forward(4)
circle(5, 90)
forward(70)
circle(130, 90)
forward(140)
circle(50, 20)
circle(50, -20)
backward(140)
right(90)
# right side upper
forward(5)
circle(20, 70)
circle(100, 10)
circle(500, 10)
circle(200, 30)
circle(3800, 3)
right(33)
forward(30)
circle(100, 23)
circle(5, 115)
circle(200, 15)
right(63)
forward(130)
# left side upper
right(63)
circle(200, 15)
circle(5, 115)
circle(100, 23)
forward(30)
right(33)
circle(3800, 3)
circle(200, 30)
circle(500, 10)
circle(100, 10)
circle(20, 70)
forward(5)
# left side lower
right(90)
backward(140)
circle(50, -20)
circle(50, 20)
forward(140)
circle(130, 90)
forward(70)
circle(5, 90)
forward(4)
goto(0, -200)
right(90)
end_fill()
# belly
fillcolor('#A99881')
begin_fill()
circle(200)
end_fill()
hideturtle()
done()