funkcja w Turbo Pascalu zwracająca kolor Atari, autorem jest Rocky
n/w kod wykorzystywany jest w G2F
function rgbRead(cl: Tcolor):byte;
var l, d, c, ma, mi, r2, g2, b2: integer;
h, lu1, lu2, lu3: real;
r, g, b: byte;
begin
ma:=0; mi:=0; h:=0; c:=0;
R:=GetRValue(cl) shr 4;
G:=GetGValue(cl) shr 4;
B:=GetBValue(cl) shr 4;
if (r=g) and (g=b) then begin rgbRead:=r; exit; end;
if (r>=g) and (r>=b) then ma:=r;
if (r<=g) and (r<=b) then mi:=r;
if (g>=r) and (g>=b) then ma:=g;
if (g<=r) and (g<=b) then mi:=g;
if (b>=g) and (b>=r) then ma:=b;
if (b<=g) and (b<=r) then mi:=b;
d:=ma-mi;
if d=1 then begin rgbRead:=mi; exit; end;
r2:=r*100; g2:=g*100; b2:=b*100;
if r=ma then h:=(g2-b2)/d
else
if g=ma then h:=200+((b2-r2)/d)
else
if b=ma then h:=400+((r2-g2)/d);
h:=h*0.6; if h<0 then h:=h+360;
lu1:=r*0.297;
lu2:=g*0.586;
lu3:=b*0.109;
l:=trunc(lu1+lu2+lu3);
case trunc(h) of
21..31: c:=15;
32..43: c:=14;
44..63: c:=13;
64..84: c:=12;
85..147: c:=11;
148..171: c:=10;
172..191: c:=9;
192..209: c:=8;
210..261: c:=7;
262..276: c:=6;
277..297: c:=5;
298..318: c:=4;
319..334: c:=3;
335..360: c:=2;
0..14: c:=2;
15..20: c:=1;
end;
rgbRead:=c shl 4+l;
end;