itSchRis917
2008-05-13 01:48:45
So, i just followed Cazax's autocoloring tutorial: http://www.villavu.com/forum/showthread.php?t=29072. And im afraid my function doesnt fully work.. Or work at all for that matter.. Can someone take a look at my code and see if they see anything wrong with it?
const
ExtendedDebug = True;
var
i, c, b, a, cx, cy : integer;
ColorList: Integer;
RangePoints:TPointArray;
RangePoint:TPoint;
Range2DSplit : T2DPointArray;
Furnace: Integer;
C1 : TIntegerArray;
function AutoColorRange: Integer;
var
R, G, B: Integer;
H, S, L: Extended;
X, Y, Z: Extended;
begin
if not LoggedIn then exit;
Furnace := 7963267;
cx := MSCX;
cy := MSCY;
for C := 0 to 10 do
begin
FindColorsSpiralTolerance(cx, cy, RangePoints, Furnace, MSX1, MSY1, MSX2, MSY2, C);
if(Length(RangePoints) - 1 >= 10)then
Break;
end;
Range2DSplit := SplitTPA(RangePoints, 4);
for i := 0 to Length(Range2DSplit) - 1 do
begin
if not LoggedIn then exit;
SortATPAFrom(Range2DSplit, IntToPoint(MSCX, MSCY));
RangePoint:= MiddleTPA(Range2DSplit[i]);
if (ExtendedDebug) then
begin
Writeln('Found '+IntToStr(GetArrayLength(RangePoints))+' possible points.');
Writeln('Split into '+IntToStr(Length(Range2DSplit) - 1)+ ' T2DPointArrays.');
end;
C1 := GetColors(RangePoints);
for a := 0 to Length(C1) - 1 do
begin
begin
cx := RangePoint.x;
cy := RangePoint.y;
ColorList := GetColor(RangePoints[a].X, RangePoints[a].Y);
//if SimilarColors(ColorList, Furnace, 50) then
begin
ColorToRGB(ColorList, R, G, B);
ColorToHSL(ColorList, H, S, L);
ColorToXYZ(ColorList, X, Y, Z);
if InRange(R - G, 95, 155) then
if InRange(R - B, 109, 169) then
if InRange(G - B, -16, 44)then
if InRange(Round(S) - Round(H), -46, -16) then
if InRange(Round(L) - Round(H), -61, -31) then
if InRange(Round(S) - Round(L), -6, 34) then
if InRange(Round(X) - Round(Y), -10, 10) then
if InRange(Round(Y) - Round(Z), -15, 5 ) then
if GetColor(RangePoints[a].X + 2, RangePoints[a].Y + 2) = ColorList then
if GetColor(RangePoints[a].X + 1, RangePoints[a].Y + 1) = ColorList then
begin
Writeln('MyColor = '+Inttostr(ColorList));
Result := ColorList;
Exit;
end;
end;
end;
end;
Writeln('Couldnt find My Color!');
Result := 0;
end;
end;