8 p.
r =
static_cast<float>(c.r) * (1.0f / 255.0f);
9 p.
g =
static_cast<float>(c.g) * (1.0f / 255.0f);
10 p.
b =
static_cast<float>(c.b) * (1.0f / 255.0f);
17 static_cast<fl::u8>(
clampf(p.
b, 0.0f, 1.0f) * 255.0f + 0.5f));
22 return x >= e1 ? 1.0f : 0.0f;
23 float t =
clampf((
x - e0) / (e1 - e0), 0.0f, 1.0f);
24 return t *
t * (3.0f - 2.0f *
t);
46 return d < 0.0f ? -d : d;
49float falloff(
float distance,
float sigma) {
52 float t = 1.0f - distance / sigma;
57 return t *
t * (3.0f - 2.0f *
t);
70 return static_cast<float>(
next() >> 8) * (1.0f / 16777216.0f);
74 for (fl::size i = 0; i <
mPx.size(); ++i)
82 return static_cast<float>(i) /
static_cast<float>(n);
87 if (n <= 0 || gain <= 0.0f)
92 RGBf &p =
mPx[
static_cast<fl::size
>(i)];
93 p.
r += color.
r * gain;
94 p.
g += color.
g * gain;
95 p.
b += color.
b * gain;
100 if (n <= 0 || gain <= 0.0f)
102 for (
int i = 0; i < n; ++i) {
103 RGBf &p =
mPx[
static_cast<fl::size
>(i)];
104 p.
r += color.
r * gain;
105 p.
g += color.
g * gain;
106 p.
b += color.
b * gain;
111 const int n =
size();
112 if (n <= 0 || gain <= 0.0f || sigma <= 0.0f)
114 for (
int i = 0; i < n; ++i) {
118 pixel(i, color, gain * k);
123 const RGBf &color,
float gain) {
124 const int n =
size();
125 if (n <= 0 || gain <= 0.0f || sigma <= 0.0f)
127 for (
int i = 0; i < n; ++i) {
131 const float k =
falloff(d, sigma);
134 pixel(i, color, gain * k);
float posOf(int i) const
Position of pixel i in turns.
void pixel(int i, const RGBf &color, float gain)
Add to one pixel, index wrapped.
void lobe(float pos, float sigma, const RGBf &color, float gain)
Add a smooth lobe centred at pos (turns) with half-width sigma (turns).
void fill(const RGBf &color, float gain)
Add the same colour to every pixel.
void ring(float origin, float radius, float sigma, const RGBf &color, float gain)
Add a band at distance radius (turns, 0..0.5) from origin, on both sides of it at once: an expanding ...
float unit()
Uniform in [0, 1).
float smoothstepf(float e0, float e1, float x)
0 below e0, 1 above e1, smooth in between.
float ringDistance(float a, float b)
Shortest distance between two ring positions, in turns, in [0, 0.5].
CRGB toCRGB(const RGBf &p)
float clampf(float v, float lo, float hi)
float ringOffset(float a, float b)
Signed shortest offset from b to a on the ring, in (-0.5, 0.5].
float falloff(float distance, float sigma)
Smooth bump: 1 at distance 0, 0 at distance >= sigma.
float wrapTurns(float t)
Wrap into [0, 1).
Linear-light float pixel, nominal range [0, 1], may exceed 1 before clip.