initial svg support

This commit is contained in:
2025-10-23 09:40:08 +02:00
parent 88d188a794
commit 6e6aa8b27e
10 changed files with 309 additions and 10 deletions
+26
View File
@@ -67,6 +67,10 @@ pub use shapes::{ShapeType, TurtleShape};
pub use state::{DrawCommand, Turtle, TurtleWorld};
pub use tweening::TweenController;
pub mod export;
#[cfg(feature = "svg")]
pub mod export_svg;
// Re-export the turtle_main macro
pub use turtle_lib_macros::turtle_main;
@@ -91,6 +95,28 @@ pub struct TurtleApp {
}
impl TurtleApp {
/// Exportiere das aktuelle Drawing in das gewünschte Format
#[allow(unused_variables)]
pub fn export_drawing(
&self,
filename: &str,
format: export::DrawingFormat,
) -> Result<(), export::ExportError> {
match format {
#[cfg(feature = "svg")]
export::DrawingFormat::Svg => {
use crate::export::DrawingExporter;
use export_svg::svg_export::SvgExporter;
let exporter = SvgExporter;
exporter.export(&self.world, filename)
}
// Weitere Formate können hier ergänzt werden
#[allow(unreachable_patterns)]
_ => Err(export::ExportError::Format(
"Export-Format nicht unterstützt".to_string(),
)),
}
}
/// Create a new `TurtleApp` with default settings
#[must_use]
pub fn new() -> Self {