diff options
| author | littleblack111 <littleblack11111@gmail.com> | 2025-09-29 14:40:12 +0800 |
|---|---|---|
| committer | littleblack111 <littleblack11111@gmail.com> | 2025-10-08 16:30:12 +0800 |
| commit | 56a7b7b6aac1f63b352129e13476b83951c538ae (patch) | |
| tree | 00ab1102c9c605f39b4ecb55bbc32d0250ae7d2b /src/image.rs | |
| parent | 1cc8d09c293cafe9dc4b6b4b91c02cd1d82ca2c6 (diff) | |
image(text): only update center offset when its nonzero
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 } |
