Advertisement
WarPie90

Untitled

Dec 26th, 2014
404
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 0.71 KB | None | 0 0
  1. function TPAContains(sub, main:TPointArray):Boolean;
  2. var
  3.   c,x,y,i,j,w,h:Int32;
  4.   Mat: T2DIntArray;
  5.   mB,sB:TBox;
  6. begin
  7.   mB := GetTPABounds(main);
  8.   W := mB.x2-mB.x1+1;
  9.   H := mB.y2-mB.y1+1;
  10.   SetLength(Mat, H,W);
  11.   for i:=0 to High(main) do
  12.     Mat[main[i].y-mB.y1, main[i].x-mB.x1] := 255;
  13.  
  14.   sB := GetTPABounds(sub);
  15.   OffsetTPA(sub, Point(-sB.x1, -sB.y1));
  16.   for y:=0 to H-1 do
  17.     for x:=0 to W-1 do
  18.     begin
  19.     c := 0;
  20.     for j:=0 to High(sub) do
  21.       if ((y+sub[j].y < H) and (x+sub[j].x < W)) and
  22.          (Mat[y+sub[j].y, x+sub[j].x] <> 0) then
  23.       begin
  24.         Inc(c);
  25.         Continue;
  26.       end else
  27.         Break;
  28.     if c = Length(sub) then
  29.       Exit(True);
  30.   end;
  31. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement