简体   繁体   English

我正在尝试使用 graphics.py 库创建一个宽度 = 100 和长度 = 50 的矩形。 我对如何指定长度有点困惑

[英]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.

相关问题 我正在尝试使用python超库创建一个http2多客户端服务器。 它仅完成第一个请求 - I am trying to create an http2 multiclient server using python hyper library. It completes only the first request 我正在尝试使用 pytorch 库构建一个带有一个神经元的神经网络。 它一直给我一个错误 - I am trying to build a neural network with one neuron using the pytorch library. It keeps giving me an error 我试图在一个句子中找到最大长度的单词 - I am trying to find the maximum length word in a sentence 打字时如何检查字符串长度? - How to check string length while I am typing? 我对OOP中对象的行为有些困惑 - I am a bit confused about the behaviour of objects in OOP 我对创建一个循环有点困惑 - I am a little bit confused about creating kinda a loop 我对 super().__init__() 有点困惑 - I am a little bit confused by the super().__init__() 我正在尝试从 output 创建一个对称矩阵,而不使用 numpy 和其他库。 - I am trying to create a symmetric matrix from the output I got in python without using the numpy and additional library? 渲染我的 views.py“Django”时我很困惑 - I am confused while rendering my views.py "Django" 我对此感到非常困惑,正在尝试,但是我不认为自己得到了想要的东西 - I am very confused by this and am trying but I don't think I am getting what is wanted
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM