Compare commits

..

No commits in common. "73d0ef4881366c29c66e6d6138fd8c759a9658bd" and "e6bc79ea7bc566618338a1b1637e901dabb3562d" have entirely different histories.

3 changed files with 1 additions and 115 deletions

View File

@ -10,7 +10,6 @@ async fn main() {
.right(90.0) .right(90.0)
.forward(100.0) .forward(100.0)
.set_pen_color(macroquad::color::GRAY) .set_pen_color(macroquad::color::GRAY)
.set_pen_width(8.0)
.circle_right(50.0, 90.0, 4) .circle_right(50.0, 90.0, 4)
.begin_fill() .begin_fill()
.forward(100.0) .forward(100.0)

View File

@ -5,7 +5,6 @@ pub mod svg_export {
use crate::commands::TurtleCommand; use crate::commands::TurtleCommand;
use crate::export::{DrawingExporter, ExportError}; use crate::export::{DrawingExporter, ExportError};
use crate::state::{DrawCommand, TurtleWorld}; use crate::state::{DrawCommand, TurtleWorld};
use macroquad::prelude::Vec2;
use std::fs::File; use std::fs::File;
use svg::{ use svg::{
node::element::{Circle, Line, Polygon, Text as SvgText}, node::element::{Circle, Line, Polygon, Text as SvgText},
@ -18,25 +17,6 @@ pub mod svg_export {
fn export(&self, world: &TurtleWorld, filename: &str) -> Result<(), ExportError> { fn export(&self, world: &TurtleWorld, filename: &str) -> Result<(), ExportError> {
let mut doc = Document::new(); let mut doc = Document::new();
let mut min_x = f32::INFINITY;
let mut max_x = f32::NEG_INFINITY;
let mut min_y = f32::INFINITY;
let mut max_y = f32::NEG_INFINITY;
fn update_bounds(
min_x: &mut f32,
max_x: &mut f32,
min_y: &mut f32,
max_y: &mut f32,
x: f32,
y: f32,
) {
*min_x = min_x.min(x);
*max_x = max_x.max(x);
*min_y = min_y.min(y);
*max_y = max_y.max(y);
}
for turtle in &world.turtles { for turtle in &world.turtles {
for cmd in &turtle.commands { for cmd in &turtle.commands {
match cmd { match cmd {
@ -46,14 +26,6 @@ pub mod svg_export {
// Linie als <line> // Linie als <line>
let start = source.start_position; let start = source.start_position;
let end = source.end_position; let end = source.end_position;
update_bounds(
&mut min_x, &mut max_x, &mut min_y, &mut max_y, start.x,
start.y,
);
update_bounds(
&mut min_x, &mut max_x, &mut min_y, &mut max_y, end.x,
end.y,
);
let line = Line::new() let line = Line::new()
.set("x1", start.x) .set("x1", start.x)
.set("y1", start.y) .set("y1", start.y)
@ -79,22 +51,6 @@ pub mod svg_export {
let center = geom.center; let center = geom.center;
if (*angle - 360.0).abs() < 1e-3 { if (*angle - 360.0).abs() < 1e-3 {
// Voller Kreis // Voller Kreis
update_bounds(
&mut min_x,
&mut max_x,
&mut min_y,
&mut max_y,
center.x - radius,
center.y - radius,
);
update_bounds(
&mut min_x,
&mut max_x,
&mut min_y,
&mut max_y,
center.x + radius,
center.y + radius,
);
let circle = Circle::new() let circle = Circle::new()
.set("cx", center.x) .set("cx", center.x)
.set("cy", center.y) .set("cy", center.y)
@ -107,23 +63,6 @@ pub mod svg_export {
// Kreisbogen als <path> // Kreisbogen als <path>
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
update_bounds(
&mut min_x,
&mut max_x,
&mut min_y,
&mut max_y,
center.x - radius,
center.y - radius,
);
update_bounds(
&mut min_x,
&mut max_x,
&mut min_y,
&mut max_y,
center.x + radius,
center.y + radius,
);
let large_arc = if *angle > 180.0 { 1 } else { 0 }; let large_arc = if *angle > 180.0 { 1 } else { 0 };
let sweep = match direction { let sweep = match direction {
crate::circle_geometry::CircleDirection::Left => 0, crate::circle_geometry::CircleDirection::Left => 0,
@ -151,14 +90,6 @@ pub mod svg_export {
TurtleCommand::EndFill => { TurtleCommand::EndFill => {
// Fills werden als <path> mit Konturen ausgegeben // Fills werden als <path> mit Konturen ausgegeben
if let Some(contours) = &source.contours { if let Some(contours) = &source.contours {
for contour in contours {
for point in contour {
update_bounds(
&mut min_x, &mut max_x, &mut min_y, &mut max_y,
point.x, point.y,
);
}
}
let mut d = String::new(); let mut d = String::new();
for (i, contour) in contours.iter().enumerate() { for (i, contour) in contours.iter().enumerate() {
if !contour.is_empty() { if !contour.is_empty() {
@ -188,30 +119,6 @@ pub mod svg_export {
} }
} else { } else {
// Fallback: Dummy-Polygon // Fallback: Dummy-Polygon
update_bounds(
&mut min_x,
&mut max_x,
&mut min_y,
&mut max_y,
source.start_position.x,
source.start_position.y,
);
update_bounds(
&mut min_x,
&mut max_x,
&mut min_y,
&mut max_y,
source.start_position.x + 10.0,
source.start_position.y + 10.0,
);
update_bounds(
&mut min_x,
&mut max_x,
&mut min_y,
&mut max_y,
source.start_position.x + 5.0,
source.start_position.y + 15.0,
);
let poly = Polygon::new() let poly = Polygon::new()
.set( .set(
"points", "points",
@ -239,10 +146,6 @@ pub mod svg_export {
source, source,
.. ..
} => { } => {
update_bounds(
&mut min_x, &mut max_x, &mut min_y, &mut max_y, position.x,
position.y,
);
let txt = SvgText::new() let txt = SvgText::new()
.set("x", position.x) .set("x", position.x)
.set("y", position.y) .set("y", position.y)
@ -254,17 +157,6 @@ pub mod svg_export {
} }
} }
// Set viewBox with 20px padding
if min_x.is_finite() && max_x.is_finite() && min_y.is_finite() && max_y.is_finite() {
let width = (max_x - min_x) + 40.0;
let height = (max_y - min_y) + 40.0;
let view_box = format!("{} {} {} {}", min_x - 20.0, min_y - 20.0, width, height);
doc = doc.set("viewBox", view_box);
} else {
// Default viewBox if no elements
doc = doc.set("viewBox", "0 0 400 400");
}
let mut file = File::create(filename).map_err(ExportError::Io)?; let mut file = File::create(filename).map_err(ExportError::Io)?;
svg::write(&mut file, &doc).map_err(ExportError::Io)?; svg::write(&mut file, &doc).map_err(ExportError::Io)?;
Ok(()) Ok(())

View File

@ -330,12 +330,7 @@ impl TweenController {
current: &Turtle, current: &Turtle,
speed: AnimationSpeed, speed: AnimationSpeed,
) -> f64 { ) -> f64 {
let mut speed = speed.value(); let speed = speed.value();
// For high speeds, make animation even faster by scaling speed exponentially
if speed > 100.0 {
speed *= speed / 100.0;
}
let base_time = match command { let base_time = match command {
TurtleCommand::Move(dist) => dist.abs() / speed, TurtleCommand::Move(dist) => dist.abs() / speed,