Skip to content

Instantly share code, notes, and snippets.

@bpierre
Created July 13, 2010 20:49
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 bpierre/474509 to your computer and use it in GitHub Desktop.
Save bpierre/474509 to your computer and use it in GitHub Desktop.
function getWave(min, max, steps) {
var stepLength = (max - min) / (steps-1);
var roundedStepLength = Math.round(stepLength*10)/10;
var rounder = roundedStepLength*10 - Math.floor(roundedStepLength)*10;
var curStep = 0,
i = 0;
var steps = [];
for(i = min; i+rounder < max; i += Math.floor(roundedStepLength)) {
if (rounder * curStep > 10) {
curstep = 0;
i++;
}
curStep++;
steps.push(i);
}
steps.push(i);
return steps;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment