Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function PartitionBox(B: TBox; Rows, Cols: Integer): TBoxArray;
- var
- idx,x,y,BoxW,BoxH: Integer;
- begin
- SetLength(Result, (Cols+1)*(Rows+1));
- BoxW := (B.x2 - B.x1 + 1) div Cols;
- BoxH := (B.y2 - B.y1 + 1) div Rows;
- for y:=0 to Rows-1 do
- for x:=0 to Cols-1 do
- begin
- idx := (Y * Cols) + X;
- Result[idx].x1 := B.x1 + (BoxW * x);
- Result[idx].y1 := B.y1 + (BoxH * y);
- Result[idx].x2 := B.x1 + (BoxW * x) + BoxW-1;
- Result[idx].y2 := B.y1 + (BoxH * y) + BoxH-1;
- end;
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement