示例#1
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));
            }
        }
示例#2
0
        static void CreateFill(SVGRectElement svgElement)
        {
            string name = svgElement.attrList.GetValue("id");

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