Показать сообщение отдельно
  #9  
Старый 15.10.2010, 19:24
Аватар для KOOL
KOOL KOOL вне форума
Активный
 
Регистрация: 06.01.2008
Адрес: Рязань
Сообщения: 306
Версия Delphi: 2009
Репутация: 6150
По умолчанию

Код:
function RYBToRGB(R, Y, B:byte):TColor;
  function cubicInt(t, A, B:single):single;
  begin
    Result:=A + t*t*(3-2*t)*(B-A);
  end;
var iR, iY, iB, x0, x1, x2, x3, y0, y1 : single;
    rR, rG, rB : byte;
begin
  iR := R/255;
  iY := Y/255;
  iB := B/255;

  x0 := cubicInt(iB, 1.0, 0.163);
  x1 := cubicInt(iB, 1.0, 0.0);
  x2 := cubicInt(iB, 1.0, 0.5);
  x3 := cubicInt(iB, 1.0, 0.2);
  y0 := cubicInt(iY, x0, x1);
  y1 := cubicInt(iY, x2, x3);
  rR := Round(255*cubicInt(iR, y0, y1));

  x0 := cubicInt(iB, 1.0, 0.373);
  x1 := cubicInt(iB, 1.0, 0.66);
  x2 := cubicInt(iB, 0.0, 0.0);
  x3 := cubicInt(iB, 0.5, 0.094);
  y0 := cubicInt(iY, x0, x1);
  y1 := cubicInt(iY, x2, x3);
  rG := Round(255*cubicInt(iR, y0, y1));

  x0 := cubicInt(iB, 1.0, 0.6);
  x1 := cubicInt(iB, 0.0, 0.2);
  x2 := cubicInt(iB, 0.0, 0.5);
  x3 := cubicInt(iB, 0.0, 0.0);
  y0 := cubicInt(iY, x0, x1);
  y1 := cubicInt(iY, x2, x3);
  rB := Round(255*cubicInt(iR, y0, y1));

  Result := (rB shl 16) + (rG shl 8) + rR;
end;
источник: http://threekings.tk/mirror/ryb_TR.pdf
З.Ы. модель субстрактивная, а не аддитивная, как RGB
__________________
РГРТУ - ФВТ - Системы Автоматизированного ПРоектирования. ت
Ответить с цитированием