I'm using AS3 (Flash) to read SVG files and display them. The problem is correctly displaying a linear/radial gradient.
Following is an example of a simple linear gradient from Red to Blue, in SVG.
<linearGradient id="GRADIENT_1" gradientUnits="userSpaceOnUse"
x1="107.3938" y1="515.5684" x2="105.2488" y2="428.8614"
gradientTransform="matrix(0.9988 0.0485 0.0485 -0.9988 0.8489 711.6634)">
<stop offset="0" style="stop-color:red"/>
<stop offset="1" style="stop-color:blue"/>
</linearGradient>
I've been able to read the colors from the gradient (stop's styles), and their spacing through the gradient (stop's offsets).
Okay, so now I've got a nice gradient with the right colors and right amount of space between them, but with NO rotation or scale, and its off position!.
The answer is to feed a Matrix into Flash's gradient function.
The Matrix supplied by SVG, gradientTransform="matrix(a,b,c,d,e,f)" appears to be effectively useless since when you feed that matrix into Flash's beginGradientFill() function, it displays the gradient stretched over the shape so much so only the center color of the gradient is visible, like a solid fill.
When I say "2 gradient points", I'm referring to x1,y1 and x2,y2, which are mostly telling you where on the shape does the gradient start & end.
There's the Matrix.createGradientBox() function which creates a matrix for use with gradients, but the parameters are very different than what SVG gives me. It wants:
(Look at the SVG snippet above, that's all the data I have describing the gradient)
i.e.
x1, y1, x2, y2 represent values in the coordinate system that results from taking the current user coordinate system in place for the element referencing the gradient (via a 'fill' or 'stroke' property) at the time when the gradient element is referenced, and then applying the transform specified by attribute gradientTransform.
via W3C Docs.