예제 #1
0
        public static List <Vector2> GetPath(SVGMatrix matrix, SVGEllipseElement svgElement)
        {
            List <Vector2> output = Ellipse(svgElement.cx.value, svgElement.cy.value, svgElement.rx.value, svgElement.ry.value, matrix);

            output.Add(output[0]);
            return(output);
        }
예제 #2
0
        static void CreateStroke(SVGEllipseElement svgElement)
        {
            string name = svgElement.attrList.GetValue("id");

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

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

            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));
            }
        }
예제 #3
0
        public static List <List <Vector2> > GetClipPath(SVGMatrix matrix, SVGEllipseElement svgElement)
        {
            List <Vector2> path = GetPath(matrix, svgElement);

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

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

            if (svgElement.paintable.IsFill())
            {
                clipPath.Add(path);
            }

            if (svgElement.paintable.IsStroke())
            {
                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.ALWAYS, SVGGraphics.roundQuality);
                if (strokePath != null && strokePath.Count > 0)
                {
                    clipPath.AddRange(strokePath);
                }
            }

            return(clipPath);
        }
예제 #4
0
        static void CreateStroke(SVGEllipseElement svgElement)
        {
            string name = svgElement.attrList.GetValue("id");

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

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

            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));
             * }
             */
        }
예제 #5
0
        public static void Create(SVGEllipseElement svgElement)
        {
            if (svgElement.paintable.visibility != SVGVisibility.Visible || svgElement.paintable.display == SVGDisplay.None)
            {
                return;
            }

            SVGGraphics.position_buffer = GetPath(svgElement.transformMatrix, svgElement);
            if (svgElement.paintable.IsFill())
            {
                CreateFill(svgElement);
            }
            if (svgElement.paintable.IsStroke())
            {
                CreateStroke(svgElement);
            }
        }
예제 #6
0
        static void CreateFill(SVGEllipseElement svgElement)
        {
            string name = svgElement.attrList.GetValue("id");

            if (string.IsNullOrEmpty(name))
            {
                name = "Ellipse Fill";
            }

            List <List <Vector2> > path;

            if (svgElement.paintable.clipPathList != null && svgElement.paintable.clipPathList.Count > 0)
            {
                path = SVGGeom.ClipPolygon(new List <List <Vector2> >()
                {
                    SVGGraphics.position_buffer
                }, svgElement.paintable.clipPathList);
            }
            else
            {
                path = new List <List <Vector2> >()
                {
                    SVGGraphics.position_buffer
                };
            }

            Mesh antialiasingMesh;
            Mesh mesh = SVGSimplePath.CreatePolygon(path, svgElement.paintable, svgElement.transformMatrix, 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 List<Vector2> GetPath(SVGMatrix matrix, SVGEllipseElement svgElement)
 {
     List<Vector2> output = Ellipse(svgElement.cx.value, svgElement.cy.value, svgElement.rx.value, svgElement.ry.value, matrix);
     output.Add(output[0]);            
     return output;
 }
 public static List<Vector2> GetPath(SVGEllipseElement svgElement)
 {
     return GetPath(SVGMatrix.Identity(), svgElement);
 }
 static void CreateStroke(SVGEllipseElement svgElement)
 {
     string name = svgElement.attrList.GetValue("id");
     if (string.IsNullOrEmpty(name))
         name = "Ellipse Stroke ";
     
     List<List<Vector2>> stroke = SVGSimplePath.CreateStroke(SVGGraphics.position_buffer, svgElement.paintable, ClosePathRule.ALWAYS);
     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));
     }
 }
 static void CreateFill(SVGEllipseElement svgElement)
 {
     string name = svgElement.attrList.GetValue("id");
     if (string.IsNullOrEmpty(name))
         name = "Ellipse Fill";
     
     List<List<Vector2>> path;
     if(svgElement.paintable.clipPathList != null && svgElement.paintable.clipPathList.Count > 0)
     {
         path = SVGGeom.ClipPolygon(new List<List<Vector2>>(){SVGGraphics.position_buffer}, svgElement.paintable.clipPathList);
     } else {
         path = new List<List<Vector2>>(){SVGGraphics.position_buffer};
     }
     
     Mesh antialiasingMesh;
     Mesh mesh = SVGSimplePath.CreatePolygon(path, svgElement.paintable, svgElement.transformMatrix, 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(SVGEllipseElement svgElement)
        {        
            if(svgElement.paintable.visibility != SVGVisibility.Visible || svgElement.paintable.display == SVGDisplay.None)
                return;

            SVGGraphics.position_buffer = GetPath(svgElement.transformMatrix, svgElement);
            if(svgElement.paintable.IsFill())
                CreateFill(svgElement);
            if(svgElement.paintable.IsStroke())
                CreateStroke(svgElement);
        }
 public static List<List<Vector2>> GetClipPath(SVGMatrix matrix, SVGEllipseElement svgElement)
 {
     List<Vector2> path = GetPath(matrix, svgElement);
     if(path == null || path.Count == 0) return null;
     
     List<List<Vector2>> clipPath = new List<List<Vector2>>();
     if(svgElement.paintable.IsFill())
     {
         clipPath.Add(path);
     }
     
     if(svgElement.paintable.IsStroke())
     {
         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.ALWAYS, SVGGraphics.roundQuality);
         if(strokePath != null && strokePath.Count > 0) clipPath.AddRange(strokePath);
     }
     
     return clipPath;
 }
예제 #13
0
 public static List <Vector2> GetPath(SVGEllipseElement svgElement)
 {
     return(GetPath(SVGMatrix.Identity(), svgElement));
 }
예제 #14
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);
        }