矩形位置 [英] Rectangle positions
问题描述
你好
关于图像上的矩形放置,我有一些数学问题。
背景:我是在个人项目中,放置的图像缩放到纸张的大小。在这种情况下,它的A3(420W x 297H)。
好的。我从Cad图纸中获取X,Y值,然后将它们输入到我的项目表单中。从我的例子来看,我有
x = 60
y = 225
我输入值和使用这些坐标在图像上出现一个矩形但是,我似乎无法正确地将数学放置得恰到好处。
矩形总是方形的,总是100,100。
Cad&纸绳从左下方开始,VB形式从左上角到矩形的角落。
几个问题:
- 是否有方法将矩形定位在其中心?
- 正确定位矩形的好方法是什么?它的工作方式与表单的坐标结构相反。
希望这个图像可能有所帮助。我知道它最有可能是一个非常简单的计算,但不管出于什么原因,我只是看不到它而且有点令人沮丧。
任何建议非常感谢:)
Nacho
纳乔是奈杰尔的衍生物 - 真实的事实!我是VB.Net的自学者。 50%的时间,我百分之百正确!
几个问题:
- 是否有方法将矩形定位在其中心?
- 正确定位矩形的好方法是什么?它的工作方式与表格的坐标结构相反。
要根据中心定位矩形,从中减去矩形宽度的一半; x偏移,并从y偏移减去矩形高度的一半。
要反转y轴,从窗口中减去y偏移(在调整中心之后)高度。
Hi There
I'm have a bit of math issue regarding rectangle placement on an image.
Background: I am on a personal project that has a placed image scaled to the size of Paper. In this case, its A3 (420W x 297H).
Ok. I get X,Y values from Cad drawings and I input them into my project form. From my example, I have
x = 60
y = 225
I input the values and a rectangle appears on the image using these coordinates however, I cannot seem to get the math right to position it correctly.
The rectangle is always square and is always 100,100.
Cad & Paper cords go from the bottom left, VB forms go from the top left to the corner of the rectangle.
Couple of questions:
- Is there a method to position a rectangle by its center?
- What would be a good solution to correctly position the rectangle? Its working opposite to the coordinate structure of a form.
Hopefully, this image might help somewhat. I know that its most likely to be a pretty simple calculation but for whatever reason, I just cant see it and its a little frustrating.
Any suggestions greatly appreciated :)
Nacho
Nacho is the derivative of Nigel - True fact! I am self taught in VB.Net. 50% of the time, I am right 100% of the time!
Couple of questions:
- Is there a method to position a rectangle by its center?
- What would be a good solution to correctly position the rectangle? Its working opposite to the coordinate structure of a form.
To position the rectangle based on the centre, subtract half the rectangle width from the x-offset, and subtract half the rectangle height from the y-offset.
To invert the y-axis, subtract the y-offset (after adjusting for the centre) from the window height.
这篇关于矩形位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!