[英]I am trying to create a rectangle with width = 100 and length = 50 using graphic.py library. I am a bit confused on how to specify the length
I am trying to create a rectangle with width = 100 and length = 50 using graphics.py
library.我正在尝试使用
graphics.py
库创建一个宽度 = 100 和长度 = 50 的矩形。 I am a bit confused on how to specify the length.我对如何指定长度有点困惑。 Here's what I have so far:
这是我到目前为止所拥有的:
main ():
win = GraphWin("window", 300, 300)
rec = Rectangle (Point (250,250), Point(200, 200))
rec.setWidth (50)
rec.draw(win)
In short, read the documentation .简而言之,阅读文档。
SetWidth
changes the line thickness, not the rectangle size. SetWidth
更改线条粗细,而不是矩形大小。
The rectangle dimensions are entirely determined by the two opposing corners you specify when you instantiate the object.矩形尺寸完全由实例化对象时指定的两个对角决定。 I'll change your values to illustrate:
我会改变你的价值观来说明:
rec = Rectangle (Point(300, 200), Point(100, 50))
This defines a rectangle with opposite corners at the given points.这定义了在给定点处具有对角的矩形。
The width (x direction) is abs(300-100) = 200宽度(x方向)为 abs(300-100) = 200
The height (y direction) is abs(200-50) = 150高度(y方向)为 abs(200-50) = 150
Does that clear up your confusion?这能解决你的困惑吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.