PDA

View Full Version : Color conflict detector



Markus
12-18-2007, 07:24 PM
Usage: enter two arrays of colors, and one array of tols, and it'll see if there are any conflicts between the colors.

Usefull when checking an array of good and bad colors, to remove the ones that conflict.


program Conflicter;
var tols, colors1, colors2 : tintegerarray; cts : integer;
procedure Init;
begin
Cts := 1; //Which colortolerancespeed?
colors1 := [255, 0, 3];
tols := [1, 0, 100];
colors2 := [255, 365, 254, 1212, 2323111121123123123];
ColorToleranceSpeed(cts);
end;
var
i, ii, iii, ht, l, ll : integer;
a : tintegerarray;
begin
Init;
if (getarraylength(colors1) <> Getarraylength(tols)) then
begin
writeln('First group of colours dont have equal number of tolerances');
terminatescript;
end;
ht := high(tols);
l := high(colors1);
ll := high(colors2);
for i := 0 to l do
for ii := 0 to ll do
begin
if SimilarColors(colors1[i], colors2[ii], tols[i]) then
begin
writeln('CONFLICT DETECTED: '+inttostr(colors1[i])+' with '+inttostr(colors2[ii])+' at tol '+inttostr(tols[i]));
end;
end;
a := colors1;
colors1 := colors2;
colors2 := a;
l := high(colors1);
ll := high(colors2);
for i := 0 to l do
for ii := 0 to ll do
begin
if (i > ht) then
begin
iii := i;
while iii > ht do
iii := iii - ht;
end;
if SimilarColors(colors1[i], colors2[ii], tols[iii]) then
begin
writeln('CONFLICT DETECTED: '+inttostr(colors1[i])+' with '+inttostr(colors2[ii])+' at tol '+inttostr(tols[i]));
end;
end;
end.