Skip to content

Instantly share code, notes, and snippets.

@benfoxall
Created October 28, 2014 01:19
Show Gist options
  • Save benfoxall/75f162343497d640fecb to your computer and use it in GitHub Desktop.
Save benfoxall/75f162343497d640fecb to your computer and use it in GitHub Desktop.
// (cos allows smooth transitions from 0->1->0)
// 0 -> 1 stepped sin frequency from 1 -> 5
function stepper(i){
var t = 2*Math.PI* ~~(i * 10);
return Math.cos(i*10*t)
}
// generalised version
// stepper = generateStepper(5,1)
function generateStepper(steps, initial){
var c = steps * initial * 2 * Math.PI;
return function(i){
return Math.cos(~~(i * steps) * i * c)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment