SCAR Code:
function SimilarRGB(col1, col2, rT, gT, bT: Integer): Boolean;
var
r1, g1, b1, r2, g2, b2: Integer;
begin
ColorToRGB(col1, r1, g1, b1);
ColorToRGB(col2, r2, g2, b2);
Result := InRange(r2, r1 - rT, r1 + rT) and InRange(g2, g1 - gT, g1 + gT) and InRange(b2, b1 - bT, b1 + bT);
end;
function SimilarHSL(col1, col2, hT, sT, lT: Integer): Boolean;
var
h1, s1, l1, h2, s2, l2: Extended;
begin
ColorToHSL(col1, h1, s1, l1);
ColorToHSL(col2, h2, s2, l2);
Result := (h2 > (h1 - hT)) and (h2 < (h1 + hT)) and (s2 > (s1 - sT)) and (s2 < (s1 + sT)) and (l2 > (l1 - lT)) and (l2 < (l1 + lT));
end;
function SimilarXYZ(col1, col2, xT, yT, zT: Integer): Boolean;
var
x1, y1, z1, x2, y2, z2: Extended;
begin
ColorToXYZ(col1, x1, y1, z1);
ColorToHSL(col2, x2, y2, z2);
Writeln(FloatToStr(x1) + ',' + FloatToStr(y1) + ',' + FloatToStr(z1));
Writeln(FloatToStr(x2) + ',' + FloatToStr(y2) + ',' + FloatToStr(z2));
Result := (x2 > (x1 - xT)) and (x2 < (x1 + xT)) and (y2 > (y1 - yT)) and (y2 < (y1 + yT)) and (z2 > (z1 - zT)) and (z2 < (z1 + zT));
end;
function SimilarCol(col1, col2, rT, gT, bT, hT, sT, lT, xT, yT, zT: Integer): Boolean;
begin
Result := SimilarRGB(col1, col2, rT, gT, bT) and SimilarHSL(col1, col2, hT, sT, lT) and SimilarXYZ(col1, col2, xT, yT, zT);
end;