如何在Python中使用海龟制作水滴形状?

问题描述 投票:0回答:1

这是我的代码:

import turtle

t = turtle.Turtle()
t.width(5)

t.right(112.5)
t.forward(100)
t.circle(50, 225)
t.forward(100)
t.hideturtle()

它几乎形成了正确的形状,但顶部的两点没有互相相遇。

enter image description here

可能圆的半径不对,或者还有其他错误。请修复我的代码

python turtle-graphics
1个回答
1
投票

您需要从一开始就添加更多角度并调整圆圈以使其正确。

import turtle


t = turtle.Turtle()
t.width(5)


t.right(120)        
t.forward(150)      
t.circle(90, 240)   
t.forward(150)      
t.hideturtle()      

turtle.done()

水滴

© www.soinside.com 2019 - 2024. All rights reserved.