Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions www/ftui/modules/ftui/ftui.helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -423,9 +423,18 @@ export function formatMoney(amount) {
}

export function scale(value, minIn, maxIn, minOut, maxOut) {
const slope = (minOut - maxOut) / (minIn - maxIn);
const intercept = slope * -(minIn) + minOut;
return value * slope + intercept;
if(value <= minIn) {
return minOut;
}
else if(value >= maxIn) {
return maxOut;
}
else
{
const slope = (minOut - maxOut) / (minIn - maxIn);
const intercept = slope * -(minIn) + minOut;
return value * slope + intercept;
}
}

export function limit(value, minIn, maxIn) {
Expand Down