Example #1
0
        static void CreateStroke(SVGLineElement svgElement)
        {
            string name = svgElement.attrList.GetValue("id");

            if (string.IsNullOrEmpty(name))
            {
                name = "Line Stroke ";
            }

            List <List <Vector2> > path = SVGSimplePath.CreateStroke(SVGGraphics.position_buffer, svgElement.paintable, ClosePathRule.NEVER);

            if (svgElement.paintable.clipPathList != null && svgElement.paintable.clipPathList.Count > 0)
            {
                path = SVGGeom.ClipPolygon(path, svgElement.paintable.clipPathList);
            }

            SVGGraphics.AddLayer(name, path, svgElement.paintable, svgElement.transformMatrix, true);

            /*
             * Mesh antialiasingMesh;
             * Mesh mesh = SVGLineUtils.TessellateStroke(path, SVGSimplePath.GetStrokeColor(svgElement.paintable), out antialiasingMesh);
             * if(mesh == null) return;
             * mesh.name = name;
             * SVGGraphics.AddLayer(new SVGMesh(mesh, svgElement.paintable.svgFill, svgElement.paintable.opacity));
             * if(antialiasingMesh != null)
             * {
             *  SVGFill svgFill = svgElement.paintable.svgFill.Clone();
             *  svgFill.blend = FILL_BLEND.ALPHA_BLENDED;
             *  SVGGraphics.AddLayer(new SVGMesh(antialiasingMesh, svgFill, svgElement.paintable.opacity));
             * }
             */
        }
Example #2
0
        static void CreateStroke(SVGLineElement svgElement)
        {
            string name = svgElement.attrList.GetValue("id");

            if (string.IsNullOrEmpty(name))
            {
                name = "Line Stroke ";
            }

            List <List <Vector2> > stroke = SVGSimplePath.CreateStroke(SVGGraphics.position_buffer, svgElement.paintable, ClosePathRule.NEVER);

            if (svgElement.paintable.clipPathList != null && svgElement.paintable.clipPathList.Count > 0)
            {
                stroke = SVGGeom.ClipPolygon(stroke, svgElement.paintable.clipPathList);
            }

            Mesh antialiasingMesh;
            Mesh mesh = SVGLineUtils.TessellateStroke(stroke, SVGSimplePath.GetStrokeColor(svgElement.paintable), out antialiasingMesh);

            if (mesh == null)
            {
                return;
            }
            mesh.name = name;
            SVGGraphics.AddMesh(new SVGMesh(mesh, svgElement.paintable.svgFill, svgElement.paintable.opacity));
            if (antialiasingMesh != null)
            {
                SVGFill svgFill = svgElement.paintable.svgFill.Clone();
                svgFill.blend = FILL_BLEND.ALPHA_BLENDED;
                SVGGraphics.AddMesh(new SVGMesh(antialiasingMesh, svgFill, svgElement.paintable.opacity));
            }
        }
Example #3
0
        public static List <Vector2> GetPath(SVGMatrix matrix, SVGLineElement svgElement)
        {
            List <Vector2> output = new List <Vector2>()
            {
                matrix.Transform(new Vector2(svgElement.x1.value, svgElement.y1.value)),
                matrix.Transform(new Vector2(svgElement.x2.value, svgElement.y2.value))
            };

            return(output);
        }
Example #4
0
        public static void Create(SVGLineElement svgElement)
        {
            if (svgElement.paintable.visibility != SVGVisibility.Visible || svgElement.paintable.display == SVGDisplay.None)
            {
                return;
            }

            SVGGraphics.position_buffer = GetPath(svgElement.transformMatrix, svgElement);

            if (svgElement.paintable.IsStroke())
            {
                CreateStroke(svgElement);
            }
        }
Example #5
0
        public static List <List <Vector2> > GetClipPath(SVGMatrix matrix, SVGLineElement svgElement)
        {
            List <Vector2> path = GetPath(matrix, svgElement);

            if (path == null || path.Count == 0)
            {
                return(null);
            }

            List <List <Vector2> > clipPath = new List <List <Vector2> >();

            List <StrokeSegment[]> segments = new List <StrokeSegment[]>()
            {
                SVGSimplePath.GetSegments(path)
            };
            List <List <Vector2> > strokePath = SVGLineUtils.StrokeShape(segments, svgElement.paintable.strokeWidth, Color.black, SVGSimplePath.GetStrokeLineJoin(svgElement.paintable.strokeLineJoin), SVGSimplePath.GetStrokeLineCap(svgElement.paintable.strokeLineCap), svgElement.paintable.miterLimit, svgElement.paintable.dashArray, svgElement.paintable.dashOffset, ClosePathRule.NEVER, SVGGraphics.roundQuality);

            if (strokePath != null && strokePath.Count > 0)
            {
                clipPath.AddRange(strokePath);
            }

            return(clipPath);
        }
Example #6
0
 public static List <Vector2> GetPath(SVGLineElement svgElement)
 {
     return(GetPath(SVGMatrix.Identity(), svgElement));
 }
