Created
October 21, 2022 21:47
-
-
Save ruan65/d4478d2bc06bfce0661042688e97a359 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension Normalize on num { | |
num normalized( | |
num selfRangeMin, | |
num selfRangeMax, [ | |
num normalizedRangeMin = 0.0, | |
num normalizedRangeMax = 1.0, | |
]) => | |
(normalizedRangeMax - normalizedRangeMin) * | |
((this - selfRangeMin) / (selfRangeMax - selfRangeMin)) + | |
normalizedRangeMin; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment