FastLED 3.10.6
Loading...
Searching...
No Matches
layers.h
Go to the documentation of this file.
1// layers.h - the three ring-native looks that MoodPainter mixes.
2//
3// Each layer renders the whole ring into its own float canvas every frame
4// and is blind to the others. The painter weights them by RoomSense::calm /
5// flow / groove, so a layer only has to look right at full strength.
6//
7// Nothing in a layer steps. Hits go through a Follower with a short attack
8// so even an instant event ramps over a frame or two, and every position is
9// advanced by rate * dt rather than snapped.
10#pragma once
11
12#include "FastLED.h"
13#include "fl/stl/stdint.h"
14
15#include "mood_palette.h"
16#include "ring_canvas.h"
17#include "room_sense.h"
18
19namespace mood_ring {
20
25 public:
26 void render(const RoomSense &s, const MoodPalette &pal, float dtSec,
27 RingCanvas &c);
28
29 private:
30 float mBreath = 0.0f;
31 float mPosA = 0.0f;
32 float mPosB = 0.5f;
33};
34
39class FlowLayer {
40 public:
41 void render(const RoomSense &s, const MoodPalette &pal, float dtSec,
42 RingCanvas &c);
43
44 private:
45 struct Grain {
46 int index = 0;
47 float ageSec = 0.0f;
48 bool active = false;
49 };
50 static const int kMaxGrains = 24;
51
52 void spawnGrains(const RoomSense &s, float dtSec, int ringSize);
53 void drawGrains(const MoodPalette &pal, float dtSec, RingCanvas &c);
54
55 float mPosA = 0.0f;
56 float mPosB = 0.5f;
57 float mHueWalk = 0.0f;
58 float mSpawnBudget = 0.0f;
62 Xorshift mRng{0xC0FFEE11u};
63};
64
70 public:
71 void render(const RoomSense &s, const MoodPalette &pal, float dtSec,
72 RingCanvas &c);
73
74 private:
75 static const int kMarkers = 4;
76
77 float mRotation = 0.0f;
78 float mCorrection = 0.0f;
82};
83
84} // namespace mood_ring
float mPosA
turns
Definition layers.h:31
void render(const RoomSense &s, const MoodPalette &pal, float dtSec, RingCanvas &c)
Definition layers.cpp:59
float mBreath
radians
Definition layers.h:30
Follower mSigma
Definition layers.h:60
void drawGrains(const MoodPalette &pal, float dtSec, RingCanvas &c)
Definition layers.cpp:105
Grain mGrains[kMaxGrains]
Definition layers.h:61
void render(const RoomSense &s, const MoodPalette &pal, float dtSec, RingCanvas &c)
Definition layers.cpp:126
static const int kMaxGrains
Definition layers.h:50
void spawnGrains(const RoomSense &s, float dtSec, int ringSize)
Definition layers.cpp:82
Busy room without a beat.
Definition layers.h:39
Smoothed one-pole follower with independent attack and release.
Definition room_sense.h:72
float mCorrection
remaining phase correction, turns
Definition layers.h:78
void render(const RoomSense &s, const MoodPalette &pal, float dtSec, RingCanvas &c)
Definition layers.cpp:165
float mRotation
turns, advanced continuously
Definition layers.h:77
static const int kMarkers
Definition layers.h:75
Music with a beat.
Definition layers.h:69
Additive drawing helpers over a span of float pixels.
Definition ring_canvas.h:66
Small deterministic RNG for sparkle. No libc, no global state.
Definition ring_canvas.h:54
Everything a visual is allowed to react to.
Definition room_sense.h:31