SRL Archive - SRL Archives

AutoColor fixes!


noidea

2009-09-05 04:45:12

I have only got one right now, FindVarrockRoadColor;

Some might think its a bit over kill, but I want it to be accurate and find the same strand of colour.
function FindVrrk: Integer;
var
Col, ii, i, c, n, w: Integer;
TestColours: TIntegerArray;
TPA: TPointArray;
x, y, z: Extended;
r, g, b: Integer;
BlackList, ResultArr, tr: TIntegerArray;
begin
FindColorsSpiralTolerance(mmcx, mmcy, tpa, 8881291, mmx1, mmy1, mmx2, mmy2, 70);
if length(tpa) > 0 then
begin
c := high(TPA);
TestColours := GetColors(TPA);
for i := 0 to c do
begin
ColorToRGB(TestColours[i], r, g, b);
ColorToXYZ(TestColours[i], x, y, z);
if not InIntArray(blacklist, TestColours[i]) then
if InRange(R - B, -5, 13) then
if InRange(R - G, -7, 10) then
if InRange(G - B, -5, 9) then
if ((x > 22.5) and (x < 26.5)) then
if ((y > 22.5) and (y < 27.8)) then
if ((z > 23.5) and (z < 28.7)) then
begin
n := high(ResultArr);
SetArrayLength(ResultArr, n + 2);
ResultArr[n+1] := TestColours[i];
end;
w := high(blacklist);
SetArrayLength(BlackList, w + 2);
BlackList[w+1] := TestColours[i];
end;
end;
if length(resultarr) < 1 then
begin
result := -1;
writeln('Could not find Varrock road color!');
exit;
end;
w := high(resultArr);
col := resultarr[0];
n := countcolor(col, mmx1, mmy1, mmx2, mmy2);
for i := 1 to w do
begin
ii := CountColor(resultarr[i], mmx1, mmy1, mmx2, mmy2);
if ii > n then
begin
n := ii;
col := resultarr[i];
end;
end;
result := col;
writeln('Varrock Road color = '+inttostr(result));
end;

Smarter Child

2009-09-05 05:15:36

It Looks good, btw, add the Writeln('Varrock Road Color = ' Color); :p

:)

noidea

2009-09-05 05:45:12

Sorry :X I've been usuing debugTPA to get this.
I dont really like how the current autocolours use SRLWarn, as it doesnt display whether or not it found the colour..

Blumblebee

2009-09-05 07:46:30

^ agreed. And I like it :) looks good, I had a good fix going myself, but it required some other functions that I made (it wasnt an autocolor really, hard to explain). awesome work man

marpis

2009-09-05 13:28:04

ranges look kinda small, did you test this in many worlds?
((x > 22.5) and (x < 26.5))
InRange(G - B, -5, 7)

Bobzilla69

2009-09-05 17:56:11

i fixed my auto color for lumbridgeroad by changing line 253 in the Auto Color.scar to
  if (FindMMColorsSpiralTolerance(TPA, 7504775, 10)) then

noidea

2009-09-05 20:27:34

From: marpis
ranges look kinda small, did you test this in many worlds?
((x > 22.5) and (x < 26.5))
InRange(G - B, -5, 7)


Yes, I have tested in multiple worlds.
But it could use some more testing.
Can any one test it please :<

Bob: Maybe thats all the SRL FindVarrockRoadColor needs =\

Bobzilla69

2009-09-05 20:33:24

you should give it a shot, i used ACA just loged in and out of world collecting colors.

edit: just collected some colors for varrock.

best color match: 8488324

might need the RGB range aswell,
R, Max:139 Min:124
G, Max:142 Min:124
B, Max:138 Min:120

havent tested it should work

Sabzi

2009-09-05 20:42:39

I have tested it(with refreshing the page) and it works good. You need bigger tolerance, though, if you want to find most of the road then before.
Nice job.

EDIT: noidea owns ACA ;), trust me. He got "some" experience with autocoloring.

EvilChicken!

2009-09-06 17:05:04

Protip: use InRange to make stuff look cleaner.

Tell me when this has been tested a bit more, and I'll add it.
Plus, would be neat with some debug pics?

noidea

2009-09-06 18:24:16

Ugh, its not quite ready.
The lumbridge castles floor is extremely similar to the Varrock Road Color, and I cant understand that =\

I still need to find the difference between the two.

Wanted

2009-09-07 05:37:21

FindFallyRoadColor fix pl0x

Blumblebee

2009-09-07 06:13:55



Function GetMMPoints(x, y, color, width, height, tolerance: Integer): TpointArray;
var tpa: TpointArray; atpa: T2DpointArray; l, i, p: Integer;
begin
FindColorsSpiralTolerance(x, y, tpa, color, MMx1, MMy1, MMx2, MMy2, tolerance);
Atpa := TPAtoATPAEx(Tpa, width, height);
for i := 0 to High(atpa) do
begin
if Length(atpa) > 5 then
begin
l := getarraylength(Result);
SetArrayLength(Result, l+1);
Result[l] := MiddleTpa(atpa[i]);
end;
end;
if Length(result) = 0 then Exit;
for i := 0 to High(Result) do
if rs_OnMiniMap(result[i].x, result[i].y) then Inc(p);
if p = 0 then SetArrayLength(Result, 0);
end;

Function FindRoadColor(TPA: TPointArray) : Integer;
var t, i, ii, time: Integer; aCol, uCol, tCol: TIntegerArray;
begin
time := GetSystemTime;
aCol := GetColors(TPA);
uCol := aCol;
ClearSameIntegers(aCol);
SetLength(tCol, high(uCol)+1);
for i := 0 to high(aCol) do
begin
for ii := 0 to high(uCol) do
begin
if aCol[i] = uCol[ii] then
Inc(tCol[ii]);
end;
end;
t := 0;
for i := 0 to high(uCol) do
if tCol[i] > tCol[t] then
t := i;
Result := uCol[t];
WriteLn('Varrock Road Color = '+IntToStr(Result));
end;

used as so:

RoadColor := FindRoadColor(GetMMPoints(MMcx, MMcy-25, 8488581, 5, 5, 25));

the x and y help to solidify the area you wish to grab the colors from. Works for any road, the example I have is for Varrock Road.

xSaintias

2009-09-07 17:25:12

have yoiu tried this out on many worlds?