(ratio: number, min: number, max: number, step: number)
| 1239 | }; |
| 1240 | |
| 1241 | const ratioToValue = (ratio: number, min: number, max: number, step: number): number => { |
| 1242 | let value = (max - min) * ratio; |
| 1243 | |
| 1244 | if (step > 0) { |
| 1245 | // round to nearest multiple of step, then add min |
| 1246 | value = Math.round(value / step) * step + min; |
| 1247 | } |
| 1248 | const clampedValue = clamp(min, value, max); |
| 1249 | |
| 1250 | return roundToMaxDecimalPlaces(clampedValue, min, max, step); |
| 1251 | }; |
| 1252 | |
| 1253 | const valueToRatio = (value: number, min: number, max: number): number => { |
| 1254 | return clamp(0, (value - min) / (max - min), 1); |
no test coverage detected