diff --git a/dyesub-tool/src/main.rs b/dyesub-tool/src/main.rs index 33139d2..0c0d63f 100644 --- a/dyesub-tool/src/main.rs +++ b/dyesub-tool/src/main.rs @@ -31,21 +31,22 @@ enum Error { fn positions<'a>( keys: &'a Vec, size: SVGMeasure, + margin: SVGMeasure, padding: SVGMeasure, dimensions: &DocumentDimensions, ) -> Vec<(&'a Key<'a>, (SVGMeasure, SVGMeasure))> { let grid = size + padding; - let mut x = padding; - let mut y = padding; + let mut x = margin; + let mut y = margin; let mut positions = Vec::with_capacity(keys.len()); for key in keys { if let Key::Break = key { - x = padding; + x = margin; y = y + grid; continue; } - if x + grid > dimensions.width { - x = padding; + if x + grid > dimensions.width - margin { + x = margin; y = y + grid; } positions.push((key, (x, y))); @@ -66,8 +67,9 @@ fn main() -> Result<(), Error> { }; let box_size = SVGMeasure::new(14.0, SVGUnit::Millimeter); let padding = SVGMeasure::new(2.5, SVGUnit::Millimeter); + let margin = SVGMeasure::new(0.25, SVGUnit::Inch); let document = DocumentTemplate { - positions: positions(&KEYS, box_size, padding, &dimensions), + positions: positions(&KEYS, box_size, margin, padding, &dimensions), dimensions: &dimensions, box_size, };