public DrawLine ( Color color, double strokeThickness, double x1, double y1, double x2, double y2 ) : void | ||
color | Color | |
strokeThickness | double | |
x1 | double | |
y1 | double | |
x2 | double | |
y2 | double | |
return | void |
public String toImageSVG(UndirectedGraph<Pixel, TaggedUndirectedEdge<Pixel, EdgeTag>> g, string fileName = "image.svg") { svg = new SVGDocument(Width * scale + 1, Height * scale + 1); //Percorre o Grafo e desenha o pixelart como SVG svg.DrawCellBorder(DrawCellBorder); foreach (var v in g.Vertices) { //Desenha o quadrado do pixelart if (DrawPixelArt) { svg.DrawRectangle(v.color, Color.Black, 1, v.x * scale, v.y * scale, scale, scale); } //desenha novo formato das celulas if (DrawNewCells && !DrawNewControlPoints) { String points = ""; foreach (Point p in v.points) { points += p.X.ToString() + "," + p.Y.ToString() + " "; } //Console.WriteLine(points); if (v.color.A != 255) // Se cor é transparente, mostra como branco svg.DrawPolygon(Color.White, Color.Black, 0.100, points); else svg.DrawPolygon(v.color, Color.Black, 0.100, points); } //desenha o nodo if (DrawVertex) { svg.DrawCircle(Color.Blue, Color.Transparent, 0, v.x * scale + scale / 2, v.y * scale + scale / 2, scale < 10 ? 1 : scale / 10); if (DrawValence) { svg.DrawText(v.valence.ToString(), 30.0, Color.White, new Point(v.x * scale + scale / 2, v.y * scale + scale / 2)); } } } //desenha os vertices if (DrawEdges) { foreach (var v in g.Edges) { svg.DrawLine(Color.Blue, 0.800, v.Source.x * scale + scale / 2, v.Source.y * scale + scale / 2, v.Target.x * scale + scale / 2, v.Target.y * scale + scale / 2); } } //Retorna o nome do arquivo salvo svg.Save(fileName); return fileName; }
public String ToNewEdges(UndirectedGraph<Pixel, TaggedUndirectedEdge<Pixel, EdgeTag>> g, string fileName = "image.svg") { svg = new SVGDocument(Width * scale + 1, Height * scale + 1); foreach (var e in g.Edges) { if ((e.Tag.visible)) svg.DrawLine(Color.Black, 0.800, e.Source.x * scale + scale / 2, e.Source.y * scale + scale / 2, e.Target.x * scale + scale / 2, e.Target.y * scale + scale / 2); } //Retorna o nome do arquivo salvo svg.Save(fileName); return fileName; }