deps/kb_meme/meme-5.0.1/src/alph-in.c
/*
 * Convert a colour in the HSV colourspace into the RGB colourspace.
 * It is easy to create colours in the HSV colourspace but then we need it in
 * the RGB colourspace to actually use.
 */
Convert a colour in the HSV colourspace into the RGB colourspace.
It is easy to create colours in the HSV colourspace but then we need it in
the RGB colourspace to actually use.
Convert a colour in the HSV colourspace into the RGB colourspace . It is easy to create colours in the HSV colourspace but then we need it in the RGB colourspace to actually use .
static int hsv2rgb(double h, double s, double v) {
  double r, g, b, f, p, q, t;
  int i;
  uint8_t red, blue, green;
  int rgb;
  if (s == 0) {
    r = v; g = v; b = v;
  } else {
    h /= 60;
    i = floor(h);
    f = h - i;
    p = v * (1.0 - s);
    q = v * (1.0 - (s * f));
    t = v * (1.0 - (s * (1.0 - f)));
    switch (i) {
      case 0:  r = v; g = t; b = p; break;
      case 1:  r = q; g = v; b = p; break;
      case 2:  r = p; g = v; b = t; break;
      case 3:  r = p; g = q; b = v; break;
      case 4:  r = t; g = p; b = v; break;
      default: r = v; g = p; b = q; break;
    }
  }
  red = (uint8_t)round(r * 255.0);
  green = (uint8_t)round(g * 255.0);
  blue = (uint8_t)round(b * 255.0);
  rgb = (red << 16) | (green << 8) | blue;
  return rgb;
}
static int hsv2rgb ( double h , double s , double v ) { double r , g , b , f , p , q , t ; int i ; uint8_t red , blue , green ; int rgb ; if ( s == 0 ) { r = v ; g = v ; b = v ; } else { h /= 60 ; i = floor ( h ) ; f = h - i ; p = v * ( 1.0 - s ) ; q = v * ( 1.0 - ( s * f ) ) ; t = v * ( 1.0 - ( s * ( 1.0 - f ) ) ) ; switch ( i ) { case 0 : r = v ; g = t ; b = p ; break ; case 1 : r = q ; g = v ; b = p ; break ; case 2 : r = p ; g = v ; b = t ; break ; case 3 : r = p ; g = q ; b = v ; break ; case 4 : r = t ; g = p ; b = v ; break ; default : r = v ; g = p ; b = q ; break ; } } red = ( uint8_t ) round ( r * 255.0 ) ; green = ( uint8_t ) round ( g * 255.0 ) ; blue = ( uint8_t ) round ( b * 255.0 ) ; rgb = ( red << 16 ) | ( green << 8 ) | blue ; return rgb ; }
Convert a colour in the HSV colourspace into the RGB colourspace.
Convert a colour in the HSV colourspace into the RGB colourspace .
// achromatic (grey)