Cazax
2008-09-25 18:33:08
Herblore*
The function searches for grimy herbs.
Slots: The slots to search for herbs.
The result will be the slots with grimy herbs.
Uses HSL for the grimy detection.
Function GrimyOrNot(Slots : TIntegerArray): TIntegerArray;
Var
TPA : TPointArray;
Box : TBoxArray;
IntArr, C : TIntegerArray;
H, S, L : Extended;
I, K : Integer;
Begin
SetArrayLength(Box, 28);
SetArrayLength(Result, 0);
For I := 1 To 28 Do
If InIntArray(Slots, I) Then
Begin
Box[Length(Box) - 1] := InvBox(I);
End;
SetArrayLength(C, 28);
For I := 1 To 28 Do
Begin
If Not InIntArray(Slots, I) Then
Continue;
FindColorsTolerance(TPA, 2115160, Box[I].X1, Box[I].Y1, Box[I].X2, Box[I].Y2, 10);
If Length(TPA) = 0 Then
Continue;
IntArr := GetColors(TPA);
ClearSameIntegers(IntArr);
For K := 0 To High(IntArr) Do
Begin
ColorToHSL(IntArr[K], H, S, L);
If (Round(H) > 8) And (Round(H) < 14) Then
If (Round(S) > 45) And (Round(S) < 49) Then
If (Round(L) > 20) And (Round(L) < 26) Then
Inc(C[I]);
If C[I] > 10 Then //Default count.
Break;
End;
End;
For I := 1 To 28 Do
Begin
If Not InIntArray(Slots, I) Then
Continue;
If (C[I] > 10) Then
Begin
SetArrayLength(Result, Length(Result) + 1);
Result[Length(Result) - 1] := I;
End;
End;
End;The function searches for grimy herbs.
Slots: The slots to search for herbs.
The result will be the slots with grimy herbs.
Uses HSL for the grimy detection.