setup

c = document.createElement('canvas');
ctx = c.getContext('2d');

sizing

never use CSS to size a canvas

always size the canvas directly, defining the number of pixels

they are unitless. just integer values

 c.width = 500;
 c.height = 500;

a line

ctx.strokeStyle = '#ddd';
ctx.beginPath();
ctx.moveTo(x-dx, y-dy);
ctx.lineTo(x, y);
ctx.stroke();

a circle

ctx.fillStyle = '#fc09';
ctx.beginPath();
ctx.arc(x, y, rx, 0, 2*Math.PI);
ctx.fill();