Advertisement
WarPie90

Dirty PartitionBox

Dec 14th, 2013
274
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 0.52 KB | None | 0 0
  1. function PartitionBox(B: TBox; Rows, Cols: Integer): TBoxArray;
  2. var
  3.   idx,x,y,BoxW,BoxH: Integer;
  4. begin
  5.   SetLength(Result, (Cols+1)*(Rows+1));
  6.   BoxW := (B.x2 - B.x1 + 1) div Cols;
  7.   BoxH := (B.y2 - B.y1 + 1) div Rows;
  8.   for y:=0 to Rows-1 do
  9.     for x:=0 to Cols-1 do
  10.     begin  
  11.       idx := (Y * Cols) + X;
  12.       Result[idx].x1 := B.x1 + (BoxW * x);
  13.       Result[idx].y1 := B.y1 + (BoxH * y);
  14.       Result[idx].x2 := B.x1 + (BoxW * x) + BoxW-1;
  15.       Result[idx].y2 := B.y1 + (BoxH * y) + BoxH-1;
  16.     end;
  17. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement