diff --git a/Cargo.lock b/Cargo.lock
index 225ca89..8142d03 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1328,9 +1328,9 @@ checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5"
[[package]]
name = "smallvec"
-version = "1.15.1"
+version = "1.16.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03"
+checksum = "f9395f0f0eee849a9b707b2f06bb92a6a422090e2123bb2ef8e87a0e61892a8e"
[[package]]
name = "strsim"
@@ -1413,6 +1413,7 @@ dependencies = [
"rustc-hash",
"serde",
"serde_json",
+ "smallvec",
"svgtypes",
"uom",
]
diff --git a/Cargo.toml b/Cargo.toml
index 0aeda20..e0d2526 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -35,5 +35,6 @@ paste = "1"
roxmltree = "0.21"
serde = { version = "1", default-features = false }
serde_json = "1"
+smallvec = "1.16"
svgtypes = "0.16"
-uom = "0.38"
+uom = "0.38"
\ No newline at end of file
diff --git a/g_code/src/turtle.rs b/g_code/src/turtle.rs
index aecf948..e56427f 100644
--- a/g_code/src/turtle.rs
+++ b/g_code/src/turtle.rs
@@ -1,7 +1,7 @@
use std::{borrow::Cow, fmt::Debug};
use ::g_code::{command, emit::Token};
-use lyon_geom::{Point, SvgArc};
+use lyon_geom::{LineSegment, Point, SvgArc};
use rust_decimal::{Decimal, prelude::*};
use svg2star::turtle::{
Turtle,
@@ -140,18 +140,15 @@ impl Turtle for GCodeTurtle<'_> {
fn stroke(&mut self, stroke: Stroke) {
let start = stroke.start_point();
- let mut commands = stroke.into_commands().peekable();
self.tool_off();
// Comments should be inline after tool_off but before a rapid move.
- while matches!(commands.peek(), Some(DrawCommand::Comment(_))) {
- if let Some(DrawCommand::Comment(comment)) = commands.next() {
- self.program.push(Token::Comment {
- is_inline: false,
- inner: Cow::Owned(comment),
- });
- }
+ if let Some(comment) = stroke.comment() {
+ self.program.push(Token::Comment {
+ is_inline: false,
+ inner: Cow::Owned(comment.to_owned()),
+ });
}
self.program.append(
@@ -163,9 +160,9 @@ impl Turtle for GCodeTurtle<'_> {
);
self.tool_on();
- for command in commands {
+ for command in stroke.into_commands() {
match command {
- DrawCommand::LineTo { from: _, to } => {
+ DrawCommand::LineTo(LineSegment { from: _, to }) => {
self.program.append(
&mut command!(LinearInterpolation {
X: self.round(to.x),
@@ -248,12 +245,6 @@ impl Turtle for GCodeTurtle<'_> {
}
}
}
- DrawCommand::Comment(comment) => {
- self.program.push(Token::Comment {
- is_inline: false,
- inner: Cow::Owned(comment),
- });
- }
}
}
}
diff --git a/g_code/tests/shapes.gcode b/g_code/tests/shapes.gcode
index c3b6113..b9b45e0 100644
--- a/g_code/tests/shapes.gcode
+++ b/g_code/tests/shapes.gcode
@@ -930,7 +930,6 @@ G1 X133.707 Y112.443 F300
G1 X133.716 Y112.143 F300
G1 X133.717 Y112.053 F300;svg#svg1 > g#layer1 > polygon#polygon1
G0 X12.575 Y173.877
-G1 X12.575 Y173.877 F300
G1 X8.009 Y179.602 F300
G1 X9.639 Y186.741 F300
G1 X16.236 Y189.919 F300
@@ -939,7 +938,6 @@ G1 X24.463 Y179.602 F300
G1 X42.162 Y169.979 F300
G1 X12.575 Y173.877 F300;svg#svg1 > g#layer1 > polyline#polyline1
G0 X76.339 Y112.397
-G1 X76.339 Y112.397 F300
G1 X71.773 Y118.122 F300
G1 X73.402 Y125.261 F300
G1 X80 Y128.439 F300
diff --git a/g_code/tests/smooth_curves.svg b/g_code/tests/smooth_curves.svg
index 16131f7..d0edfa0 100644
--- a/g_code/tests/smooth_curves.svg
+++ b/g_code/tests/smooth_curves.svg
@@ -1 +1 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/g_code/tests/transform_origin.svg b/g_code/tests/transform_origin.svg
index 2a81764..2964a40 100644
--- a/g_code/tests/transform_origin.svg
+++ b/g_code/tests/transform_origin.svg
@@ -1,5 +1,5 @@
diff --git a/g_code/tests/transform_origin_equivalent.svg b/g_code/tests/transform_origin_equivalent.svg
index 1c9a984..7813304 100644
--- a/g_code/tests/transform_origin_equivalent.svg
+++ b/g_code/tests/transform_origin_equivalent.svg
@@ -1,5 +1,5 @@
diff --git a/g_code/tests/use_defs.svg b/g_code/tests/use_defs.svg
index 7c1929f..ca6308d 100644
--- a/g_code/tests/use_defs.svg
+++ b/g_code/tests/use_defs.svg
@@ -1,6 +1,6 @@
diff --git a/g_code/tests/use_symbol.svg b/g_code/tests/use_symbol.svg
index 2de460c..544830d 100644
--- a/g_code/tests/use_symbol.svg
+++ b/g_code/tests/use_symbol.svg
@@ -1,7 +1,7 @@