added polygon clock drawing code

This commit is contained in:
Michael Yang 2014-05-17 11:11:54 -04:00
parent f910628e27
commit 98d8ae9622

23
main.js
View file

@ -1,7 +1,7 @@
// main thing here
window.requestAnimFrame = (function(){
return window.requestAnimationFrame ||
return window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
function( callback ){
@ -15,7 +15,22 @@ window.requestAnimFrame = (function(){
})();
function render() {
// game code
requestAnimFrame(animloop);
}
drawClock(10, 10, 0, 6);
}
function drawClock(x, y, sides, sideLength, theta) {
ctx.beginPath();
ctx.moveTo(0, sideLength);
for (var i = 0; i < sides; i++) {
var coords = rotatePoint(x, y, degToRadians(60));
ctx.lineTo(coords.x, coords.y);
ctx.moveTo(coords.x, coords.y);
}
ctx.stroke();
}
function degToRadians(degrees) {
return ((Math.PI) / 180) * degrees;
}f