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 75 of file Painter.cpp.

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

References mapf(), fl::min(), ColorHSV::s_, and ColorHSV::v_.

+ Here is the call graph for this function: