FastLED 3.10.8
Loading...
Searching...
No Matches

◆ rainbow()

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

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

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

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

+ Here is the call graph for this function: