15 r = r * int(other_color.
r_) / 255;
16 g = g * int(other_color.
g_) / 255;
17 b = b * int(other_color.
b_) / 255;
23 const int s =
static_cast<int>(
scale * 255.0f);
25 int r =
static_cast<int>(
r_) * s / 255;
26 int g =
static_cast<int>(
g_) * s / 255;
27 int b =
static_cast<int>(
b_) * s / 255;
44 if ((255 -
r_) < color.
r_)
r_ = 255;
46 if ((255 -
g_) < color.
g_)
g_ = 255;
48 if ((255 -
b_) < color.
b_)
b_ = 255;
54 const uint8_t* rgb =
At(rgb_index);
55 return rgb ? *rgb : 0;
60 uint8_t* rgb =
At(rgb_index);
70 }
else if (1.0f <= t) {
74 Color3i new_color = other_color;
75 new_color.
Mul(1.0f - t);
102 typedef double FloatT;
103 FloatT r = (FloatT) rgb.
r_/255.f;
104 FloatT g = (FloatT) rgb.
g_/255.f;
105 FloatT b = (FloatT) rgb.
b_/255.f;
106 FloatT max_rgb = max(r, max(g, b));
107 FloatT min_rgb = min(r, min(g, b));
110 FloatT d = max_rgb - min_rgb;
111 s_ = max_rgb == 0 ? 0 : d / max_rgb;
113 if (max_rgb == min_rgb) {
117 h_ = (g - b) / d + (g < b ? 6 : 0);
118 }
else if (max_rgb == g) {
119 h_ = (b - r) / d + 2;
120 }
else if (max_rgb == b) {
121 h_ = (r - g) / d + 4;
129 typedef double FloatT;
135 FloatT f =
h_ * 6.0 -
static_cast<FloatT
>(i);
136 FloatT
p =
v_ * (1.0 -
s_);
137 FloatT q =
v_ * (1.0 - f *
s_);
138 FloatT t =
v_ * (1.0 - (1.0 - f) *
s_);
141 case 0: r =
v_, g = t, b =
p;
break;
142 case 1: r = q, g =
v_, b =
p;
break;
143 case 2: r =
p, g =
v_, b = t;
break;
144 case 3: r =
p, g = q, b =
v_;
break;
145 case 4: r = t, g =
p, b =
v_;
break;
146 case 5: r =
v_, g =
p, b = q;
break;
UISlider scale("Scale", 4,.1, 4,.1)
static FASTLED_NAMESPACE_BEGIN uint8_t const p[]
void Add(const Color3i &color)
Color3i(uint8_t r, uint8_t g, uint8_t b)
void Mul(const Color3i &other_color)
void Interpolate(const Color3i &other_color, float t)
void Sub(const Color3i &color)
void Set(uint8_t r, uint8_t g, uint8_t b)
uint8_t * At(int rgb_index)
uint8_t Get(int rgb_index) const
void FromRGB(const Color3i &rgb)