From 8a56990cff9cd46ad8307b48f4f30cb9846e456b Mon Sep 17 00:00:00 2001 From: Juergen Stuber Date: Fri, 8 Nov 2024 00:16:20 +0100 Subject: [PATCH] Distribute available space also to the margins --- src/bin/primes/main.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/bin/primes/main.rs b/src/bin/primes/main.rs index 0f7dd1c..bde3f78 100644 --- a/src/bin/primes/main.rs +++ b/src/bin/primes/main.rs @@ -188,11 +188,13 @@ fn main() -> Result<()> { // Start positions for rendering (lower left pixel). let lines = (y_size - 2 * MIN_MARGIN + MIN_LINE_SEP) / (HEIGHT + MIN_LINE_SEP); + let lines = lines.max(1); let line_sep = if lines >= 2 { - (y_size - 2 * MIN_MARGIN - lines * HEIGHT) / (lines - 1) + (y_size - 2 * MIN_MARGIN - lines * HEIGHT) / lines } else { MIN_LINE_SEP }; + let line_sep = line_sep.max(MIN_LINE_SEP); let y0 = MIN_MARGIN + (y_size - 2 * MIN_MARGIN - lines * HEIGHT - (lines - 1) * line_sep) / 2; let mut start_positions = (0..lines) .map(|i| p2d(bbox.x_end(), y0 + i * (line_sep + HEIGHT)))