added polygon clock drawing code
This commit is contained in:
parent
f910628e27
commit
98d8ae9622
1 changed files with 19 additions and 4 deletions
23
main.js
23
main.js
|
@ -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
|
Loading…
Reference in a new issue