Last active
August 29, 2015 14:15
-
-
Save sergelerner/dbc1ee2d1db0a4da5f94 to your computer and use it in GitHub Desktop.
Canvas Sin Wave
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<head> | |
<meta charset="utf-8"> | |
<style> | |
canvas { | |
display: block; | |
} | |
</style> | |
<script src="script.js"></script> | |
</head> | |
<body> | |
<canvas id="canvas"></canvas> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.onload = function() { | |
var canvas = document.getElementById("canvas"), | |
context = canvas.getContext("2d"), | |
width = canvas.width = window.innerWidth, | |
height = canvas.height = window.innerHeight; | |
context.translate(0, height/2); | |
context.scale(1, -1); | |
for (var angle = 0; angle < Math.PI * 2; angle += .1) { | |
var x = angle * 100, | |
y = Math.sin(angle) * 200; | |
context.fillRect(x, y, 5, 5); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment