static inline cRGB HSV2RGB(float H, float S, float V) { H = 6.0f * H; if (S < 5.0e-6) { cRGB(V, V, V); } else { int i = (int)H; float f = H - i; float p1 = V * (1.0f - S); float p2 = V * (1.0f - S * f); float p3 = V * (1.0f - S * (1.0f - f)); switch (i) { case 0: return cRGB(V, p3, p1); case 1: return cRGB(p2, V, p1); case 2: return cRGB(p1, V, p3); case 3: return cRGB(p1, p2, V); case 4: return cRGB(p3, p1, V); case 5: return cRGB(V, p1, p2); } } return cRGB(0, 0, 0); }
EffectSineWave::EffectSineWave () { setColor(cRGB(0,0,0), cRGB(255,255,255)); this->cyclePi = PI * 4.0; this->offset = 0; }
cRGB operator()(const cRGB &c) const { return cRGB(std::min(std::max(c.r, 0.0f), 1.0f), std::min(std::max(c.g, 0.0f), 1.0f), std::min(std::max(c.b, 0.0f), 1.0f)); }
static inline cRGB operator*(float s, const cRGB &a) { return cRGB(s * a.r, s * a.g, s * a.b); }
static inline cRGB operator+(const cRGB &a, const cRGB &b) { return cRGB(a.r + b.r, a.g + b.g, a.b + b.b); }