Python。学习海龟图形
Python. Learning turtle graphics
我想用乌龟画这幅画。
这是我在 atm 上收到的:
import turtle
def animal():
turtle.speed(1)
turtle.pencolor('black')
turtle.up()
turtle.goto(-180, -180)
turtle.down()
turtle.lt(180)
turtle.circle(-200, 180)
turtle.lt(90)
turtle.circle(50, 220)
turtle.done()
所以问题是画完body半圆后怎么画老鼠耳朵。因为在我的代码中鼠标耳朵与 body 相交。在不猜测正确坐标并且在 return 之后到 ear 开始的地方有什么好方法吗?
any good way to do it without guessing correct coordinates and after
return to the point where was ear started
此代码应该完成您要求的两件事:1) 画出耳朵而不必知道在哪里停止; 2) return 耳朵开始画的地方:
import turtle
def animal():
turtle.up()
turtle.goto(-180, 180)
turtle.lt(90)
turtle.down()
turtle.fillcolor('gray45')
turtle.begin_fill()
turtle.circle(75)
turtle.end_fill()
turtle.lt(90)
turtle.fillcolor('white')
turtle.begin_fill()
turtle.circle(170, 180)
turtle.end_fill()
turtle.circle(170, -180)
animal()
turtle.done()
我想用乌龟画这幅画。
这是我在 atm 上收到的:
import turtle
def animal():
turtle.speed(1)
turtle.pencolor('black')
turtle.up()
turtle.goto(-180, -180)
turtle.down()
turtle.lt(180)
turtle.circle(-200, 180)
turtle.lt(90)
turtle.circle(50, 220)
turtle.done()
所以问题是画完body半圆后怎么画老鼠耳朵。因为在我的代码中鼠标耳朵与 body 相交。在不猜测正确坐标并且在 return 之后到 ear 开始的地方有什么好方法吗?
any good way to do it without guessing correct coordinates and after return to the point where was ear started
此代码应该完成您要求的两件事:1) 画出耳朵而不必知道在哪里停止; 2) return 耳朵开始画的地方:
import turtle
def animal():
turtle.up()
turtle.goto(-180, 180)
turtle.lt(90)
turtle.down()
turtle.fillcolor('gray45')
turtle.begin_fill()
turtle.circle(75)
turtle.end_fill()
turtle.lt(90)
turtle.fillcolor('white')
turtle.begin_fill()
turtle.circle(170, 180)
turtle.end_fill()
turtle.circle(170, -180)
animal()
turtle.done()