Skip to main content

lichtung_plot/spec/
output.rs

1//! Call-local PNG publication options.
2
3/// PNG export options for rasterizing the canonical SVG scene.
4#[derive(Debug, Clone, Copy, PartialEq)]
5pub struct PngOptions {
6    /// How the output PNG pixel dimensions are chosen.
7    pub sizing: PngSizing,
8    /// PNG encoder compression preset.
9    pub compression: PngCompression,
10}
11
12impl Default for PngOptions {
13    fn default() -> Self {
14        Self {
15            sizing: PngSizing::Dpi(300.0),
16            compression: PngCompression::Balanced,
17        }
18    }
19}
20
21/// Mutually exclusive PNG sizing modes.
22#[derive(Debug, Clone, Copy, PartialEq)]
23pub enum PngSizing {
24    /// Preserve the SVG canvas pixel dimensions.
25    Source,
26    /// Render at a print-oriented DPI, treating SVG CSS pixels as 96 DPI.
27    /// Also writes matching DPI metadata to the PNG file.
28    Dpi(f64),
29    /// Multiply SVG canvas width and height by this scale factor.
30    Scale(f64),
31    /// Set the output width in pixels and preserve aspect ratio.
32    Width(u32),
33    /// Set the output height in pixels and preserve aspect ratio.
34    Height(u32),
35}
36
37/// High-level PNG compression presets.
38#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
39pub enum PngCompression {
40    /// Do not compress. Fastest, largest files.
41    None,
42    /// Prefer encoding speed over file size.
43    Fast,
44    /// Balance encoding speed and file size.
45    #[default]
46    Balanced,
47    /// Spend more time for smaller files.
48    High,
49}