如何知道c#中矩形的中心 [英] how to know center of rectangle in c#

查看:208
本文介绍了如何知道c#中矩形的中心的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何知道矩形的中心?

推荐答案

如果你已经通过谷歌搜索矩形C#的中心试了一下,你可能没有问过任何一个你自己的答案。但似乎新一代开发人员甚至不想进行简单的搜索。 Anway!



查看这篇文章



查找矩形中心的扩展方法 [ ^ ]
If you have had given a try by googling center of rectangle C#, you probably got answer yourself without asking any one. But it seems that new generation developers don't even want to do a simple search. Anway!

Check this article

Extension methods for finding centers of a rectangle[^]


独立于编程语言,这是简单的数学:矩形的中心位于其左上角和右下角的一半



Independently from the programming language, that's simple math: the center of the rectangle is halfway its top-left and bottom-right points

xc = (xtl + xbr) / 2; 
yc = (xtl + xbr) / 2; 





或者如果你有矩形宽度和高度,



or if you have the rectangle width and heigh,

xc = xtl + w / 2;
yc = ytl + h / 2;


这篇关于如何知道c#中矩形的中心的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