Example #7
0
        private List <List <Vector2> > GetClipPath(Node node, SVGMatrix svgMatrix)
        {
            SVGTransformList transformList = new SVGTransformList();

            switch (node.name)
            {
            case SVGNodeName.Rect:
            {
                return(SVGRectElement.GetClipPath(svgMatrix, new SVGRectElement(node, transformList)));
            }

            case SVGNodeName.Line:
            {
                return(SVGLineElement.GetClipPath(svgMatrix, new SVGLineElement(node, transformList)));
            }

            case SVGNodeName.Circle:
            {
                return(SVGCircleElement.GetClipPath(svgMatrix, new SVGCircleElement(node, transformList)));
            }

            case SVGNodeName.Ellipse:
            {
                return(SVGEllipseElement.GetClipPath(svgMatrix, new SVGEllipseElement(node, transformList)));
            }

            case SVGNodeName.PolyLine:
            {
                return(SVGPolylineElement.GetClipPath(svgMatrix, new SVGPolylineElement(node, transformList)));
            }

            case SVGNodeName.Polygon:
            {
                return(SVGPolygonElement.GetClipPath(svgMatrix, new SVGPolygonElement(node, transformList)));
            }

            case SVGNodeName.Path:
            {
                return(SVGPathElement.GetClipPath(svgMatrix, new SVGPathElement(node, transformList)));
            }

            case SVGNodeName.Use:
            {
                string xlink = node.attributes.GetValue("xlink:href");
                if (!string.IsNullOrEmpty(xlink))
                {
                    if (xlink [0] == '#')
                    {
                        xlink = xlink.Remove(0, 1);
                    }

                    if (SVGParser._defs.ContainsKey(xlink))
                    {
                        Node definitionNode = SVGParser._defs [xlink];
                        if (definitionNode != null && definitionNode != node)
                        {
                            return(GetClipPath(definitionNode, svgMatrix));
                        }
                    }
                }
                break;
            }
            }

            return(null);
        }
 public static List<Vector2> GetPath(SVGMatrix matrix, SVGLineElement svgElement)
 {
     List<Vector2> output = new List<Vector2>(){
         matrix.Transform(new Vector2(svgElement.x1.value, svgElement.y1.value)),
         matrix.Transform(new Vector2(svgElement.x2.value, svgElement.y2.value))
     };
     return output;
 }
 public static List<Vector2> GetPath(SVGLineElement svgElement)
 {
     return GetPath(SVGMatrix.Identity(), svgElement);
 }
 static void CreateStroke(SVGLineElement svgElement)
 {
     string name = svgElement.attrList.GetValue("id");
     if (string.IsNullOrEmpty(name))
         name = "Line Stroke ";
     
     List<List<Vector2>> stroke = SVGSimplePath.CreateStroke(SVGGraphics.position_buffer, svgElement.paintable, ClosePathRule.NEVER);
     if(svgElement.paintable.clipPathList != null && svgElement.paintable.clipPathList.Count > 0)
     {
         stroke = SVGGeom.ClipPolygon(stroke, svgElement.paintable.clipPathList);
     }
     
     Mesh antialiasingMesh;
     Mesh mesh = SVGLineUtils.TessellateStroke(stroke, SVGSimplePath.GetStrokeColor(svgElement.paintable), out antialiasingMesh);
     if(mesh == null) return;            
     mesh.name = name;
     SVGGraphics.AddMesh(new SVGMesh(mesh, svgElement.paintable.svgFill, svgElement.paintable.opacity));
     if(antialiasingMesh != null)
     {
         SVGFill svgFill = svgElement.paintable.svgFill.Clone();
         svgFill.blend = FILL_BLEND.ALPHA_BLENDED;
         SVGGraphics.AddMesh(new SVGMesh(antialiasingMesh, svgFill, svgElement.paintable.opacity));
     }
 }
        public static void Create(SVGLineElement svgElement)
        {
            if(svgElement.paintable.visibility != SVGVisibility.Visible || svgElement.paintable.display == SVGDisplay.None)
                return;

            SVGGraphics.position_buffer = GetPath(svgElement.transformMatrix, svgElement);

            if(svgElement.paintable.IsStroke())
                CreateStroke(svgElement);
        }
        public static List<List<Vector2>> GetClipPath(SVGMatrix matrix, SVGLineElement svgElement)
        {
            List<Vector2> path = GetPath(matrix, svgElement);
            if(path == null || path.Count == 0) return null;
            
            List<List<Vector2>> clipPath = new List<List<Vector2>>();

            List<StrokeSegment[]> segments = new List<StrokeSegment[]>(){SVGSimplePath.GetSegments(path)};
            List<List<Vector2>> strokePath = SVGLineUtils.StrokeShape(segments, svgElement.paintable.strokeWidth, Color.black, SVGSimplePath.GetStrokeLineJoin(svgElement.paintable.strokeLineJoin), SVGSimplePath.GetStrokeLineCap(svgElement.paintable.strokeLineCap), svgElement.paintable.miterLimit, svgElement.paintable.dashArray, svgElement.paintable.dashOffset, ClosePathRule.NEVER, SVGGraphics.roundQuality);
            if(strokePath != null && strokePath.Count > 0) clipPath.AddRange(strokePath);
            
            return clipPath;
        }