Canvas is an awesome HTML tag that we can use through Javascript to make charts, graphs, games, and almost anything you can dream of.
- Shapes: http://codepen.io/sinthetyc/pen/qAlnj
- Paths: http://codepen.io/soulwire/pen/HAGCg
- Curves: http://codepen.io/stuffit/pen/agBqI
- Draw pixels: http://jsdo.it/notch/dB1E
- Mix with HTML: http://codepen.io/chribbe/pen/KkGrF
Crack open http://codepen.io and sign up for an account.
In HTML, drop in:
<canvas id="canvas1" width="300" height="200"></canvas>
In JS, you'll need:
var canvas = document.getElementById('canvas1');
var ctx = canvas.getContext('2d');
Now you've got the "context" object in JavaScript, which we can use to paint on the canvas. Awesome!
Try out drawing some rectangles:
ctx.fillStyle = "rgb(200,200,0)";
ctx.fillRect(10, 10, 55, 50);
ctx.fillStyle = "rgba(0, 0, 200, 0.5)";
ctx.fillRect(30, 30, 55, 50);