PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ rt_util_hsv_to_rgb()

rt_errorstate rt_util_hsv_to_rgb ( double  hsv[3],
double  rgb[3] 
)

Definition at line 559 of file rt_util.c.

559  {
560  double r = 0;
561  double g = 0;
562  double b = 0;
563  double v = hsv[2];
564 
565  if (DBL_EQ(hsv[1], 0.))
566  r = g = b = v;
567  else {
568  double i;
569  double f;
570  double p;
571  double q;
572  double t;
573 
574  int a;
575 
576  i = floor(hsv[0] * 6.);
577  f = (hsv[0] * 6.0) - i;
578  p = v * (1. - hsv[1]);
579  q = v * (1. - hsv[1] * f);
580  t = v * (1. - hsv[1] * (1. - f));
581 
582  a = (int) i;
583  switch (a) {
584  case 1:
585  r = q;
586  g = v;
587  b = p;
588  break;
589  case 2:
590  r = p;
591  g = v;
592  b = t;
593  break;
594  case 3:
595  r = p;
596  g = q;
597  b = v;
598  break;
599  case 4:
600  r = t;
601  g = p;
602  b = v;
603  break;
604  case 5:
605  r = v;
606  g = p;
607  b = q;
608  break;
609  case 0:
610  case 6:
611  default:
612  r = v;
613  g = t;
614  b = p;
615  break;
616  }
617  }
618 
619  rgb[0] = r;
620  rgb[1] = g;
621  rgb[2] = b;
622 
623  return ES_NONE;
624 }
char * r
Definition: cu_in_wkt.c:24
@ ES_NONE
Definition: librtcore.h:180
#define DBL_EQ(x, y)
Definition: librtcore.h:2236

References DBL_EQ, ES_NONE, and r.

Referenced by test_hsv_to_rgb().

Here is the caller graph for this function: