n3ss3s
2007-12-21 09:43:20
yeah, it kind of doesn't find the closest one, but hey, propably faster than doing FindColorsTolerance for all the colors of the subpoints and mainpoint, then going through them, but, it gets about the closest :p
Though I doubt it works, but ya'll get the idea.
DAMN LEECHERS! :p 37 views 0 posts!
Guess you're all just speechless then :p Jk/Jk
Though I doubt it works, but ya'll get the idea.
Function InitTPABmp(Points: TPointArray): Integer;
// Thanks Wizzy, 99% based on your DebugTPA
Var
Width, Height, ClientBMP, I: Integer;
xs, ys, xe, ye: Integer;
Begin
Try
Begin
xe := xs xor xs;
ye := ys xor ys;
xs := 1 shl 20;
ys := 1 shl 20;
For I := 0 To High(Points) Do
Begin
xs := Min(xs, Points[i].X);
ys := Min(ys, Points[i].Y);
xe := Max(xe, Points[i].X);
ye := Max(ye, Points[i].Y);
End;
Width := xe - xs;
Height := ye - ys;
ClientBMP := BitmapFromString(Width, Height, '');
CopyClientToBitmap(ClientBMP, xs, ys, xe, ye);
For I := 0 To High(Points) Do
FastSetPixel(ClientBMP, Points[i].X - xs, Points[i].Y - ys, GetColor(Points[i].X, Points[i].Y));
Result := ClientBMP;
FreeBitmap(ClientBMP);
End
Except
FreeBitmap(ClientBMP);
End;
End;
Function FindDTMSpiral(Var X, Y: Integer; Cx, Cy, X1, Y1, X2, Y2: Integer; DTM: TDTM): Boolean;
Var
Dx, Dy, D, CH, bmp, DeTM, Fx, Fy, Fx2, Fy2, I, W, H: Integer;
tmp, TPA: TPointArray;
Dists: TIntegerArray;
Begin
SetArrayLength(Dists, GetArrayLength(DTM.SubPoints));
For I := 0 To High(DTM.SubPoints) Do
Begin
Dx := DTM.SubPoints[i].x;
Dy := DTM.SubPoints[i].y;
Dists[i] := Distance(DTM.MainPoint.x, DTM.MainPoint.y, Dx, Dy);
FindColorsTolerance(tmp, DTM.SubPoints[i].Color, x1, y1, x2, y2, 0);
TPA := CombineTPA(TPA, tmp);
End;
FindColorsTolerance(tmp, DTM.MainPoint.Color, x1, y1, x2, y2, 0);
TPA := CombineTPA(TPA, tmp);
D := AMax(Dists);
CH := GetClientWindowHandle;
bmp := BitmapFromString(0, 0, '');
Try
bmp := InitTPABmp(TPA);
CH := GetClientWindowHandle;
SetTargetBitmap(bmp);
GetBitmapSize(bmp, W, H);
DeTM := AddDTM(DTM);
FX := CX;
FY := CY;
FX2 := CX;
FY2 := CX;
While IntInBox(Fx, Fy, IntToBox(0, 0, W, H)) Do
Begin
If DTMRotated(DeTM, X, Y, Fx, Fy, Fx2, Fy2) Then
Result := True
Else
Begin
Fx := Fx - D;
Fy := Fy - D;
Fx2 := Fx2 + D;
Fy2 := Fy2 + D;
End;
If Result Then
Break;
End;
Except
SetClientWindowHandle(CH);
End;
SetClientWindowHandle(CH);
End;DAMN LEECHERS! :p 37 views 0 posts!
Guess you're all just speechless then :p Jk/Jk