void Update() { SVG.Clear(); for (var i = 0; i < 4; ++i) { var angle0 = Mathf.PI * 0.5f * (i + 0); var angle1 = Mathf.PI * 0.5f * (i + 1); var r = 3f; var x0 = Mathf.Cos(angle0) * r; var y0 = Mathf.Sin(angle0) * r; var x1 = Mathf.Cos(angle1) * r; var y1 = Mathf.Sin(angle1) * r; var a = r * (4f / 3f) * Mathf.Tan((angle1 - angle0) / 4f); var inAngle = angle0 + Mathf.PI * 0.5f; var inX = x0 + Mathf.Cos(inAngle) * a; var inY = y0 + Mathf.Sin(inAngle) * a; var outAngle = angle1 - Mathf.PI * 0.5f; var outX = x1 + Mathf.Cos(outAngle) * a; var outY = y1 + Mathf.Sin(outAngle) * a; if (i == 0) { SVG.Move(x0, y0); } SVG.Curve(inX, inY, outX, outY, x1, y1); } Mesh.Fill(SVG); }
void Update() { Rects.RemoveAll(r => r == null); for (var i = 0; i < Rects.Count; ++i) { for (var j = i + 1; j < Rects.Count; ++j) { if (Rects[i].HitTest(Rects[j])) { continue; } if (Rects[j].HitTest(Rects[i])) { continue; } } } LineSVG.Clear(); if (IsDragging) { var p = GetMousePoint(); if (Input.GetMouseButton(0)) { DrawLine(LineSVG, DragStart, p); } else { IsDragging = false; foreach (var r in Rects.ToList()) { r.Split(DragStart, p, Rects); } } } else { if (Input.GetMouseButtonDown(0)) { DragStart = GetMousePoint(); IsDragging = true; } } LineMesh.Fill(LineSVG); }
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); } }
void Update() { HeadSVG.Clear(); TailSVG.Clear(); BodySVG.Clear(); Update(Time.deltaTime); var v = Mathf.Max(0.7f, 1.3f - Mathf.Clamp01((Head - Tail).magnitude / 3f)); Circle(HeadSVG, Head, HeadR); Circle(TailSVG, Tail, TailR); Metaball(BodySVG, Head, HeadR, Tail, TailR, v); HeadMesh.Fill(HeadSVG); TailMesh.Fill(TailSVG); BodyMesh.Fill(BodySVG); }
void Update() { Circle1SVG.Clear(); Circle2SVG.Clear(); MetaballSVG.Clear(); var c1 = (Vector2)Circle1Mesh.transform.localPosition; var c2 = (Vector2)Circle2Mesh.transform.localPosition; var c1R = 1f; var c2R = 1.2f; var v = Mathf.Max(0.5f, 1.3f - Mathf.Clamp01((c2 - c1).magnitude / 8f)); Circle(Circle1SVG, Vector2.zero, c1R); Circle(Circle2SVG, Vector2.zero, c2R); Metaball(MetaballSVG, c1, c1R, c2, c2R, v); Circle1Mesh.Fill(Circle1SVG); Circle2Mesh.Fill(Circle2SVG); MetaballMesh.Fill(MetaballSVG); }
void Update() { Mesh.Fill(SVG); }
private void Render() { SVG.Clear(); Draw(SVG); Mesh.Fill(SVG); }