Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {==============================================================================]
- @action: Keeps only corner points in TPA.
- @note: None
- @contributors: Janilabo, slacky
- [==============================================================================}
- procedure TPACorners(var TPA: TPointArray); callconv
- var
- x, y, h, r, i: Integer;
- C: T2DIntegerArray;
- bx: TBox;
- up, down, left, right, topLeft, topRight, bottomLeft, bottomRight: Boolean;
- begin;
- h := High(TPA);
- if (h > 0) then
- begin
- r := 0;
- bx := TPABounds(TPA);
- BoxExpand(bx);
- CreateATIA(0, ((bx.X2 - bx.X1) + 1), ((bx.Y2 - bx.Y1) + 1), C);
- for i := 0 to h do
- Inc(C[(TPA[i].X - bx.X1)][(TPA[i].Y - bx.Y1)]);
- for y := 0 to (bx.Y2 - bx.Y1) do
- for x := 0 to (bx.X2 - bx.X1) do
- if (C[x][y] > 0) then
- begin
- topLeft := (C[(x - 1)][(y - 1)] > 0);
- up := (C[x][(y - 1)] > 0);
- topRight := (c[(x + 1)][(y - 1)] > 0);
- left := (c[(x - 1)][y] > 0);
- right := (c[(x + 1)][y] > 0);
- bottomLeft := (c[(x - 1)][(y + 1)] > 0);
- down := (c[x][(y + 1)] > 0);
- bottomRight := (c[(x + 1)][(y + 1)] > 0);
- if not ((topLeft and bottomRight) or (up and down) or (topRight and bottomLeft) or (left and right)) then
- begin
- for i := 0 to (C[x][y] - 1) do
- TPA[(r + i)] := Point((x + bx.X1), (y + bx.Y1));
- r := (r + C[x][y]);
- end;
- end;
- SetLength(TPA, r);
- end;
- end;
Advertisement
Add Comment
Please, Sign In to add comment