Janilabo

grid

Aug 17th, 2013
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 1.09 KB | None | 0 0
  1. {==============================================================================]
  2.   @action: Returns/builds grid of boxes with parameters;
  3.            startPoint = start point of the grid
  4.            boxWidth, boxHeight = dimensions of all boxes
  5.            rows, columns = count of rows and columns
  6.            rowSpace, columnSpace = the space between points at rows and columns
  7. [==============================================================================}
  8. function TBAGrid(startPoint: TPoint; boxWidth, boxHeight, rows, columns, rowSpace, columnSpace: Integer): TBoxArray;
  9. var
  10.   r, c: Integer;
  11. begin
  12.   if ((rows > -1) and (columns > -1) and (boxWidth > 0) and (boxHeight > 0) and ((rows * columns) > 0)) then
  13.   begin
  14.     SetLength(Result, (rows * columns));
  15.     for r := 0 to (rows - 1) do
  16.       for c := 0 to (columns - 1) do
  17.         Result[((r * columns) + c)] := IntToBox((startPoint.X + (c * columnSpace)), (startPoint.Y + (r * rowSpace)), ((startPoint.X + (c * columnSpace)) + (boxWidth - 1)), ((startPoint.Y + (r * rowSpace)) + (boxHeight - 1)));
  18.   end else
  19.     SetLength(Result, 0);
  20. end;
Advertisement
Add Comment
Please, Sign In to add comment