1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
//! Plot terminal output rendering.
use std::path::Path;
use crate::builder::Plot;
use crate::{Error, Output};
impl<K: crate::kind::Marker> Plot<K> {
/// Borrow this configuration, render once and publish an outlined SVG.
/// Each call performs a new render and returns a reusable frozen output.
/// The output filename is completed with `.svg` after conversion.
pub fn svg(&self, path: impl AsRef<Path>) -> Result<Output, Error> {
let output = Output::new(super::render_scene(super::root::RootSource::Plot(
self.description(),
))?);
output.svg(path)
}
/// Render once, publish SVG with selectable text, and return a reusable output.
/// The output filename is completed with `.svg` after rendering.
pub fn svg_preserve_text(&self, path: impl AsRef<Path>) -> Result<Output, Error> {
let output = Output::new(super::render_scene(super::root::RootSource::Plot(
self.description(),
))?);
output.svg_preserve_text(path)
}
/// Render once, publish a balanced 300-DPI PNG, and return a reusable output.
/// The output filename is completed with `.png` after rasterization.
pub fn png(&self, path: impl AsRef<Path>) -> Result<Output, Error> {
let output = Output::new(super::render_scene(super::root::RootSource::Plot(
self.description(),
))?);
output.png(path)
}
/// Render once, publish a balanced source-sized PNG without density metadata.
/// The output filename is completed with `.png` after rasterization.
pub fn png_preview(&self, path: impl AsRef<Path>) -> Result<Output, Error> {
let output = Output::new(super::render_scene(super::root::RootSource::Plot(
self.description(),
))?);
output.png_preview(path)
}
/// Render once and publish a PNG using the exact caller-provided options.
/// The output filename is completed with `.png` after rasterization.
pub fn png_with_options(
&self,
path: impl AsRef<Path>,
options: crate::PngOptions,
) -> Result<Output, Error> {
let output = Output::new(super::render_scene(super::root::RootSource::Plot(
self.description(),
))?);
output.png_with_options(path, options)
}
}