如何填充较小的垂直和放大的大矩形?水平矩形 [英] How do I can fill a large rectangle with smaller Vertical & Horizontal rectangles

查看:142
本文介绍了如何填充较小的垂直和放大的大矩形?水平矩形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请尽快帮助我。


推荐答案

嗯,你决定了多少你想要在大矩形内的行和列,然后使用两个循环来计算每个子矩形的位置和大小。



例如3行3列= 9个小矩形。

Well, you decide how many rows and columns you want inside the big rectangle, then use two loops to calculate the position and size of each sub-rectangle.

For example 3 rows and 3 columns = 9 small rectangles.
int numberOfRows = 3;
int numberOfCols = 3;
int width = (int)(largRect.Width / 3);
int height = (int)(largRect.Height / 3);
for (int row = 0; row < numberOfRows; row++)
{
    for (int col = 0; col < numberOfCols; col++)
    {
        Point location = new Point(col*width, row*height);
        // The rest of the code is for you to write
    }
}





这只是一种方法。如果你需要一个更精确的答案,你需要指定你想要做什么。



This is just one way of doing it. If you need a more exact answer you need to specify what you want to do.


我只想要一个解决方案,比如覆盖带有矩形的多边形
I just want a solution like Covering a Polygon with Rectangles


这篇关于如何填充较小的垂直和放大的大矩形?水平矩形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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