您能帮我用乌龟图形绘制房屋吗?
我不明白如何用乌龟正确地在Python画房子。我已经尝试了几种方法,但是房子总是有不正确的线路,而其他地方的线路。您可以用门和窗户帮助和画小房子吗?我有有关此图纸的考试。
# veido majas pirmo stavu
k.fillcolor('cyan')
k.begin_fill()
k.right(90)
k.forward(250)
k.left(90)
k.forward(400)
k.left(90)
k.forward(250)
k.left(90)
k.forward(400)
k.right(90)
k.end_fill()
# veido majas jumtu
k.fillcolor('brown')
k.begin_fill()
k.right(45)
k.forward(200)
k.right(90)
k.forward(200)
k.left(180)
k.forward(200)
k.right(135)
k.forward(259)
k.right(90)
k.forward(142)
k.end_fill()
# for door and
# windows
y.right(90)
y.forward(400)
y.left(90)
y.forward(50)
y.left(90)
y.forward(150)
y.right(90)
y.forward(200)
y.right(90)
y.forward(150)
y.right(90)
y.forward(100)
y.right(90)
y.forward(150)
y.right(90)
y.forward(100)
y.right(90)
y.forward(75)
y.right(90)
y.forward(200)
y.right(180)
y.forward(200)
y.right(90)
y.forward(75)
y.left(90)
y.forward(15)
y.left(90)
y.forward(200)
y.right(90)
y.forward(15)
y.right(90)
y.forward(75)
I can not understand how to properly draw a house in python with turtle. I've tried several ways, but house is always with incorrect lines that are going somewhere else. Can you help and draw little house with doors and and window? I have exam about this drawing.
# veido majas pirmo stavu
k.fillcolor('cyan')
k.begin_fill()
k.right(90)
k.forward(250)
k.left(90)
k.forward(400)
k.left(90)
k.forward(250)
k.left(90)
k.forward(400)
k.right(90)
k.end_fill()
# veido majas jumtu
k.fillcolor('brown')
k.begin_fill()
k.right(45)
k.forward(200)
k.right(90)
k.forward(200)
k.left(180)
k.forward(200)
k.right(135)
k.forward(259)
k.right(90)
k.forward(142)
k.end_fill()
# for door and
# windows
y.right(90)
y.forward(400)
y.left(90)
y.forward(50)
y.left(90)
y.forward(150)
y.right(90)
y.forward(200)
y.right(90)
y.forward(150)
y.right(90)
y.forward(100)
y.right(90)
y.forward(150)
y.right(90)
y.forward(100)
y.right(90)
y.forward(75)
y.right(90)
y.forward(200)
y.right(180)
y.forward(200)
y.right(90)
y.forward(75)
y.left(90)
y.forward(15)
y.left(90)
y.forward(200)
y.right(90)
y.forward(15)
y.right(90)
y.forward(75)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
实际上,房子由三角形和一个广场组成。因此,只需谷歌搜索或堆叠如何与乌龟绘制正方形和三角形,然后尝试将它们链接在一起(2个形状)。希望这有帮助!如果没有,请阅读文档( https://docs.pypython.org/3/library3/library 3/library /turtle.html )学习如何正确移动乌龟。在绘制任何内容之前,请尝试想象房屋的形状(左,右或可能是45度的位置),并弄清楚您希望每一侧的时间多长。
注意:最好不要从Internet复制任何代码,尽力而为并使用文档自己绘制它。这样,您就可以提高乌龟绘画技巧和抽象的想象力:)
Actually, the house consists of a triangle and a square. So just google it or stackoverflow it how to draw square and triangle with the turtle, and then try to link them (2 shapes) together. Hope this helps! If not, read the documentation (https://docs.python.org/3/library/turtle.html) and learn how to properly move a turtle. Before drawing anything, try to imagine the house shapes (where to turn left, right or maybe 45 degrees) and figure how long you want each side to be.
Note: It is better to not copy any code from the Internet, do your best and draw it by yourself using the documentation. This way you'll improve your turtle drawing skills and abstract imagination :)
这应该给你一个完美的房子!太可爱了!
This should give u the perfect house! so cute!
我想您对Pyhton并不熟悉,我即时制作了一个小程序,可以为您做到这一点,您可以尝试修改它并研究龟文档以使其能够完成您想要的事情,同时它具有很好的开始点:)
I guess you are not very familiar with pyhton, I made a little program on the fly that does just that for you, you can try to modify it and study the turtle documentation to make it do what you want, meanwhile it has a good starting point :)
尝试一下。
Try this.