Exemple #1
0
        public static Matrix GetTransformMatrix(SvgElement element)
        {
            ISvgTransformable transElm = element as ISvgTransformable;

            if (transElm == null)
            {
                return(Matrix.Identity);
            }

            SvgTransformList svgTList     = (SvgTransformList)transElm.Transform.AnimVal;
            SvgTransform     svgTransform = (SvgTransform)svgTList.Consolidate();
            SvgMatrix        svgMatrix    = ((SvgTransformList)transElm.Transform.AnimVal).TotalMatrix;

            return(new Matrix(svgMatrix.A, svgMatrix.B, svgMatrix.C,
                              svgMatrix.D, svgMatrix.E, svgMatrix.F));
        }
Exemple #2
0
        public static Matrix GetTransformMatrix(SvgElement element, TransformGroup transform)
        {
            ISvgTransformable transElm = element as ISvgTransformable;

            if (transElm == null)
            {
                return(Matrix.Identity);
            }

            SvgTransformList svgTList     = (SvgTransformList)transElm.Transform.AnimVal;
            SvgTransform     svgTransform = (SvgTransform)svgTList.Consolidate();
            SvgMatrix        svgMatrix    = ((SvgTransformList)transElm.Transform.AnimVal).TotalMatrix;

            var matrix = new Matrix(svgMatrix.A, svgMatrix.B, svgMatrix.C,
                                    svgMatrix.D, svgMatrix.E, svgMatrix.F);

            if (!matrix.IsIdentity)
            {
                transform.Children.Add(new MatrixTransform(matrix));
            }

            return(matrix);
        }