Skip to content

Instantly share code, notes, and snippets.

@cormacrelf
Created March 18, 2012 02:51
Show Gist options
  • Save cormacrelf/2068183 to your computer and use it in GitHub Desktop.
Save cormacrelf/2068183 to your computer and use it in GitHub Desktop.
moregraphs
var canvas = document.getElementById('c');
canvas.width = 600;
canvas.height = 600;
var ctx = canvas.getContext('2d');
var draw = function(x,y){
ctx.fillRect(x,600-y,1,1);
};
ctx.fillRect(300,0,1,600);
ctx.fillRect(0,300,600,1);
var f = function(x) {
return Math.pow(x / 50, 2);
};
for (j = 0; j < 600; j++) {
x = j - 300;
var y = Math.sin((x)/ 30 ) * 100;
y += 300;
draw(j,y);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment