Thanks, mormonman, I'm going to try that out. Home, I'll PM you my account.
I've also written a couple "inverse" TPA functions to get a TPA of every point in a box that
isn't in the given TPA. In other words, you look for a (constant) color, and it will invert that TPA and return the points that isn't that color. This may also work for mordaut, since the background colors are constant.
If this bmp/dtm idea doesn't pan out, that's my back up. :) For those who are interested (there may be bugs, I haven't tested it that much):
program new;
{$DEFINE SMART}
{$i srl/srl.simba}
{$i srl/srl/misc/paintsmart.simba}
{$i srl/srl/misc/debug.simba}
type
TRotatingItem = record
Name: string;
Max, Min, Avg, Width, Height: Integer;
end;
function InverseTPA(tpa: TPointArray; area: TBox): TPointArray;
var
i, c, h, hh: integer;
tpaArea: TPointArray;
begin
tpaArea := TPAFromBox(area);
setLength(result, length(tpaArea));
c := 0;
h := high(tpaArea);
for i := 0 to h do
begin
if (pointInTPA(tpaArea[i], tpa)) then
continue;
result[c] := tpaArea[i];
inc(c);
end;
setLength(result, c);
end;
function InverseColors(cols, tols: TIntegerArray; area: TBox): TPointArray;
var
i: integer;
tpa: TPointArray;
atpa: T2DPointArray;
begin
setLength(atpa, length(cols));
for i := 0 to high(cols) do
findColorsTolerance(atpa[i], cols[i], area.x1, area.y1, area.x2, area.y2, tols[i]);
tpa := mergeATPA(atpa);
result := InverseTPA(tpa, area);
debugTPA(result, '');
end;
function GetRotatingItem(cols, tols: TIntegerArray; area: TBox; tries: integer; name: string): TRotatingItem;
var
c: Integer;
bounds: TBox;
tmp: TPointArray;
arr, w, h: TIntegerArray;
begin
setLength(arr, tries);
setLength(w, tries);
setLength(h, tries);
repeat
tmp := inverseColors(cols, tols, area);
bounds := getTPABounds(tmp);
w[c] := (bounds.x2 - bounds.x1);
h[c] := (bounds.y2 - bounds.y1);
arr[c] := length(tmp);
inc(c);
until(c = tries);
quickSort(arr);
result.name := name;
result.min := arr[low(arr)];
result.max := arr[high(arr)];
result.avg := averageTIA(arr);
result.width := averageTIA(w);
result.height := averageTIA(h);
end;
procedure DebugRotatingItem(item: TRotatingItem);
begin
writeln('with TRotatingItem do');
writeln('begin');
writeln(' Name := '+capitalize(item.name)+';');
writeln(' Min := '+toStr(item.min)+';');
writeln(' Max := '+toStr(item.max)+';');
writeln(' Avg := '+toStr(item.avg)+';');
writeln(' Width := '+toStr(item.width)+';');
writeln(' Height := '+toStr(item.height)+';');
writeln('end;');
end;
var
i: integer;
tia: TIntegerArray;
begin
{$IFDEF SMART}
SMART_Server := 1;
SMART_Members := False;
SMART_Signed := True;
SMART_SuperDetail := False;
{$ENDIF}
clearDebug();
activateClient();
setupSRL();
SMART_ClearCanvas();
for i := 1 to 8 do
begin
SMART_DrawBoxEx(false, MD_SmallBox(i), clGreen);
debugRotatingItem(getRotatingItem(
[4410947, 5003083], [10, 10], MD_SmallBox(i), 30, 'Mordaut '+toStr(i)));
writeln('');
end;
end.
It won't compile because it's missing MD_SmallBox and a couple grid functions I wrote to create grids (will be useful for inventory and bank later).