Witam
Mam dziwny problem z funkcją która ma obliczyć kolor po podaniu "progresu".
Wygląda ona tak:
function HexToTColor(sColor : string) : TColor;
begin
Result :=
RGB(
StrToInt('$'+Copy(sColor, 1, 2)),
StrToInt('$'+Copy(sColor, 3, 2)),
StrToInt('$'+Copy(sColor, 5, 2))
) ;
end;
function Przejscie(A,B:TColor; pos,max_pos:integer):Tcolor;
var
C:TColor;
a1,b1,c1:integer;
begin
a1:=Trunc(abs(((GetRValue(b) - GetRValue(a))*pos)/max_pos + GetRValue(a)));
b1:=Trunc(abs(((GetGValue(b) - GetGValue(a))*pos)/max_pos + GetGValue(a)));
c1:=Trunc(abs(((GetBValue(b) - GetBValue(a))*pos)/max_pos + GetBValue(a)));
C:= HexToTColor((IntToHex(a1,2)) + (IntToHex(b1,2)) + IntToHex(c1,2));
result:= C;
end;
Problem w tym że nie wiem dlaczego czasem funkcja "wybucha" i np. podaje na zmianę kolor1 i kolor2, lub inne cuda O_o
Z góry dziękuję za pomoc.