Created
July 26, 2017 10:57
-
-
Save eonist/4bee7a718feab1ddf73fd4147a9b7e2b to your computer and use it in GitHub Desktop.
linearPressure for forcetouch
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
/** | |
* NOTE: calculates the entire range of the stage pressures so from stage 0 to 1 the pressure goes from 0 to 0.5 and from stage 1 to 2 the linear pressure goes from 0.5 to 1 this makes it easier to scale things in a linear fashion from 0 to 1 in the entire stage range | |
*/ | |
var linearPressure:CGFloat{ | |
if event.stage == 0 { | |
return 0 | |
}else if event.stage == 1{ | |
return pressure / 2 | |
}else /*if stage == 2*/ { | |
return 0.5 + (pressure / 2) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment