MCPcopy Create free account
hub / github.com/FastLED/FastLED / CalcLuminance

Function CalcLuminance

examples/LuminescentGrand/shared/Painter.cpp:40–73  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

38}
39
40float CalcLuminance(float time_delta_ms,
41 bool sustain_pedal_on,
42 const Key& key,
43 int key_idx) {
44
45 if (key.mCurrColor.v_ <= 0.0) {
46 return 0.0;
47 }
48
49 const bool dampened_key = (key_idx < kFirstNoteNoDamp);
50
51 const float decay_factor = CalcDecayFactor(sustain_pedal_on,
52 key.mOn,
53 key_idx,
54 key.mVelocity * (1.f/127.f), // Normalizing
55 dampened_key,
56 time_delta_ms);
57
58 if (key.mOn) {
59 //const float brigthness_factor = sin(key.mOrigColor.v_ * PI / 2.0);
60 float brigthness_factor = 0.0f;
61
62 if (kUseLedCurtin) {
63 brigthness_factor = fl::sqrt(fl::sqrt(key.mOrigColor.v_));
64 } else {
65 //brigthness_factor = key.mOrigColor.v_ * key.mOrigColor.v_;
66 brigthness_factor = key.mOrigColor.v_;
67 }
68 return LuminanceDecay(decay_factor) * brigthness_factor;
69 //return 1.0f;
70 } else {
71 return decay_factor * key.mOrigColor.v_;
72 }
73}
74
75float CalcSaturation(float time_delta_ms, const ColorHSV& color, bool key_on) {
76 if (color.v_ <= 0.0) {

Callers 1

PaintMethod · 0.85

Calls 3

CalcDecayFactorFunction · 0.85
sqrtFunction · 0.85
LuminanceDecayFunction · 0.85

Tested by

no test coverage detected