// Start is called before the first frame update
    void Start()
    {
        var mesh = GetComponent <SVGMesh>();
        var svg  = new SVGData();

        svg.Path("M256.5,31.2L13.7,451.7h485.6L256.5,31.2z M232.9,180L336,410.7H129.8L232.9,180z");
        mesh.Fill(svg);
    }
Esempio n. 2
0
        public static void SvgPath(string svgPathString)
        {
            var     origin  = ApiManager.Instance.BrushPosition;
            SVGData svgData = new SVGData();

            svgData.Path(svgPathString);
            SVGPolyline svgPolyline = new SVGPolyline();

            svgPolyline.Fill(svgData);
            DrawStrokes.MultiPath2dToStrokes(svgPolyline.Polyline, origin, 0.01f, true);
        }
        public void GetContours()
        {
            var svg = new SVGData();

            svg.Path(Fixtures.TwitterBirdPathCurve);

            var mesh = new MeshData();

            BezierToVertex.Scale = 10f;
            BezierToVertex.GetContours(svg, mesh);

            Assert.That(mesh.Vertices, Is.EqualTo(Fixtures.TwitterBirdPathCurveVertices).Using(Vector3EqualityComparer.Instance));
            Assert.That(mesh.Edges, Is.EqualTo(Fixtures.TwitterBirdPathCurveEdges));
        }
Esempio n. 4
0
    internal void ParseSVGToPath(string urlToFile)
    {
        if (string.IsNullOrEmpty(urlToFile))
        {
            return;
        }
        svgPaths.Clear();
        svgClassesToShow.Clear();
        svgParser parser = new svgParser();
        SvgClass  svg    = parser.Parse(urlToFile);

        foreach (SvgPath svgPath in svg.SvgPath.Where(x => x.D.Length > 10))
        {
            SVG = new SVGData();
            SVG.Path(svgPath.D);
            Mesh.Fill(SVG);
            List <Coords> coordsForId = new List <Coords>();
            float         minX        = Mesh.MeshData.Vertices.Min(x => x.x);
            float         minY        = Mesh.MeshData.Vertices.Min(y => y.y);
            float         maxX        = Mesh.MeshData.Vertices.Max(x => x.x);
            float         maxY        = Mesh.MeshData.Vertices.Max(y => y.y);
            float         midX        = (maxX - minX);
            float         midY        = (maxY - minY);

            for (int i = 0; i < Mesh.MeshData.Vertices.Count; i++)
            {
                Coords coord = new Coords {
                    X = Mesh.MeshData.Vertices[i].x - midX, Y = Mesh.MeshData.Vertices[i].y - midY, Z = Mesh.MeshData.Vertices[i].z
                };
                coordsForId.Add(coord);
            }

            if (svgPath.Class == null)
            {
                svgPath.Class = svgPath.Id;
            }
            else if (svgPath.Class.Length == 0)
            {
                svgPath.Class = svgPath.Id;
            }
            if (string.IsNullOrEmpty(svgPath.Class))
            {
                svgPath.Class = (svgClassesToShow.Count + 1).ToString();
            }
            CreateSVGClassObject(svgPath.Class);
            svgPaths.Add(svgPath.Class, coordsForId);
            svgClassesToShow.Add(svgPath.Class);
        }
    }
Esempio n. 5
0
 void Start()
 {
     SVG = new SVGData();
     SVG.Path(SVG_PATH);
     // Debug.Log(SVG.Dump());
 }