【问题标题】:Python. Learning turtle graphicsPython。学习海龟图形
【发布时间】:2018-03-19 18:28:50
【问题描述】:

我想用海龟画这张图。

这是我的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()

所以问题是画完身体半圆后怎么画老鼠耳朵。因为在我的代码中,鼠标耳朵与身体相交。在不猜测正确坐标并返回到耳朵开始的点之后,有什么好方法吗?

【问题讨论】:

    标签: python python-3.x turtle-graphics


    【解决方案1】:

    在不猜测正确坐标和之后的任何好方法 回到耳朵开始的地方

    这段代码应该做你要求的两件事:1)画耳朵而不必知道在哪里停下来; 2)回到耳朵开始画的地方:

    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()
    

    【讨论】: