I'm not explaining what XYZ means, I'll just show you how to use it in functions and its properties.
XYZ is the fourth color tolerance speed, to call it, you have to use the procedure ColorToleranceSpeed(3). Here is the order:
CTS 0(Color32) = Extremely fast, but not accurate at all.
CTS 1(RGB) = Fast, Accurate.
CTS 2(HSL) = More accurate than CTS1, but less faster.
CTS 3(XYZ) = Extremely accurate, not fast at all.
Note: about the fastness, the difference is not big, between 40 - 100 ms.
The more accurate a CTS is, the less tolerance you have to use.
example:
CTS 0 Tol = 20
CTS 1 Tol = 15
CTS 2 Tol = 10
CTS 3 Tol = 5
Now, I'll compare them(finding a tree):
CTS 0:
CTS 1:
CTS 2:
CTS 3:
So, CTS 3 was the most accurate picture.
Functions used with XYZ:
1:
SCAR Code:
Procedure ColorToleranceSpeed(3)
Calls XYZ. Default CTS is 1 (for setting it back).
2:
SCAR Code:
Procedure SetColorSpeed3Modifiers(Sensitivity : Integer)
Have you ever heard of SetColorSpeed2Modifiers? This does the same thing, but with other value. The higher a sensitivity is, the lower tolerance you should use. Default sensitivity is 4 (for setting it back).
An example:
SCAR Code:
Function FindRockPoints: TPointArray;
Begin
ColorToleranceSpeed(3);
SetColorSpeed3Modifiers(10);
FindColorsSpiralTolerance(MSCX, MSCY, Result, RockColor, MSX1, MSY1, MSX2, MSY2, 2);
SetColorSpeed3Modifiers(4);
ColorToleranceSpeed(1);
End;
Note: SetColorSpeed3Modifiers just influence the tolerance you need to input, nothing more. So it is your choose to use it, but I'll use it in the tutorial.
3:
SCAR Code:
Procedure ColorToXYZ(Color : TColor; Var X, Y, Z : Extended)
Gets the XYZ values of a color, mostly used in autocoloring(minimap). In autocoloring, you have to use these values to compare them other values, like I did in my last tutorial(my sig):
SCAR Code:
Function FindWaterColor: Integer;
Var
TPA : TPointArray;
I, H : Integer;
X, Y, Z, X2, Y2, Z2 : Extended;
TIA : TIntegerArray;
Begin
FindColorsSpiralTolerance(MSCX, MSCY, TPA, WaterColor, MMX1, MMY1, MMX2, MMY2);
ColorToXYZ(WaterColor, X, Y, Z);
If Length(TPA) = 0 Then
Exit;
H := High(TPA);
TIA := GetColors(TPA);
For I := 0 To H Do
Begin
ColorToXYZ(TIA[I], X2, Y2, Z2),
If ((X2 - X) < 4) And ((X2 - X) > 2) Then
If ((Y2 - Y) < 2) And ((Y2 - Y) > 0) Then
If ((Y2 - Y) < 5) And ((Y2 - Y) > 3) Then
Begin
Writeln('WaterColor = ' + IntToStr(TIA[I]);
Result := TIA[I];
Exit;
End;
End;
End;
You can use this while finding objects in the main screen, like ACA2 does with RGB and HSL.
4:
SCAR Code:
Function XYZToColor(X, Y, Z : Extended): Integer
Transforms XYZ values to a color.
These are all the functions related to XYZ in SCAR. How a function would look:
SCAR Code:
Function FindChicken(Var CX, CY : Integer): Boolean;
Var
TPA : TPointArray;
ATPA : T2DPointArray;
I, H, J : Integer;
X, Y, Z, X2, Y2, Z2 : Extended;
Begin
ColorToleranceSpeed(3);
SetColorSpeed3Modifiers(10);
FindColorsSpiralTolerance(MSCX, MSCY, TPA, ChickenColor, MSX1, MSY1, MSX2, MSY2, 3);
SetColorSpeed3Modifiers(4);
ColorToleranceSpeed(1);
ColorToXYZ(ChickenColor, X, Y, Z);
ATPA := TPAtoATPAex(TPA, 5, 5);
H := High(ATPA);
For I := 0 To H Do
For J := 0 To High(ATPA[i]) Do
Begin
ColorToXYZ(GetColor(ATPA[i][J].X, ATPA[I][J].Y), X2, Y2, Z2);
If ((X2 - X) < 4) And ((X2 - X) > 2) Then
If ((Y2 - Y) < 2) And ((Y2 - Y) > 0) Then
If ((Y2 - Y) < 5) And ((Y2 - Y) > 3) Then
Begin
CX := ATPA[i][J].X;
CY := ATPA[i][J].Y;
Writeln('ChickenColor = ' + IntToStr(GetColor(ATPA[i][J])));
Result := True;
Exit;
End;
End;
End;
Note: You should add a uptext checker for a more accurate result.
Freddy's words:
Originally Posted by
Freddy1990
The fourth tolerance mode compares colors based on the human eye, so if you think a color looks alike, so will SCAR using that mode, making it extremely sensitive and accurate. You can also change the sensitivity which will make it so you have to use a higher or lower tolerance to achieve a similar effect.
Final Note : What to do with XYZ? experiment with it! compare ranges, differences, distances, sizes, tolerances, lengths, etc.