HSV => RGB

  1. function HSV2RGB(h: integer; s, v: double): GraphABC.Color;
  2. var
  3.   Hi: integer;
  4.   f, p, q, t, r, g, b: double;
  5. begin
  6.   Hi := (h div 60) mod 6;
  7.   f := h / 60 - (h div 60);
  8.   p := v * (1 - s);
  9.   q := v * (1 - f * s);
  10.   t := v * (1 - (1 - f) * s);
  11.  
  12.   case Hi of
  13.     0: begin r := v; g := t; b := p; end;
  14.     1: begin r := q; g := v; b := p; end;
  15.     2: begin r := p; g := v; b := t; end;
  16.     3: begin r := p; g := q; b := v; end;
  17.     4: begin r := t; g := p; b := v; end;
  18.     5: begin r := v; g := p; b := q; end;
  19.   end;
  20.  
  21.   Result := GraphABC.RGB(round(r * 255), round(g * 255), round(b * 255));
  22. end;

Реклама

Мы в соцсетях

tw tg yt gt