SVG studies

initial user coordinate system

SVG viewPort

view port coordinate system equals user coordinate system

using the viewBox attr user coordinate system can be modified

viewBox can be smaller than viewPort

SVG viewPort

SVG viewBox

viewBox can be bigger than viewPort

SVG viewPort

SVG viewBox

viewBox can be fully or partially visible

SVG viewPort

SVG viewBox

viewBox can be fully or partially visible

SVG viewPort

SVG viewBox

viewBox

any descendant of the svg will be positioned and sized in the new user coordinate system

SVG viewPort

SVG viewBox

SVG viewPort

SVG viewBox

viewPort width, height represents the user coordinate system before viewBox transformation is applied
1 unit in the user coordiante system equal 0.5 units in the viewPort coordinate system

The preserveAspectRatio attribute

preserveAspectRatio=defer? align meetOrSlice?

SVG viewPort

SVG viewBox

by default it preserves aspect ratio

SVG viewPort

SVG viewBox

preserveAspectRatio="none"

if is set to none the graphic will be scaled inside the viewPort without mantaining the aspect ratio

Transform

the element’s new current coordinate system is transformed by the transformation functions specified inside the transform attribute

SVG viewPort

rec 1

rec 2

rec 3

Scale

The scaled SVG’s element’s position changes inside the viewport when it is scaled

SVG viewPort

rec 1

rec 2

rec 3