SRL Archive - SRL Snippets

MakeDTM


Kevin

2013-07-04 21:42:47

This is not mine. Like at all. This is @Kasi's. He is lazy, and as I was about to write this, he apparently already had it. Since he didn't know why it wasn't already public I'm putting this here for him :p


function MakeDTM(OutlineCol, Step : Integer; SearchBox : TBox) : Integer;
var
TPA : TPointArray;
MidPoint : TPoint;
I : Integer;
DTMPoints : TPointArray;
DTMPointsDef : Array of TDTMPointDef;
TempTDTM : TDTM;
begin
FindColors(TPA, OutlineCol, SearchBox.X1, SearchBox.Y1, SearchBox.X2, SearchBox.Y2);
if Length(TPA) = 0 then
exit;
MidPoint := MiddleTPA(TPA);

for I := 0 to High(TPA) do
begin
CombineTPAWrap(DTMPoints, [TPA[I]], DTMPoints);
I := I + Step;
if I > High(TPA) then
break;
end;

SMART_DrawDotsEx(false, TPA, 255);

SetLength(DTMPointsDef, Length(DTMPoints) + 1);
with DTMPointsDef[0] do
begin
x := MidPoint.x;
y := MidPoint.y;
AreaSize := 1;
Color := GetColor(MidPoint.x, MidPoint.y);
Tolerance := 20;
end;

for I := 1 to High(DTMPointsDef) do
with DTMPointsDef[I] do
begin
x := DTMPoints[I - 1].x;
y := DTMPoints[I - 1].y;
AreaSize := 1;
Color := OutlineCol;
Tolerance := 0;
end;
TempTDTM.MainPoint := DTMPointsDef[0];
SetLength(TempTDTM.SubPoints, High(DTMPointsDef));
for I := 1 to High(DTMPointsDef) do
TempTDTM.SubPoints[I - 1] := DTMPointsDef[I];
Result := AddDTM(TempTDTM);

Writeln('Made DTM Center Col - <B>' + IntToStr(DTMPointsDef[0].Color) + '</B>!');
end;

Kasi

2013-07-05 14:04:11

When did i give you this? cant even remember lol