Canvas example
Example of drawing a rectangle and circle using canvas.
by justin_barber_arvig
HTML
<canvas width="640" height="480"></canvas>
JavaScript
const canvas = document.querySelector('canvas');
const ctx = canvas.getContext('2d');
// global colors
ctx.strokeStyle = 'white';
ctx.fillStyle = 'skyblue';
// draw rectangle (x position, y position, width, height)
ctx.fillRect(0, 0, 50, 50);
ctx.fillRect(90, 90, 50, 50);
// draw circle (x, y, radius, start, end, antiClockwise)
ctx.beginPath();
ctx.arc(100, 200, 25, 0, Math.PI * 2, false);
ctx.fill();
ctx.stroke();