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

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