(plot: &impl Plot, path: &str)
| 118 | } |
| 119 | |
| 120 | pub fn save_to_file(plot: &impl Plot, path: &str) { |
| 121 | let (w, h) = resolve_dimensions(plot.ir_layout()); |
| 122 | |
| 123 | if path.ends_with(".svg") { |
| 124 | let mut svg = String::new(); |
| 125 | let dashes; |
| 126 | { |
| 127 | let root = SVGBackend::with_string(&mut svg, (w, h)).into_drawing_area(); |
| 128 | dashes = render_to_backend(plot, root); |
| 129 | } |
| 130 | smooth_svg_lines(&mut svg); |
| 131 | apply_svg_dash_patterns(&mut svg, &dashes); |
| 132 | std::fs::write(path, svg).unwrap(); |
| 133 | } else { |
| 134 | let root = BitMapBackend::new(path, (w, h)).into_drawing_area(); |
| 135 | render_to_backend(plot, root); |
| 136 | } |
| 137 | } |
| 138 | |
| 139 | pub fn render_to_svg_string(plot: &impl Plot) -> String { |
| 140 | let (w, h) = resolve_dimensions(plot.ir_layout()); |
no test coverage detected