SVG Flashcards
SVG
= Scalable Vector Graphics
An XML-based image format that describes graphics using geometrical attributes.
What are SVG primitives?
Individual XML elements described using tags and attributes.
SVG Stacking
The code order determines which element will appear over the other. Preceding siblings are always overlapped by siblings declared after them.
z-index doesn’t work in SVG.
SVG defs
A header containing SVG elements that will not be displayed until referenced by a ‘use’ element.
Filters, clippings, gradients, masks and reusable shapes are usually declared here.
Each of the elements within must have an id in order to be referencable.
SVG use
An SVG tag used for displaying one of the elements declared in the header.
The element is referenced by id using the xlink notation:
use xlink:href="#myShape" /
Matrix transforms
Used to scale(), translate(), skew(), or rotate() any shape or group or the entire SVG viewport.
These commands are used inside of the transform
XML attribute, and their order is significant.
viewBox attribute values
viewBox=“x y w h”
x, y - the centre of coordinates
Gradients
Linear gradients are created perpendicular to a line so they require the same attributes as the line element. Radial gradients use circle attributes.
Gradients should have at least one child stop with:
- a non-zero ‘offset’ and
- stop-color different than black
Gradients are usually declared in the defs header, and used as a fill or stroke value.
Clip mask
Clip mask is created with any element declared inside the clipPath element.
This is usually done in the defs header.