Skip to main content

microcad_export/svg/
mod.rs

1// Copyright © 2024-2025 The µcad authors <info@ucad.xyz>
2// SPDX-License-Identifier: AGPL-3.0-or-later
3
4//! Scalable Vector Graphics (SVG) export
5
6mod attributes;
7mod canvas;
8pub mod exporter;
9mod primitives;
10pub mod writer;
11
12#[cfg(test)]
13mod tests;
14
15pub use attributes::SvgTagAttributes;
16pub use canvas::*;
17pub use exporter::*;
18pub use primitives::*;
19pub use writer::*;
20
21/// Trait to write something into an SVG.
22pub trait WriteSvg {
23    /// Write SVG tags.
24    fn write_svg(&self, writer: &mut SvgWriter, attr: &SvgTagAttributes) -> std::io::Result<()>;
25}
26
27/// Trait to write something into an SVG while mapping it to canvas coordinates.
28pub trait WriteSvgMapped: WriteSvg + MapToCanvas {
29    /// Map and write SVG tags.
30    fn write_svg_mapped(
31        &self,
32        writer: &mut SvgWriter,
33        attr: &SvgTagAttributes,
34    ) -> std::io::Result<()> {
35        self.map_to_canvas(writer.canvas()).write_svg(writer, attr)
36    }
37}