Created
October 16, 2017 13:27
-
-
Save cemolcay/74859fac5dcdb3caf26013499c15563b to your computer and use it in GitHub Desktop.
This file contains 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
func convertValue(oldValue: CGFloat, oldMin: CGFloat, oldMax: CGFloat, newMin: CGFloat, newMax: CGFloat) -> CGFloat { | |
let oldRange = oldMax - oldMin | |
let newRange = newMax - newMin | |
return (((oldValue - oldMin) * newRange) / oldRange) + newMin | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment