PostGIS  2.1.10dev-r@@SVN_REVISION@@
rt_errorstate rt_util_hsv_to_rgb ( double  hsv[3],
double  rgb[3] 
)

Definition at line 665 of file rt_api.c.

References DBL_EQ, ES_NONE, and r.

Referenced by test_hsv_to_rgb().

665  {
666  double r = 0;
667  double g = 0;
668  double b = 0;
669  double v = hsv[2];
670 
671  if (DBL_EQ(hsv[1], 0.))
672  r = g = b = v;
673  else {
674  double i;
675  double f;
676  double p;
677  double q;
678  double t;
679 
680  int a;
681 
682  i = floor(hsv[0] * 6.);
683  f = (hsv[0] * 6.0) - i;
684  p = v * (1. - hsv[1]);
685  q = v * (1. - hsv[1] * f);
686  t = v * (1. - hsv[1] * (1. - f));
687 
688  a = (int) i;
689  switch (a) {
690  case 1:
691  r = q;
692  g = v;
693  b = p;
694  break;
695  case 2:
696  r = p;
697  g = v;
698  b = t;
699  break;
700  case 3:
701  r = p;
702  g = q;
703  b = v;
704  break;
705  case 4:
706  r = t;
707  g = p;
708  b = v;
709  break;
710  case 5:
711  r = v;
712  g = p;
713  b = q;
714  break;
715  case 0:
716  case 6:
717  default:
718  r = v;
719  g = t;
720  b = p;
721  break;
722  }
723  }
724 
725  rgb[0] = r;
726  rgb[1] = g;
727  rgb[2] = b;
728 
729  return ES_NONE;
730 }
char * r
Definition: cu_in_wkt.c:25
#define DBL_EQ(x, y)
Definition: rt_api.h:2161

Here is the caller graph for this function: