HSV to RGB implementation in raw C, platform independent.
52{
53
54
55
56
57
59 uint8_t saturation = hsv.sat;
60
61
62
64 uint8_t brightness_floor = (value * invsat) / 256;
65
66
67
68
69 uint8_t color_amplitude = value - brightness_floor;
70
71
72
75
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109 uint8_t rampup_amp_adj = (rampup * color_amplitude) / (256 / 4);
110 uint8_t rampdown_amp_adj = (rampdown * color_amplitude) / (256 / 4);
111
112
113 uint8_t rampup_adj_with_floor = rampup_amp_adj + brightness_floor;
114 uint8_t rampdown_adj_with_floor = rampdown_amp_adj + brightness_floor;
115
116
117 if( section ) {
118 if( section == 1) {
119
120 rgb.r = brightness_floor;
121 rgb.g = rampdown_adj_with_floor;
122 rgb.b = rampup_adj_with_floor;
123 } else {
124
125 rgb.r = rampup_adj_with_floor;
126 rgb.g = brightness_floor;
127 rgb.b = rampdown_adj_with_floor;
128 }
129 } else {
130
131 rgb.r = rampdown_adj_with_floor;
132 rgb.g = rampup_adj_with_floor;
133 rgb.b = brightness_floor;
134 }
135}
UISlider offset("Offset", 0.0f, 0.0f, 1.0f, 0.01f)
#define APPLY_DIMMING(X)
Apply dimming compensation to values.
#define HSV_SECTION_3
Divide the color wheel into four sections, 64 elements each.