public EpsDocument(Stream stream, PageSize pageSize) { _w = new FormattingStreamWriter(stream); _w.NewLine = "\n"; _size = pageSize; DefaultPointSize = 1; }
public EpsDocument(Stream stream, PageSize pageSize) { _w = new FormattingStreamWriter(stream); _w.NewLine = "\n"; _size = pageSize; DefaultPointSize = 1; }
/// <summary> /// Export a mesh to SVG format. /// </summary> /// <param name="mesh">The current mesh.</param> /// <param name="filename">The SVG filename.</param> /// <param name="width">The desired width of the image.</param> /// <param name="regions">Enable rendering of regions.</param> /// <param name="points">Enable rendering of points.</param> public void Export(IMesh mesh, string filename, int width, bool regions = false, bool points = true) { // Check file name if (string.IsNullOrWhiteSpace(filename)) { filename = string.Format("mesh-{0}.svg", DateTime.Now.ToString("yyyy-M-d-hh-mm-ss")); } if (!filename.EndsWith(".svg")) { filename = Path.ChangeExtension(filename, ".svg"); } if (width < 200) { width = 200; } var bounds = mesh.Bounds; float margin = 0.05f * (float)bounds.Width; scale = width / ((float)bounds.Width + 2 * margin); int x_offset = -(int)((bounds.Left - margin) * scale - 0.5); int y_offset = (int)((bounds.Top + margin) * scale + 0.5); int height = (int)((bounds.Height + 2 * margin) * scale + 0.5); using (var svg = new FormattingStreamWriter(filename)) { svg.WriteLine("<svg version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\""); svg.WriteLine("\twidth=\"{0}px\" height=\"{1}px\"", width, height); svg.WriteLine("\tviewBox=\"0 0 {0} {1}\">", width, height); svg.WriteLine("<g transform=\"translate({0}, {1}) scale(1,-1)\">", x_offset, y_offset); DrawTriangles(svg, mesh, regions, false); //DrawEdges(svg, mesh); DrawSegments(svg, mesh); if (points) { DrawPoints(svg, mesh, false); } svg.WriteLine("</g>"); svg.WriteLine("</svg>"); } }
/// <summary> /// Export the mesh to SVG format. /// </summary> /// <param name="mesh">The current mesh.</param> /// <param name="filename">The SVG filename.</param> /// <param name="width">The desired width of the image.</param> public void Export(Mesh mesh, string filename, int width) { // Check file name if (String.IsNullOrWhiteSpace(filename)) { filename = String.Format("mesh-{0}.svg", DateTime.Now.ToString("yyyy-M-d-hh-mm-ss")); } if (!filename.EndsWith(".svg")) { filename = Path.ChangeExtension(filename, ".svg"); } if (width < 200) { width = 200; } var bounds = mesh.Bounds; float margin = 0.05f * (float)bounds.Width; scale = width / ((float)bounds.Width + 2 * margin); int x_offset = -(int)((bounds.Left - margin) * scale); int y_offset = (int)((bounds.Top + margin) * scale); int height = (int)((bounds.Height + 2 * margin) * scale); using (var svg = new FormattingStreamWriter(filename)) { svg.WriteLine("<svg version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\""); svg.WriteLine("\twidth=\"{0}px\" height=\"{1}px\"", width, height); svg.WriteLine("\tviewBox=\"0 0 {0} {1}\">", width, height); svg.WriteLine("<g transform=\"translate({0}, {1}) scale(1,-1)\">", x_offset, y_offset); DrawTriangles(svg, mesh, false); //DrawEdges(svg, mesh); DrawSegments(svg, mesh); DrawPoints(svg, mesh, false); svg.WriteLine("</g>"); svg.WriteLine("</svg>"); } }
// Protected implementation of Dispose pattern. protected virtual void Dispose(bool disposing) { if (disposed) { return; } Close(); if (disposing) { _w.Dispose(); _w = null; } // Free any unmanaged objects here. // disposed = true; }
// Protected implementation of Dispose pattern. protected virtual void Dispose(bool disposing) { if (disposed) return; Close(); if (disposing) { _w.Dispose(); _w = null; } // Free any unmanaged objects here. // disposed = true; }