Exemplo n.º 1
0
        static void CreateStroke(SVGPolygonElement svgElement)
        {
            string name = svgElement.attrList.GetValue("id");

            if (string.IsNullOrEmpty(name))
            {
                name = "Polygon 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(stroke, 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));
             * }
             */
        }
Exemplo n.º 2
0
        static void CreateStroke(SVGRectElement svgElement)
        {
            string name = svgElement.attrList.GetValue("id");

            if (string.IsNullOrEmpty(name))
            {
                name = "Rectangle 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));
            }
        }
Exemplo n.º 3
0
        static void CreateFill(SVGPolygonElement svgElement)
        {
            string name = svgElement.attrList.GetValue("id");

            if (string.IsNullOrEmpty(name))
            {
                name = "Polygon 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
                };
            }

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

            /*
             * Mesh antialiasingMesh;
             * Mesh mesh = SVGSimplePath.CreatePolygon(path, svgElement.paintable, svgElement.transformMatrix, 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));
             * }
             */
        }
Exemplo n.º 4
0
        static void CreateFill(SVGPathElement svgElement)
        {
            string name = svgElement.attrList.GetValue("id");

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

            List <List <Vector2> > path;

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

            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));
            }
        }
Exemplo n.º 5
0
 public new void Render()
 {
     if (!string.IsNullOrEmpty(name))
     {
         CreateLayer();
     }
     for (int i = 0; i < elementList.Count; i++)
     {
         ISVGDrawable temp = elementList[i] as ISVGDrawable;
         if (temp != null)
         {
             temp.Render();
             SVGGraphics.currentGroup = this;
         }
     }
     if (SVGGraphics.currentGroup == this)
     {
         SVGGraphics.currentGroup = null;
     }
     if (_layer.shapes != null && _layer.shapes.Length > 0)
     {
         SVGGraphics.AddLayer(_layer);
     }
 }
Exemplo n.º 6
0
 public void Render()
 {
     SVGGraphics.Create(this, "Path Element", ClosePathRule.AUTO);
 }
Exemplo n.º 7
0
 public void Render()
 {
     SVGGraphics.Create(this, "Circle Element");
 }
Exemplo n.º 8
0
 public void Render()
 {
     SVGGraphics.Create(this, "Polygon Element");
 }
Exemplo n.º 9
0
 public void Render()
 {
     SVGGraphics.Create(this, "Line Element", ClosePathRule.NEVER);
 }
Exemplo n.º 10
0
        public static void Create(ISVGElement svgElement, string defaultName = null, ClosePathRule closePathRule = ClosePathRule.ALWAYS)
        {
            if (svgElement == null)
            {
                return;
            }
            if (svgElement.paintable.visibility != SVGVisibility.Visible || svgElement.paintable.display == SVGDisplay.None)
            {
                return;
            }

            List <SVGShape>        shapes     = new List <SVGShape>();
            List <List <Vector2> > inputPaths = svgElement.GetPath();

            if (inputPaths.Count == 1)
            {
                if (svgElement.paintable.IsFill())
                {
                    List <List <Vector2> > path = inputPaths;
                    if (svgElement.paintable.clipPathList != null && svgElement.paintable.clipPathList.Count > 0)
                    {
                        path = SVGGeom.ClipPolygon(new List <List <Vector2> >()
                        {
                            inputPaths[0]
                        }, svgElement.paintable.clipPathList);
                    }

                    SVGShape[] addShapes = SVGGraphics.GetShapes(path, svgElement.paintable, svgElement.transformMatrix);
                    if (addShapes != null && addShapes.Length > 0)
                    {
                        shapes.AddRange(addShapes);
                    }
                }
                if (svgElement.paintable.IsStroke())
                {
                    List <List <Vector2> > path = SVGSimplePath.CreateStroke(inputPaths[0], svgElement.paintable, closePathRule);
                    if (svgElement.paintable.clipPathList != null && svgElement.paintable.clipPathList.Count > 0)
                    {
                        path = SVGGeom.ClipPolygon(path, svgElement.paintable.clipPathList);
                    }

                    SVGShape[] addShapes = SVGGraphics.GetShapes(path, svgElement.paintable, svgElement.transformMatrix, true);
                    if (addShapes != null && addShapes.Length > 0)
                    {
                        shapes.AddRange(addShapes);
                    }
                }
            }
            else
            {
                if (svgElement.paintable.IsFill())
                {
                    List <List <Vector2> > fillPaths = inputPaths;
                    if (svgElement.paintable.clipPathList != null && svgElement.paintable.clipPathList.Count > 0)
                    {
                        fillPaths = SVGGeom.ClipPolygon(inputPaths, svgElement.paintable.clipPathList);
                    }

                    SVGShape[] addShapes = SVGGraphics.GetShapes(fillPaths, svgElement.paintable, svgElement.transformMatrix);
                    if (addShapes != null && addShapes.Length > 0)
                    {
                        shapes.AddRange(addShapes);
                    }
                }
                if (svgElement.paintable.IsStroke())
                {
                    List <List <Vector2> > strokePath = SVGSimplePath.CreateStroke(inputPaths, svgElement.paintable, closePathRule);
                    if (svgElement.paintable.clipPathList != null && svgElement.paintable.clipPathList.Count > 0)
                    {
                        strokePath = SVGGeom.ClipPolygon(strokePath, svgElement.paintable.clipPathList);
                    }

                    SVGShape[] addShapes = SVGGraphics.GetShapes(strokePath, svgElement.paintable, svgElement.transformMatrix, true);
                    if (addShapes != null && addShapes.Length > 0)
                    {
                        shapes.AddRange(addShapes);
                    }
                }
            }

            if (shapes.Count > 0)
            {
                string name = svgElement.attrList.GetValue("id");
                if (string.IsNullOrEmpty(name))
                {
                    name = defaultName;
                }
                SVGLayer layer = new SVGLayer();
                layer.shapes = shapes.ToArray();
                layer.name   = name;
                SVGGraphics.AddLayer(layer);
            }
        }
Exemplo n.º 11
0
 public void Render()
 {
     SVGGraphics.Create(this, "Ellipse Element");
 }
Exemplo n.º 12
0
 public void Render()
 {
     SVGGraphics.Create(this, "Rectangle Element");
 }