Skip to content

Commit

Permalink
fix #5081 and #5082
Browse files Browse the repository at this point in the history
  • Loading branch information
computergeek1507 committed Dec 29, 2024
1 parent cef03c5 commit f10ab46
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions xLights/ValueCurve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2202,18 +2202,19 @@ void ValueCurve::ScaleAndOffsetValues(float scale, int offset)
if (offset == 0 && abs(scale - 1.0) < 0.0001) {
return;
}

float range = _max - _min;
auto ScaleVal = [&](float val)
{
float newVal = (val * (scale * _divisor )) + (offset * _divisor);
const float valScaled = val * range;//0-255
float newVal = (valScaled * (scale * _divisor)) + (offset * _divisor);
newVal = std::min(newVal, _max);
newVal = std::max(newVal, _min);
return (val * scale ) + offset;
return newVal / range;

This comment has been minimized.

Copy link
@derwin12

derwin12 Dec 29, 2024

Collaborator

Any risk of range being 0? ie max = min?

};

std::vector<int> parametersToScale;

if (_type == "Custom") {
//custom values are 0-1
for (auto& it : _values) {
it.y = ScaleVal(it.y);
}
Expand Down

0 comments on commit f10ab46

Please sign in to comment.