Beispiel #1
0
        /// <summary>
        /// Set the clipping of the group
        /// </summary>
        public static void SetClipPath(GraphicGroup group,
                                       Matrix currentTransformationMatrix,
                                       CssStyleCascade cssStyleCascade,
                                       Dictionary <string, XElement> globalDefinitions)
        {
            var clipPath = cssStyleCascade.GetPropertyFromTop("clip-path");

            if (string.IsNullOrEmpty(clipPath))
            {
                return;
            }

            if (!clipPath.StartsWith("url(", StringComparison.OrdinalIgnoreCase))
            {
                return;
            }

            int endUri = clipPath.IndexOf(")", StringComparison.OrdinalIgnoreCase);
            var uri    = clipPath.Substring(4, endUri - 4);

            uri = uri.Trim();
            var id = uri.Substring(1);

            if (!globalDefinitions.ContainsKey(id))
            {
                return;
            }

            var clipElem = globalDefinitions[id];

            // richt now we support only a single path for the clip geometry
            var shapeElement = clipElem.Elements().First();

            if (shapeElement == null)
            {
                return;
            }

            var clipGeometry = GeometryParser.Parse(shapeElement, currentTransformationMatrix);

            clipGeometry.FillRule = GraphicFillRule.NoneZero;

            var clipRule = cssStyleCascade.GetProperty("clip-rule");

            if (!string.IsNullOrEmpty(clipRule))
            {
                switch (clipRule)
                {
                case "evenodd":
                    clipGeometry.FillRule = GraphicFillRule.EvenOdd;
                    break;

                case "nonzero":
                    clipGeometry.FillRule = GraphicFillRule.NoneZero;
                    break;
                }
            }

            group.Clip = clipGeometry;
        }
Beispiel #2
0
 /// <summary>
 /// Constructor
 /// </summary>
 public BrushParser(XNamespace svgNamespace,
                    CssStyleCascade cssStyleCascade,
                    Dictionary <string, XElement> globalDefinitions,
                    DoubleParser doubleParser)
 {
     this.svgNamespace      = svgNamespace;
     this.cssStyleCascade   = cssStyleCascade;
     this.globalDefinitions = globalDefinitions;
     this.doubleParser      = doubleParser;
 }
Beispiel #3
0
 /// <summary>
 /// Constructor
 /// </summary>
 public Clipping(CssStyleCascade cssStyleCascade,
                 Dictionary <string, XElement> globalDefinitions,
                 GeometryParser geometryParser,
                 GeometryTextParser textParser)
 {
     this.cssStyleCascade   = cssStyleCascade;
     this.globalDefinitions = globalDefinitions;
     this.geometryParser    = geometryParser;
     this.textParser        = textParser;
 }
Beispiel #4
0
 /// <summary>
 /// Constructor
 /// </summary>
 public TextParser(CssStyleCascade cssStyleCascade,
                   DoubleParser doubleParser,
                   BrushParser brushParser,
                   Clipping clipping)
     : base(cssStyleCascade, doubleParser)
 {
     this.cssStyleCascade = cssStyleCascade;
     this.doubleParser    = doubleParser;
     this.brushParser     = brushParser;
     this.clipping        = clipping;
 }
Beispiel #5
0
 /// <summary>
 /// Constructor
 /// </summary>
 public DoubleParser(CssStyleCascade cssStyleCascade)
 {
     this.cssStyleCascade = cssStyleCascade;
 }
Beispiel #6
0
        /// <summary>
        /// Tests whether a clip path is set
        /// </summary>
        public static bool IsClipPathSet(CssStyleCascade cssStyleCascade)
        {
            var clipPath = cssStyleCascade.GetPropertyFromTop("clip-path");

            return(!string.IsNullOrEmpty(clipPath));
        }