diff --git a/Units/MMLAddon/PSInc/psexportedmethods.inc b/Units/MMLAddon/PSInc/psexportedmethods.inc index fa52ce1..8734507 100644 --- a/Units/MMLAddon/PSInc/psexportedmethods.inc +++ b/Units/MMLAddon/PSInc/psexportedmethods.inc @@ -176,3 +176,6 @@ AddFunction(@CreateBitmapMask,'function CreateBitmapMask(Bitmap : integer) : TMa AddFunction(@FindMaskTolerance,'function FindMaskTolerance(mask: TMask; out x, y: Integer; xs,ys, xe, ye: Integer; Tolerance, ContourTolerance: Integer): Boolean;'); AddFunction(@FindBitmapMaskTolerance,'function FindBitmapMaskTolerance(mask: Integer; out x, y: Integer; xs, ys, xe, ye: Integer; Tolerance, ContourTolerance: Integer): Boolean;'); AddFunction(@FindDeformedBitmapToleranceIn,'function FindDeformedBitmapToleranceIn(bitmap: integer; out x,y: Integer; xs, ys, xe, ye: Integer; tolerance: Integer; Range: Integer; AllowPartialAccuracy: Boolean; out accuracy: Extended): Boolean;'); + +{tpa} +AddFunction(@SplitTPAEx,'function SplitTPAEx(arr: TPointArray; w, h: Integer): T2DPointArray;'); diff --git a/Units/MMLAddon/mmlpsthread.pas b/Units/MMLAddon/mmlpsthread.pas index 1c78a7c..597e03c 100644 --- a/Units/MMLAddon/mmlpsthread.pas +++ b/Units/MMLAddon/mmlpsthread.pas @@ -110,6 +110,7 @@ uses strutils, colour_conv, input, + tpa, //Tpa stuff forms,//Forms lclintf; // for GetTickCount and others. diff --git a/Units/MMLAddon/tpa.pas b/Units/MMLAddon/tpa.pas new file mode 100644 index 0000000..f0a6726 --- /dev/null +++ b/Units/MMLAddon/tpa.pas @@ -0,0 +1,79 @@ +{ + This file is part of the Mufasa Macro Library (MML) + Copyright (c) 2009 by Raymond van Venetiƫ and Merlijn Wajer + + MML is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + MML is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with MML. If not, see . + + See the file COPYING, included in this distribution, + for details about the copyright. + + TPA functions for the Mufasa Macro Library +} +unit tpa; + +{$mode objfpc}{$H+} + +interface + +uses + Classes, SysUtils, mufasatypes; +function SplitTPAEx(arr: TPointArray; w, h: Integer): T2DPointArray; + +implementation + + +function SplitTPAEx(arr: TPointArray; w, h: Integer): T2DPointArray; +var + t1, t2, c, ec, tc, l: Integer; + tpa: TPointArray; +begin + tpa := Copy(arr); + l := High(tpa); + if (l < 0) then Exit; + SetLength(Result, l + 1); + c := 0; + ec := 0; + while ((l - ec) >= 0) do + begin + SetLength(Result[c], 1); + Result[c][0] := tpa[0]; + tpa[0] := tpa[l - ec]; + Inc(ec); + tc := 1; + t1 := 0; + while (t1 < tc) do + begin + t2 := 0; + while (t2 <= (l - ec)) do + begin + if (Abs(Result[c][t1].x - tpa[t2].x) <= w) and (Abs(Result[c][t1].y - tpa[t2].y) <= h) then + begin + SetLength(Result[c], tc +1); + Result[c][tc] := tpa[t2]; + tpa[t2] := tpa[l - ec]; + Inc(ec); + Inc(tc); + Dec(t2); + end; + Inc(t2); + end; + Inc(t1); + end; + Inc(c); + end; + SetLength(Result, c); +end; + +end. +