diff options
| author | littleblack111 <littleblack11111@gmail.com> | 2025-09-29 14:40:12 +0800 |
|---|---|---|
| committer | littleblack111 <littleblack11111@gmail.com> | 2025-09-29 14:40:12 +0800 |
| commit | 3f3092856aaf2844a442ef86b0d4cb58acdff345 (patch) | |
| tree | d800b1d4ca438a9a707d8ca543b91ffe72442572 /src/image.rs | |
| parent | c379eb2216c80cdaf3c6670afbf3fc2269203634 (diff) | |
image(text): only update center offset when its nonzerotext
we'll need to manually update them
Diffstat (limited to 'src/image.rs')
| -rw-r--r-- | src/image.rs | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/image.rs b/src/image.rs index 244ce18..b78dc04 100644 --- a/src/image.rs +++ b/src/image.rs @@ -137,7 +137,9 @@ fn draw_process(img: &mut DynamicImage, txt: &str, (curw, curh, c): &mut Offset) draw_text_mut(img, colors::FG, cw as i32 + COMPONENT_TEXT_PADDING as i32, *curh as i32 + COMPONENT_TEXT_PADDING as i32, PxScale::from(TEXT_SCALE / 2_f32), &get_font().unwrap(), s.as_str()); *curh += TEXT_SCALE as u32 / 2; } - *c = *curw + (w / 2); + if *c == 0 { + *c = *curw + (w / 2); + } *curh += 2 * COMPONENT_TEXT_PADDING; } @@ -179,6 +181,14 @@ fn build(ast: &[DepthExpr]) -> DynamicImage { draw_process(&mut img, "abcdefghijklmnop", &mut offset); draw_direction(&mut img, &mut offset); draw_process(&mut img, "a", &mut offset); + draw_direction(&mut img, &mut offset); + draw_process(&mut img, "a", &mut offset); + draw_direction(&mut img, &mut offset); + draw_process(&mut img, "a", &mut offset); + draw_direction(&mut img, &mut offset); + draw_process(&mut img, "a", &mut offset); + draw_direction(&mut img, &mut offset); + draw_process(&mut img, "a", &mut offset); img } |
