MCPcopy Create free account
hub / github.com/emscripten-core/emscripten / HSVtoRGB

Function HSVtoRGB

test/pthread/test_pthread_mandelbrot.cpp:31–80  ·  view source on GitHub ↗

h: 0,360 s: 0,1 v: 0,1

Source from the content-addressed store, hash-verified

29// s: 0,1
30// v: 0,1
31void HSVtoRGB(float *r, float *g, float *b, float h, float s, float v)
32{
33 int i;
34 float f, p, q, t;
35 if (s == 0)
36 {
37 // achromatic (grey)
38 *r = *g = *b = v;
39 return;
40 }
41 h /= 60; // sector 0 to 5
42 i = floor(h);
43 f = h - i; // factorial part of h
44 p = v * (1 - s);
45 q = v * (1 - s * f);
46 t = v * (1 - s * (1 - f));
47 switch(i)
48 {
49 case 0:
50 *r = v;
51 *g = t;
52 *b = p;
53 break;
54 case 1:
55 *r = q;
56 *g = v;
57 *b = p;
58 break;
59 case 2:
60 *r = p;
61 *g = v;
62 *b = t;
63 break;
64 case 3:
65 *r = p;
66 *g = q;
67 *b = v;
68 break;
69 case 4:
70 *r = t;
71 *g = p;
72 *b = v;
73 break;
74 default: // case 5:
75 *r = v;
76 *g = p;
77 *b = q;
78 break;
79 }
80}
81
82int smallestIterOut = 0x7FFFFFFF;
83uint32_t ColorMap(int iter)

Callers 1

ColorMapFunction · 0.85

Calls 1

floorFunction · 0.50

Tested by

no test coverage detected