Esempio n. 1
0
        /// <summary>
        /// Get the opacity value for the specified property
        /// </summary>
        private double GetAlpha(string name)
        {
            var    alpha1 = cssStyleCascade.GetDoubleFromTop($"{name}-opacity", 1);
            double alpha2 = cssStyleCascade.GetDoubleFromTop("opacity", 1);
            var    alpha  = alpha1 * alpha2;

            return(alpha);
        }
Esempio n. 2
0
        /// <summary>
        /// Parse all graphic elements
        /// </summary>
        private GraphicGroup ParseGroup(XNamespace ns, XElement groupElement, Matrix matrix)
        {
            var group = new GraphicGroup();

            cssStyleCascade.PushStyles(groupElement);

            Matrix currentTransformationMatrix = matrix;

            var transform = cssStyleCascade.GetPropertyFromTop("transform");

            if (!string.IsNullOrEmpty(transform))
            {
                var transformMatrix = TransformMatrixParser.GetTransformMatrix(transform);
                currentTransformationMatrix = transformMatrix * currentTransformationMatrix;
            }

            Clipping.SetClipPath(group, currentTransformationMatrix, cssStyleCascade, globalDefinitions);
            group.Opacity = cssStyleCascade.GetDoubleFromTop("opacity", 1);

            var shapeParser = new ShapeParser();

            foreach (var element in groupElement.Elements())
            {
                switch (element.Name.LocalName)
                {
                case "defs":
                case "style":
                    // already read, ignore
                    break;

                case "g":
                case "svg":
                {
                    var childGroup = ParseGroup(ns, element, currentTransformationMatrix);
                    group.Childreen.Add(childGroup);
                    break;
                }

                default:
                {
                    var shape = shapeParser.Parse(element, ns, currentTransformationMatrix, cssStyleCascade, globalDefinitions);

                    if (shape != null)
                    {
                        group.Childreen.Add(shape);
                    }
                    break;
                }
                }
            }

            cssStyleCascade.Pop();

            return(group);
        }