Simple canvas example

by erickzanardo

HTML

<canvas id="mycanvas" width="300" height="300">

CSS

canvas {
    border: 1px solid #000;
}

JavaScript

var canvas = document.getElementById('mycanvas');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#000';
ctx.fillRect(125, 125, 50, 50);