SVG Flashcards
How can you create simple shapes that you then re-use in an SVG drawing?
use the defs element to define illustrations that are inside of g tags with IDs. Then use the ‘use’ element and reference the ID.
Draw a 2px wide white line from 0,0 to 100,100
line x1=”0” y1=”0” x2=”100” y2=”100” stroke=”white” stroke-width=”2”
If the viewBox is smaller than the viewport, what happens to an image?
It will get larger. It will be rendered into the viewbox; then the viewbox will scale up to fill the viewport.
If the viewBox is larger than the viewport, what will happen to an image?
It will get smaller. It will render into the viewbox; then the viewbox will scale down to fit in the viewport.
How can you manage how images render when viewBox and viewport aren’t the same?
Use preserveAspectRatio = Align takes things like “xMaxYMin”; meet/slice is like background-size contain or cover.
What is the viewport?
It’s the area where svg is visible. In concrete terms, it’s managed by width and height. E.g. svg width=”800” …