Ogre
2010-12-19 17:57:02
I think this could be useful for things such as a simple auto color.
This was a function I originally wanted to make a while ago in a script I was making, and I did, but it was pretty ugly. What you see here is mostly Method's doing.
function MostSimilarColorInBox(Color, MinTol: Integer; Box: TBox): Integer;
var
Colors: TIntegerArray;
i, n: Integer;
begin
Result := -1;
Colors := GetColorsBox(Box.x1, Box.y1, Box.x2, Box.y2, True);
for i := 0 to High(Colors) do
begin
if SimilarColors(Color, Colors[i], MinTol) then
begin
for n := 0 to MinTol do
begin
if SimilarColors(Color, Colors[i], n) then
begin
MinTol := n;
Break;
end;
end;
Result := Color;
if n = 0 then
Exit;
end;
end;
end;This was a function I originally wanted to make a while ago in a script I was making, and I did, but it was pretty ugly. What you see here is mostly Method's doing.