Wizzup?
2007-10-28 06:23:38
Thanks to lorax for some good ol' mathematical help. :)
This get's all the points of the color you put in, in a area defined by StartD and EndD, it works just like the normal RadialWalk, Starts from StartD. (The SortTPAFrom)
You can do alot with SortTPAFrom, Sort from start, end, middle of the two degrees, or a different degree you put in.
~ Wizzup?
EDIT2:
New code.
This get's all the points of the color you put in, in a area defined by StartD and EndD, it works just like the normal RadialWalk, Starts from StartD. (The SortTPAFrom)
You can do alot with SortTPAFrom, Sort from start, end, middle of the two degrees, or a different degree you put in.
program New;
{.include SRL/SRL.scar}
Function DebugTPA(Points: TPointArray; BmpName: String): Boolean;
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;
DisplayDebugImgWindow(0, 0);
DisplayDebugImgWindow(Width, Height);
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, 255);
If BmpName <> '' Then
SaveBitmap(ClientBMP, ScriptPath + BmpName + '.bmp');
SafeDrawBitmap(ClientBMP, GetDebugCanvas, 0, 0);
DisplayDebugImgWindow(Width, Height);
FreeBitmap(ClientBMP);
End
Except
FreeBitmap(ClientBMP);
End;
Result := True;
End;
Function InDegreeEx(x, y, mx, my, sd, ed: Integer; minr, maxr: Extended): Boolean;
Var
xDeg, d: Extended;
Begin
sd := sd Mod 360;
ed := ed Mod 360;
xDeg := Degrees(ArcTan2(y - my, x - mx)) + 90;
If xDeg < 0 Then
xDeg := 90 - (xDeg * -1) + 270;
Result := ( (xDeg > sd) And (xDeg < ed) );
If Result Then
Begin
d := Sqrt(Sqr(x - mx) + Sqr(y - my));
Result := ( (d > minr) And (d < maxr) );
End;
End;
Procedure GetRadialPoints(Var Points: TPointArray; Color, Tol, startD, endD, MinRadius, MaxRadius: Integer);
Var
Time, I, C: Integer;
Temp: TPointArray;
S: Boolean;
Begin
Time := GetSystemTime;
FindColorsTolerance(Temp, Color, MMX1, MMY1, MMX2, MMY2, Tol);
startD := startD Mod 360;
endD := endD Mod 360;
SetLength(Points, Length(Temp));
C := 0;
If StartD > EndD Then
Begin;
S := True;
Swap(startD, endD);
End;
For I := 0 To High(Temp) Do
If InDegreeEx(Temp[I].X, Temp[I].Y, MMCX, MMCY, startD, endD, MinRadius, MaxRadius) Then
Begin
Points[C] := Temp[I];
C := C + 1;
End;
SetLength(Points, C);
SetLength(Temp, 0);
If S Then
Swap(startD, endD);
DebugTPA(Points, '');
End;
Var
P: TpointArray;
begin
SetupSRL;
GetRadialPoints(P, 6386555, 0, 250, 0, 0, 30);
end.~ Wizzup?
EDIT2:
New code.