Create Graphical Content in the Browser with SVG
Rasterized
Vectors
image Sbyrnes321
Declarative language to describe graphical content using XML
<circle cx="100" cy="100" r="60">
Very few basic graphical shapes to create larger compositions.
<circle> <ellipse> <image>
<line> <path> <polygon>
<polyline> <rect> <text>
Using transformation matrices creates a scene hierarchy.
<!doctype html>
<img src="image.svg">
IE 9
Chrome 4
FF 4
Safari 3.2
<!doctype html>
<svg>
<circle cx="100" cy="100" r="60">
</svg>
IE 9
Chrome 7
FF 4
Safari 5.1
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:ev="http://www.w3.org/2001/xml-events"
version="1.1" baseProfile="full"
width="800mm" height="600mm"
viewBox="-400 -300 800 600">
</svg>
<svg width="100%" height="100%">
<circle cx="50%" cy="50%" r="60"></circle>
</svg>
Structure in SVG, style in CSS and add behaviour with JavaScript
fill | Fill colour of shapes |
stroke | Colour of shape outlines |
stroke-width | The width of shape outlines |
stroke-dasharray | Specify a dash pattern for the strokes |
stroke-dashoffset | An offset for the dash pattern |
stroke-linecap | How line caps should be rendered |
stroke-linejoin | How lines are joined together |
shape-rendering | Useful if you need crispy edges |
<circle class="dot"
cx="50%" cy="50%" r="60"></circle>
const dot = document.querySelector('.dot');
dot.addEventListener('click', () => {
alert('I was clicked!');
});
I'm deathly afraid of mice!