FastLED 3.9.15
Loading...
Searching...
No Matches

◆ rainbow()

CRGB fl::FlowFieldFP::rainbow ( s16x16 t,
s16x16 speed,
s16x16 phase )
staticprivate

Definition at line 548 of file flowfield.cpp.hpp.

548 {
549 constexpr s16x16 one(1.0f);
550 constexpr s16x16 fp_255(255.0f);
551 s16x16 hue_raw = t * speed + phase;
552 // Positive modulo: hue in [0, 1)
553 s16x16 hue = s16x16::mod(hue_raw, one);
554 if (hue.raw() < 0)
555 hue = hue + one;
556 i32 hue_int = s16x16::clamp(hue * fp_255, s16x16(), fp_255).to_int();
557 u8 hue_u8 = (u8)hue_int;
558 CHSV hsv(hue_u8, 255, 255);
559 CRGB rgb;
560 hsv2rgb_rainbow(hsv, rgb);
561 return rgb;
562}
uint8_t hue
Definition advanced.h:94
float speed() const
Definition flowfield.h:258
static constexpr FASTLED_FORCE_INLINE s16x16 mod(s16x16 a, s16x16 b) FL_NOEXCEPT
Definition s16x16.h:129
static constexpr FASTLED_FORCE_INLINE s16x16 clamp(s16x16 x, s16x16 lo, s16x16 hi) FL_NOEXCEPT
Definition s16x16.h:162
constexpr i32 to_int() const FL_NOEXCEPT
Definition s16x16.h:61
fl::hsv8 CHSV
Definition chsv.h:11
CRGB hsv2rgb_rainbow(const CHSV &hsv)
unsigned char u8
Definition stdint.h:131
fl::CRGB CRGB
Definition video.h:15

References fl::s16x16::clamp(), hsv2rgb_rainbow(), hue, fl::s16x16::mod(), fl::FlowField::speed(), fl::t, and fl::s16x16::to_int().

+ Here is the call graph for this function: