Skip to content

Instantly share code, notes, and snippets.

@vanrez-nez
Last active August 29, 2015 14:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vanrez-nez/b4aedd416c3dcff608a3 to your computer and use it in GitHub Desktop.
Save vanrez-nez/b4aedd416c3dcff608a3 to your computer and use it in GitHub Desktop.
Function that oscillates between two values
// @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