Canvas & SVG
Hyper Text Markup Language
Academic, Scientific
Documents & Publications
Operating System (apis)
Browser (apis)
Hardware (is)
HTML
JavaScript
CSS
Browser Plugins
Flash
Operating System
Browser
Hardware
HTML
JavaScript
CSS
+ Graphics APIs
Graphics defined by pixel coordinates and color values
photographs, video, image manipulation, drawing,
jpeg, gif, png, bmp
Graphics defined by shapes, paths
Figures, charts, illustrations
svg, ai, eps, pdf
Canvas API
Images
Video
SVG
Fonts
<canvas></canvas>
<canvas id="canvas"></canvas>
<canvas id="canvas">No Canvas Support!</canvas>
Canvas Under the Hood
A visual representation of an array of pixel values
[255, 0, 0, 255]
R
G
B
A
1
1
Canvas Under the Hood
A visual representation of an array of pixel values
[255,0,0,255,0,255,0,255,0,0,255,255,0,0,0,255]
2
2
Red
Black
Blue
Green
const canvas = document.getElementById('canvas');
const context = canvas.getContext('2d');
Canvas
Context
fillRect()
lineTo()
stokeArc()
drawImage()
rotate()
fillText()
translate()
rect()
fill()
ellipse()
bezierCurve()
addHitRegion()
arc()
arcTo()
asyncDrawXULElement()
beginPath()
bezierCurveTo()
clearHitRegions()
clearRect()
clip()
closePath()
createImageData()
createLinearGradient()
createPattern()
createRadialGradient()
drawFocusIfNeeded()
drawImage()
drawWidgetAsOnScreen()
drawWindow()
ellipse()
fill()
fillRect()
fillText()
getImageData()
getLineDash()
isPointInPath()
....
Clear?
(Watermarking images example)
<svg width="100" height="100">
<svg width="200" height="200" viewBox="0 0 100 100">
<svg width="200" height="250">
<rect x="10" y="10" width="30" height="30"/>
<circle cx="25" cy="75" r="20"/>
</svg>
https://developer.mozilla.org/en-US/docs/Web/SVG/Tutorial/SVG_and_CSS