FastLED 3.9.15
Loading...
Searching...
No Matches

◆ CalcSaturation()

float anonymous_namespace{Painter.cpp}::CalcSaturation ( float time_delta_ms,
const ColorHSV & color,
bool key_on )

Definition at line 74 of file Painter.cpp.

74 {
75 if (color.v_ <= 0.0) {
76 return color.s_;
77 }
78 if (!key_on) {
79 return 1.0f;
80 }
81 static const float kDefaultSaturationTime = 0.05f * 1000.f;
82
83 // At time = 0.0 the saturation_factor will be at 0.0 and then transition to 1.0
84 float saturation_factor = mapf(time_delta_ms,
85 0.0f, kDefaultSaturationTime,
86 0.0f, 1.0f);
87 // As time increases the saturation factor will continue
88 // to grow past 1.0. We use min to clamp it back to 1.0.
89 saturation_factor = MIN(1.0f, saturation_factor);
90 // TODO - make the saturation interpolate between the original
91 // color and the unsaturated state.
92 return saturation_factor;
93}
#define MIN(a, b)
Definition math_macros.h:15
float v_
Definition color.h:98
float s_
Definition color.h:98
float mapf(float x, float in_min, float in_max, float out_min, float out_max)
Definition util.cpp:17

References mapf(), MIN, ColorHSV::s_, and ColorHSV::v_.

+ Here is the call graph for this function: