remove dead code and translate german comments to english
This commit is contained in:
parent
96b02f61be
commit
156301f272
@ -12,54 +12,7 @@ use macroquad::prelude::*;
|
|||||||
// See https://easings.net/ for visual demonstrations
|
// See https://easings.net/ for visual demonstrations
|
||||||
use tween::CubicInOut;
|
use tween::CubicInOut;
|
||||||
|
|
||||||
/// Render the entire turtle world
|
/// Render the turtle world with active tween visualization.
|
||||||
pub(crate) fn render_world(world: &TurtleWorld) {
|
|
||||||
// Update camera zoom based on current screen size to prevent stretching
|
|
||||||
let camera = Camera2D {
|
|
||||||
zoom: vec2(1.0 / screen_width() * 2.0, 1.0 / screen_height() * 2.0),
|
|
||||||
target: world.camera.target,
|
|
||||||
..Default::default()
|
|
||||||
};
|
|
||||||
|
|
||||||
// Set camera
|
|
||||||
set_camera(&camera);
|
|
||||||
|
|
||||||
// Draw all accumulated commands from all turtles
|
|
||||||
for turtle in &world.turtles {
|
|
||||||
for cmd in &turtle.commands {
|
|
||||||
match cmd {
|
|
||||||
DrawCommand::Mesh { data, source: _ } => {
|
|
||||||
// Rendering wie bisher
|
|
||||||
draw_mesh(&data.to_mesh());
|
|
||||||
// Hier könnte man das source für Debug/Export loggen
|
|
||||||
}
|
|
||||||
DrawCommand::Text {
|
|
||||||
text,
|
|
||||||
position,
|
|
||||||
heading,
|
|
||||||
font_size,
|
|
||||||
color,
|
|
||||||
source: _,
|
|
||||||
} => {
|
|
||||||
draw_text_command(text, *position, *heading, *font_size, *color);
|
|
||||||
// Hier könnte man das source für Debug/Export loggen
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Draw all visible turtles
|
|
||||||
for turtle in &world.turtles {
|
|
||||||
if turtle.params.visible {
|
|
||||||
draw_turtle(&turtle.params);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Reset to default camera
|
|
||||||
set_default_camera();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Render the turtle world with active tween visualization
|
|
||||||
#[allow(clippy::too_many_lines)]
|
#[allow(clippy::too_many_lines)]
|
||||||
pub(crate) fn render_world_with_tweens(world: &TurtleWorld, zoom_level: f32) {
|
pub(crate) fn render_world_with_tweens(world: &TurtleWorld, zoom_level: f32) {
|
||||||
// Update camera zoom based on current screen size to prevent stretching
|
// Update camera zoom based on current screen size to prevent stretching
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
//! Export-Backend-Trait und zentrale Export-Typen
|
//! Export backend trait and core export types.
|
||||||
|
|
||||||
use crate::state::TurtleWorld;
|
use crate::state::TurtleWorld;
|
||||||
use crate::TurtlePlan;
|
use crate::TurtlePlan;
|
||||||
@ -7,14 +7,14 @@ use crate::TurtlePlan;
|
|||||||
pub enum ExportError {
|
pub enum ExportError {
|
||||||
Io(std::io::Error),
|
Io(std::io::Error),
|
||||||
Format(String),
|
Format(String),
|
||||||
// Weitere Formate können ergänzt werden
|
// Additional formats can be added here.
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug)]
|
#[derive(Clone, Copy, Debug)]
|
||||||
pub enum DrawingFormat {
|
pub enum DrawingFormat {
|
||||||
#[cfg(feature = "svg")]
|
#[cfg(feature = "svg")]
|
||||||
Svg,
|
Svg,
|
||||||
// Weitere Formate wie Png, Pdf, ...
|
// Additional formats: Png, Pdf, …
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) trait DrawingExporter {
|
pub(crate) trait DrawingExporter {
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
//! SVG-Export-Backend für TurtleWorld
|
//! SVG export backend for `TurtleWorld`.
|
||||||
|
|
||||||
#[cfg(feature = "svg")]
|
#[cfg(feature = "svg")]
|
||||||
pub mod svg_export {
|
pub mod svg_export {
|
||||||
@ -42,7 +42,7 @@ pub mod svg_export {
|
|||||||
DrawCommand::Mesh { source, .. } => {
|
DrawCommand::Mesh { source, .. } => {
|
||||||
match &source.command {
|
match &source.command {
|
||||||
TurtleCommand::Move(_) | TurtleCommand::Goto(_) => {
|
TurtleCommand::Move(_) | TurtleCommand::Goto(_) => {
|
||||||
// Linie als <line>
|
// Straight line — emit as SVG <line>
|
||||||
let start = source.start_position;
|
let start = source.start_position;
|
||||||
let end = source.end_position;
|
let end = source.end_position;
|
||||||
update_bounds(
|
update_bounds(
|
||||||
@ -78,7 +78,7 @@ pub mod svg_export {
|
|||||||
);
|
);
|
||||||
let center = geom.center;
|
let center = geom.center;
|
||||||
if (angle.value() - 360.0).abs() < 1e-3 {
|
if (angle.value() - 360.0).abs() < 1e-3 {
|
||||||
// Voller Kreis
|
// Full circle — emit as SVG <circle>
|
||||||
update_bounds(
|
update_bounds(
|
||||||
&mut min_x,
|
&mut min_x,
|
||||||
&mut max_x,
|
&mut max_x,
|
||||||
@ -104,7 +104,7 @@ pub mod svg_export {
|
|||||||
.set("fill", "none");
|
.set("fill", "none");
|
||||||
doc = doc.add(circle);
|
doc = doc.add(circle);
|
||||||
} else {
|
} else {
|
||||||
// Kreisbogen als <path>
|
// Partial arc — emit as SVG <path> with A command
|
||||||
let start = source.start_position;
|
let start = source.start_position;
|
||||||
let end = source.end_position;
|
let end = source.end_position;
|
||||||
// For arcs, include the full circle bounds to ensure complete visibility
|
// For arcs, include the full circle bounds to ensure complete visibility
|
||||||
@ -149,7 +149,7 @@ pub mod svg_export {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
TurtleCommand::EndFill => {
|
TurtleCommand::EndFill => {
|
||||||
// Fills werden als <path> mit Konturen ausgegeben
|
// Fill contours — emit as SVG <path> with evenodd fill rule
|
||||||
if let Some(contours) = &source.contours {
|
if let Some(contours) = &source.contours {
|
||||||
for contour in contours {
|
for contour in contours {
|
||||||
for point in contour {
|
for point in contour {
|
||||||
@ -187,7 +187,7 @@ pub mod svg_export {
|
|||||||
doc = doc.add(path);
|
doc = doc.add(path);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Fallback: Dummy-Polygon
|
// Fallback: no contour data — emit a dummy polygon
|
||||||
update_bounds(
|
update_bounds(
|
||||||
&mut min_x,
|
&mut min_x,
|
||||||
&mut max_x,
|
&mut max_x,
|
||||||
|
|||||||
@ -63,7 +63,7 @@ pub(crate) mod tweening;
|
|||||||
pub use builders::{CurvedMovement, DirectionalMovement, Turnable, TurtlePlan, WithCommands};
|
pub use builders::{CurvedMovement, DirectionalMovement, Turnable, TurtlePlan, WithCommands};
|
||||||
pub use commands::{CommandQueue, TurtleCommand};
|
pub use commands::{CommandQueue, TurtleCommand};
|
||||||
pub use commands_channel::TurtleCommandSender;
|
pub use commands_channel::TurtleCommandSender;
|
||||||
pub use general::{Degrees, Radians, AnimationSpeed, Color, Coordinate, Length, Precision};
|
pub use general::{AnimationSpeed, Color, Coordinate, Degrees, Length, Precision, Radians};
|
||||||
pub use shapes::{ShapeType, TurtleShape};
|
pub use shapes::{ShapeType, TurtleShape};
|
||||||
|
|
||||||
pub mod export;
|
pub mod export;
|
||||||
@ -96,9 +96,7 @@ pub struct TurtleApp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl TurtleApp {
|
impl TurtleApp {
|
||||||
/// Exportiere das aktuelle Drawing in das gewünschte Format
|
/// Export the current drawing to a file in the specified format.
|
||||||
#[allow(unused_variables)]
|
|
||||||
/// Export the current drawing to a file in the specified format
|
|
||||||
///
|
///
|
||||||
/// # Errors
|
/// # Errors
|
||||||
///
|
///
|
||||||
@ -116,10 +114,10 @@ impl TurtleApp {
|
|||||||
let exporter = SvgExporter;
|
let exporter = SvgExporter;
|
||||||
exporter.export(&self.world, filename)
|
exporter.export(&self.world, filename)
|
||||||
}
|
}
|
||||||
// Weitere Formate können hier ergänzt werden
|
// Additional formats can be registered here.
|
||||||
#[allow(unreachable_patterns)]
|
#[allow(unreachable_patterns)]
|
||||||
_ => Err(export::ExportError::Format(
|
_ => Err(export::ExportError::Format(
|
||||||
"Export-Format nicht unterstützt".to_string(),
|
"Unsupported export format".to_string(),
|
||||||
)),
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user