Last active
August 29, 2015 14:27
-
-
Save vanrez-nez/b4aedd416c3dcff608a3 to your computer and use it in GitHub Desktop.
Function that oscillates between two values
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
// @input: discrete counter | |
// @min: lower value | |
// @max: maximum value | |
function oscillate(input, min, max) { | |
var range = max - min; | |
return min + Math.abs(((input + range) % (range * 2)) - range); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment