Split Square Into Smaller Squares
#2

You basically just have to split the rectangle/square into X parts, take that length and multiply it by X + the base coords to get the Xth square coordinates.

eg.

To split a 100.0, 100.0 sqaure into 10 squares you need to divide the coords by 10, which results in 10.0, 10.0.
To get the 5th square on the X axis you would do 5x 10.0 to get the minX value, add 10.0 to get maxX for that square.

That would result in the coords 50.0, 0.0, 60.0, 10.0 (minX, maxX, minY, maxY).

Код:
splitsquares(Float:sizeX = 100.0, Float:sizeY = 100.0, num = 5)
{
new Float:offsetX = sizeX / num, Float:offsetY = sizeY / num;

for(new x = 0; x < num; x ++) for(new y = 0; y < num; y ++)
{
new Float:minX = x * offsetX, Float:maxX = minX + sizeX;
new Float:minY = y * offsetY, Float:maxY = minY + sizeY;

// Do stuff with minX, maxX, minY, maxY...
}
}
Reply


Messages In This Thread
Split Square Into Smaller Squares - by Redirect Left - 02.02.2018, 23:51
Re: Split Square Into Smaller Squares - by NaS - 02.02.2018, 23:59
Re: Split Square Into Smaller Squares - by Marricio - 03.02.2018, 00:17
Re: Split Square Into Smaller Squares - by NaS - 03.02.2018, 00:19
Re: Split Square Into Smaller Squares - by Marricio - 03.02.2018, 00:20
Re: Split Square Into Smaller Squares - by NaS - 03.02.2018, 00:28
Re: Split Square Into Smaller Squares - by Redirect Left - 03.02.2018, 16:58
Re: Split Square Into Smaller Squares - by NaS - 03.02.2018, 17:26

Forum Jump:


Users browsing this thread: 2 Guest(s)