Canvas
Getting the context
var canvas = document.getElementById('c')
var c = canvas.getContext('2d')Basic drawing
// x = 10, y = 20, width = 200, height = 100
c.fillStyle = '#ff0000'
c.strokeStyle = '#ff00ff'c.lineWidth = 5
c.lineCap = 'round'c.fillRect(10, 20, 200, 100)c.stroke()
c.fill()Saving and restoring
c.save()c.restore()Animation
onframe: function() {
c.clearRect(0, 0, w, h)
}Transformations
Image drawing
Colors, styles shadows
Gradients
Drawing
More resources
Last updated