Skip to content

Instantly share code, notes, and snippets.

@ayamflow
Created February 25, 2016 01:51
Show Gist options
  • Save ayamflow/6a148d49eaa376d4455c to your computer and use it in GitHub Desktop.
Save ayamflow/6a148d49eaa376d4455c to your computer and use it in GitHub Desktop.
Loop a value between 2 corners
function loop(val, min, max){
if (val < min) return ((val + 1) % max) + (max - 1);
return val % max;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment