Josh Robertson / @hossman333
Lots of demos.
var canvas = document.getElementById('example');
var ctx = canvas.getContext('2d');
ctx.clearRect(0, 0, canvas.width, canvas.height);
radians = degrees * Math.PI / 180
degrees = radians * 180 / Math.PI
var canvas = document.getElementById('example');
var ctx = canvas.getContext('2d');
var radius = 50;
ctx.beginPath();
ctx.arc(canvas.width / 2, canvas.height / 2, radius, 0, Math.PI);
ctx.stroke();
var canvas = document.getElementById('example');
var ctx = canvas.getContext('2d');
var radius = 50;
ctx.beginPath();
ctx.arc(canvas.width / 2, canvas.height / 2, radius, 0, Math.PI * 2);
ctx.stroke();
var canvas = document.getElementById('example');
var ctx = canvas.getContext('2d');
var radius = 50;
ctx.beginPath();
ctx.arc(canvas.width / 2, canvas.height / 2, radius, 0, Math.PI / 2);
ctx.stroke();
var canvas = document.getElementById('example');
var ctx = canvas.getContext('2d');
var radius = 50;
var degrees = 180;
var radians = degrees * Math.PI / 180;
ctx.beginPath();
ctx.arc(canvas.width / 2, canvas.height / 2, radius, 0, radians);
ctx.stroke();
var canvas = document.getElementById('example');
var ctx = canvas.getContext('2d');
var radius = 50;
var degrees = 360;
var radians = degrees * Math.PI / 180;
ctx.beginPath();
ctx.arc(canvas.width / 2, canvas.height / 2, radius, 0, radians);
ctx.stroke();
var canvas = document.getElementById('example');
var ctx = canvas.getContext('2d');
var radius = 50;
var degrees = 90;
var radians = degrees * Math.PI / 180;
ctx.beginPath();
ctx.arc(canvas.width / 2, canvas.height / 2, radius, 0, radians);
ctx.stroke();
ctx.clearRect(0, 0, canvas.width, canvas.height);
var angle = 32.3; // eh, whatever you wannnt bro
var radians = angle * Math.PI / 180;
var vx = Math.cos(radians) * speed;
var vy = Math.sin(radians) * speed;
var x = 0;
var vx = 0;
var ax = 0.04;
requestAnimationFrame(function draw() {
vx += ax;
x += vx;
requestAnimationFrame(draw);
});
Live Example
var y = 0;
var vy = 0;
var ay = 0.04;
requestAnimationFrame(function draw() {
vy += ay;
y += vy;
requestAnimationFrame(draw);
});
Live Example
var x = 0;
var y = 0;
var vx = 0;
var vy = 0;
var angle = 45;
var force = 0.01;
requestAnimationFrame(function draw() {
var radians = angle * Math.PI / 180;
var ax = Math.cos(radians) * force;
var ay = Math.sin(radians) * force;
vx += ax;
vy += ay;
x += vx;
y += vy;
requestAnimationFrame(draw);
});
Live Example