Skip to content

Instantly share code, notes, and snippets.

@bit101
Last active November 5, 2017 18:00
Show Gist options
  • Save bit101/68fb146ed72e137e46bfd55dfd7029d0 to your computer and use it in GitHub Desktop.
Save bit101/68fb146ed72e137e46bfd55dfd7029d0 to your computer and use it in GitHub Desktop.
trig 1, iteration 1
var canvas = document.getElementById("canvas"),
context = canvas.getContext("2d"),
width = canvas.width = window.innerWidth,
height = canvas.height = window.innerHeight;
var waveCount = 1,
waveHeight = height / 2 - 10,
res = 1;
context.translate(0, height / 2);
context.scale(1, -1);
context.beginPath();
for(var x = 0; x < width; x += res) {
var i = x / width * Math.PI * 2 * waveCount,
y = Math.sin(i) * waveHeight;
context.lineTo(x, y);
console.log(i);
}
context.stroke();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment