After going through the SVG specification, as well as resources like this and this, I'm finding it difficult to fully grasp how chaining transforms function.
Selected Relevant Quotations
By applying the transform attribute to an SVG element, that element essentially receives a duplicate of the current user coordinate system in use.
Additionally:
When transformations are chained together, the key thing to keep in mind is that similar to HTML element transformations, each transformation impacts the coordinate system after it has been transformed by preceding transformations.
In addition:
To illustrate, if you intend to apply a rotation followed by a translation to an element, the translation occurs based on the updated coordinate system, not the original non-rotated one.
Lastly:
The order of transformations holds significance. The order in which the transformation functions appear within the transform attribute determines the sequence in which they affect the shape.
Code Example
The first rectangle's current coordinate system undergoes scaling first and then rotation (pay attention to the sequence). Meanwhile, the second rectangle's current coordinate system experiences rotation prior to scaling.
svg {
border: 1px solid green;
}
<svg xmlns="http://www.w3.org/2000/svg">
<style>
rect#s1 {
fill: red;
transform: scale(2, 1) rotate(10deg);
}
</style>
<rect id="s1" x="" y="" width="100" height="100" />
</svg>
<svg xmlns="http://www.w3.org/2000/svg">
<style>
rect#s2 {
fill: blue;
transform: rotate(10deg) scale(2, 1);
}
</style>
<rect id="s2" x="" y="" width="100" height="100" />
</svg>
Question
We're aware that when linking transforms, a duplicate of the current coordinate system in use for that element is created, and then the transforms are executed according to the specified order.
When we have a scaled user coordinate system and add a rotation to it, the rectangle is essentially skewed (as noted by the changed angles). However, this effect is avoided when the two transforms are done inversely (rotate first, then scale).
I would greatly appreciate expert insights into exactly how the scaled current coordinate system is rotated. I am seeking to comprehend, from a technical perspective, why the skewing occurs in the initial rectangle.
Thank you.