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

◆ composedWith()

FluxScalar fl::FluxScalar::composedWith ( FluxScalar other) const

Multiplicative composition, commutative: combining brightness and the limiter in either order gives the same scalar, which is all C4 needs.

It is NOT associative – Q16 rounding breaks that. With raw values 1, 32768, 32768, (a.composedWith(b)).composedWith(c) is 1 while a.composedWith(b.composedWith(c)) is 0. Compose at most two scalars, or keep wider precision across the chain.

Definition at line 33 of file flux_scalar.cpp.hpp.

33 {
34 // Q16 x Q16 is Q32; the i64 accumulator is required because two
35 // near-unity scalars already exceed i32.
36 const i64 product = static_cast<i64>(mRawQ16) * static_cast<i64>(other.mRawQ16);
37 return FluxScalar(static_cast<i32>((product + 32768) >> 16));
38}
FluxScalar(i32 raw) FL_NO_EXCEPT
fl::i64 i64
Definition stdint.h:221

References FluxScalar(), fl::FL_NO_EXCEPT, and mRawQ16.

+ Here is the call graph for this function: