From 9530f4fddb7feda1a106b6ee7019d0c9f0b2349d Mon Sep 17 00:00:00 2001 From: adamalj Date: Sat, 26 Oct 2024 21:18:30 -0700 Subject: [PATCH] fix: non integer image position fix: maintain center position --- src/convert/svg.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/convert/svg.rs b/src/convert/svg.rs index e244578..7c000c9 100644 --- a/src/convert/svg.rs +++ b/src/convert/svg.rs @@ -207,7 +207,15 @@ impl SvgBuilder { } let mut placed_coord_x = (self.margin * 2 + n) as f64 - border_size; - placed_coord_x /= 2f64; + + // Adjust for non-integer initial x coordinates so as not to partially cover bits by rounding down. + if placed_coord_x % 2f64 != 0f64 { + placed_coord_x += 1f64; + border_size -= 1f64; + } + + placed_coord_x = placed_coord_x / 2f64; + let mut placed_coord = (placed_coord_x, placed_coord_x); if let Some((x, y)) = self.image_position {