public void TestLayers() { var writer = new SVGWriter(); writer.StartNewLayer("layer-0"); writer.AddLine(new Segment2d(Vector2d.Zero, Vector2d.AxisX)); writer.StartNewLayer("layer-1"); writer.AddLine(new Segment2d(Vector2d.Zero, Vector2d.AxisY)); writer.Write("layers.svg"); }
public static void WriteTestOutputGraphs(List <DGraph2> graphs, string sFilename, SVGWriter.Style lineStyle, SVGWriter.Style vtxStyle, double vtxRadius = 2.5) { Vector2d a = Vector2d.Zero, b = Vector2d.Zero; SVGWriter svg = new SVGWriter(); foreach (DGraph2 graph in graphs) { foreach (int eid in graph.EdgeIndices()) { graph.GetEdgeV(eid, ref a, ref b); svg.AddLine(new Segment2d(a, b), lineStyle); } } if (vtxRadius > 0) { foreach (DGraph2 graph in graphs) { foreach (int vid in graph.VertexIndices()) { a = graph.GetVertex(vid); svg.AddCircle(new Circle2d(a, vtxRadius), vtxStyle); } } } svg.Write(Program.TEST_OUTPUT_PATH + sFilename); }
public void TestBasic() { var writer = new SVGWriter(); writer.AddLine(new Segment2d(Vector2d.Zero, Vector2d.AxisX)); writer.Write("basic.svg"); }
public static void test_svg() { Polygon2d poly = Polygon2d.MakeCircle(100.0f, 10); PolyLine2d pline = new PolyLine2d(); pline.AppendVertex(Vector2d.Zero); pline.AppendVertex(200 * Vector2d.AxisX); pline.AppendVertex(200 * Vector2d.One); Circle2d circ = new Circle2d(33 * Vector2d.One, 25); Segment2d seg = new Segment2d(Vector2d.Zero, -50 * Vector2d.AxisY); SVGWriter writer = new SVGWriter(); writer.AddPolygon(poly, SVGWriter.Style.Filled("lime", "black", 0.25f)); writer.AddPolyline(pline, SVGWriter.Style.Outline("orange", 2.0f)); writer.AddCircle(circ, SVGWriter.Style.Filled("yellow", "red", 5.0f)); writer.AddLine(seg, SVGWriter.Style.Outline("blue", 10.0f)); int astep = 29; Vector2d c = new Vector2d(-200, 100); for (int k = 1; k <= 12; ++k) { Arc2d arc = new Arc2d(c + k * 45 * Vector2d.AxisX, 20, 0, k * astep); writer.AddArc(arc); writer.AddBox(arc.Bounds, SVGWriter.Style.Outline("red", 0.5f)); } c.y += 50; for (int k = 1; k <= 12; ++k) { Arc2d arc = new Arc2d(c + k * 45 * Vector2d.AxisX, 20, k * astep, (k + 5) * astep); writer.AddArc(arc); writer.AddBox(arc.Bounds, SVGWriter.Style.Outline("red", 0.5f)); } c.y += 50; for (int k = 1; k <= 12; ++k) { Arc2d arc = new Arc2d(c + k * 45 * Vector2d.AxisX, 20, k * astep, (k + 10) * astep); writer.AddArc(arc); writer.AddBox(arc.Bounds, SVGWriter.Style.Outline("red", 0.5f)); } c.y += 50; for (int k = 1; k <= 12; ++k) { Arc2d arc = new Arc2d(c + k * 45 * Vector2d.AxisX, 20, k * astep, (k + 10) * astep); arc.Reverse(); writer.AddArc(arc); writer.AddBox(arc.Bounds, SVGWriter.Style.Outline("red", 0.5f)); } writer.Write(TestUtil.GetTestOutputPath("test.svg")); }
private static void ExportToSVG(DGraph2 input, DGraph2 minGraph, DGraph2 pathGraph) { SVGWriter writer = new SVGWriter(); writer.AddGraph(input, SVGWriter.Style.Outline("blue", 0.1f)); writer.AddGraph(minGraph, SVGWriter.Style.Outline("red", 0.1f)); foreach (int eid in minGraph.EdgeIndices()) { if (minGraph.GetEdgeGroup(eid) >= 0) { writer.AddLine(minGraph.GetEdgeSegment(eid), SVGWriter.Style.Outline("green", 0.07f)); } } writer.AddGraph(pathGraph, SVGWriter.Style.Outline("black", 0.03f)); foreach (int vid in pathGraph.VertexIndices()) { if (pathGraph.IsBoundaryVertex(vid)) { writer.AddCircle(new Circle2d(pathGraph.GetVertex(vid), 0.5f), SVGWriter.Style.Outline("blue", 0.03f)); } } writer.Write("MIN_GRAPH.svg"); }