简体   繁体   English

如何调整此乌龟图形绘图以画出一个圆?

[英]how do i adjust this turtle graphics drawing to draw around a circle?

with the current code, this is the result . 使用当前代码, 这就是结果

but I'm trying to get it to look like this , but not sure what to tweak. 但我试图使它看起来像这样 ,但不确定要进行哪些调整。

#circle circle 

import turtle

turtle.colormode(255)

window=turtle.Screen()

draw=turtle.Turtle()
draw.pensize(2)
window.screensize(1200,1200)
draw.speed('fastest')
red, green, blue= 255, 255, 0


for shape in range(30):
    for circle in range(1):
        draw.circle(200)
    draw.penup()
    draw.forward(30)
    draw.pendown()
    draw.left(20)   
    green=green-5
    blue=blue+6
    draw.color(red, green, blue)

window.mainloop()

If you notice your two images, the one you want has the circles drawn outside the center, while the wrong one draws them around the center. 如果您注意到了两张图像,则您想要的一幅图像的圆在中心之外绘制,而错误的一幅圆则在中心附近绘制。 Try changing draw.left(20) to draw.right(20) and adjust your values from there to get the sizes you want. 尝试将draw.left(20)更改为draw.right(20)然后从此处调整值以获得所需的大小。

The change keeps the turtle outside of the circle just drawn, which is what you're looking for. 所做的更改使乌龟保持在刚刚绘制的圆之外,这正是您要寻找的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM