w3c/svgwg

Computing the equivalent transform of an SVG viewport

letochagone opened this issue · 0 comments

8.2. Computing the equivalent transform of an SVG viewport
I'm trying to understand the viewBox mechanism, by taking a very simple example and applying the process described in the chapter above.
I asked the question stackoverflow illustrating it with an example.

it seems to me that this page is more dedicated to the errors encountered, but I still try to ask my question: where did I go wrong in computing the equivalent ?

I think this chapter 8.2 is missing an example to help with understanding.

( I'm terribly slow to understand but maybe I'm not the only one :) )

UPDATE : I found the cause of my error

the transform attribute should be put in the circle element and not in the svg element

<svg width="100" height="100" > <circle r="50" transform="translate(25 0) scale(1 1)" /> </svg>

<svg width="100" height="100" viewBox="0 0 50 100"> <circle r="50" /> </svg>

https://www.w3.org/TR/SVG/coords.html#ComputingAViewportsTransform
This process converts the min-x, min-y, width and height values of a viewBox attribute, the position and size of the element on which the viewBox attribute is defined, and the value of the preserveAspectRatio attribute on that element into a translation and a scale that is applied to content contained by the element.

I would like to suggest that an example be added in the specification

in fact, there are many sites on svg, which talk about the viewBox, but only on examples. I think examples are fundamental when they follow the theory, but not when (like all these sites) you have to guess the theory from them

merci !