FastLED 3.10.6
Loading...
Searching...
No Matches

◆ paletteFor()

MoodPalette mood_ring::paletteFor ( const RoomSense & s,
float hueDrift )

Derive the family for this frame. Cheap; call every frame.

Definition at line 21 of file mood_palette.cpp.

21 {
23 // Travel the short way round the wheel from cool to warm (through
24 // magenta/red), which is the emotionally right path: sad -> tense ->
25 // happy, not sad -> green -> happy.
26 const float w = clampf(s.warmth, 0.0f, 1.0f);
27 float hue = kCoolHue + (kWarmHue + 256.0f - kCoolHue) * w;
28 hue += hueDrift * 256.0f;
29 while (hue >= 256.0f)
30 hue -= 256.0f;
31 while (hue < 0.0f)
32 hue += 256.0f;
33 p.hueBase = static_cast<fl::u8>(hue);
34
35 const float a = clampf(s.arousal, 0.0f, 1.0f);
36 p.hueSpread =
37 static_cast<fl::u8>(kMinSpread + (kMaxSpread - kMinSpread) * a);
38 p.saturation = static_cast<fl::u8>(kMinSat + (kMaxSat - kMinSat) * a);
39 return p;
40}
uint8_t hue
Definition advanced.h:94
unsigned char u8
Definition stdint.h:131
float clampf(float v, float lo, float hi)
Definition ring_canvas.h:19
float arousal
0 calm .. 1 energetic
Definition room_sense.h:55
fl::u8 hueSpread
how far t=1 travels from t=0
float warmth
0 cool .. 1 warm, from valence
Definition room_sense.h:54
fl::u8 hueBase
centre of the family

References mood_ring::RoomSense::arousal, clampf(), hue, mood_ring::MoodPalette::hueBase, mood_ring::MoodPalette::hueSpread, mood_ring::MoodPalette::saturation, and mood_ring::RoomSense::warmth.

Referenced by mood_ring::MoodPainter::draw().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: