n3ss3s
2008-09-29 12:44:01
{*******************************************************************************
Procedure AdjustAccordingly(Color1, Color2: Integer);
By: n3ss3s
Description: Adjusts your CTS 2 mods (if the mode is 2) to fit the difference
between the two colors.
*******************************************************************************}
Procedure AdjustAccordingly(Color1, Color2, LumTol: Integer);
Var
HSL: Array of Array [0..2] of Extended;
Begin
If GetColorToleranceSpeed <> 2 Then
srl_Warn('AdjustAccordingly', 'CTS <> 2', 0)
Else
Begin
SetArrayLength(HSL, 3);
ColorToHSL(Color1, HSL[0][0], HSL[0][1], HSL[0][2]);
ColorToHSL(Color2, HSL[1][0], HSL[1][1], HSL[1][2]);
HSL[2][0] := Abs(HSL[0][0] - HSL[1][0]);
HSL[2][1] := Abs(HSL[0][1] - HSL[1][1]);
HSL[2][2] := Abs(HSL[0][2] - HSL[1][2]);
SetColorSpeed2Modifiers((HSL[2][0] + 0.0001) / LumTol, (HSL[2][1] + 0.0001 / LumTol);
End;
End;
I'll make some more if I feel like that.
Rock finder…
Function FindRocks(Color, Tol: Integer; tol_H, tol_S: Extended): TPointArray;
Var
TPA: TPointArray;
L, C, I: Integer;
B: TBox;
TPAA: T2DPointArray;
Begin
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(tol_H, tol_S);
FindColorsTolerance(TPA, Color, MSX1, MSY1, MSX2, MSY2, tol);
SetColorSpeed2Modifiers(0.2, 0.2);
TPAA := TPAToATPAEx(TPA, 30, 30);
L := High(TPAA);
SetArrayLength(Result, L + 1);
For I := 0 To L Do
If Length(TPAA[i]) < 65 Then
If Length(TPAA[i]) > 10 Then
Begin
B := GetTPABounds(TPAA[i]);
Try
If (Length(TPAA[i]) + 0.001) / ((B.x2 - B.x1) * (B.y2 - B.y1)) < 0.5 Then
Begin
Result[c] := Point((B.x2 + B.x1) shr 1, (B.y2 + B.y1) shr 1);
C := C + 1;
End;
Except End;
End;
SetArrayLength(Result, C);
ColorToleranceSpeed(1);
End;
Tree finder
Function TreePoints: T2DPointArray;
Var
S, I: Integer;
TPA, Other: TPointArray;
TPAA: T2DPointArray;
B: TBox;
Begin
S := GetSystemTime;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.15, 4.0);
FindColorsTolerance(TPA, 5079157, MSX1, MSY1, MSX2, MSY2, 20);
TPAA := SplitTPA(TPA, 3);
SortATPASize(TPAA, True);
For I := 0 To High(TPAA) Do
If GetArrayLength(TPAA[i]) < 25 Then
Begin
SetArrayLength(TPAA, i);
Break;
End;
SetColorSpeed2Modifiers(0.15, 4.0);
For I := 0 To High(TPAA) Do
Begin
B := GetTPABounds(TPAA[i]);
TPA := TPAA[i];
FindColorsTolerance(Other, 198920, B.x1, B.y1, B.x2, B.y2, 20);
TPAA[i] := CombineTPA(Other, TPA);
End;
Result := TPAA;
SetColorSpeed2Modifiers(0.2, 0.2);
ColorToleranceSpeed(1);
Writeln('Took: ' + IntToStr(GetSystemTime - S));
End;
