Skip to content

Commit 8c34c62

Browse files
committed
fix: better spacing between different todos
1 parent ceee2a0 commit 8c34c62

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

src/wall.rs

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -186,15 +186,13 @@ pub fn set_wall(todos: &[String], dones: &[String]) {
186186

187187
if todos.len() > 0 {
188188
to_print.push("TODOS:".to_string());
189-
to_print.push("".to_string());
190189
for (i, todo) in todos.iter().enumerate() {
191190
to_print.push(format!("{}. {}", i + 1, todo));
192191
}
193192
}
194193
if dones.len() > 0 {
195194
to_print.push("".to_string());
196195
to_print.push("DONES:".to_string());
197-
to_print.push("".to_string());
198196
for (i, done) in dones.iter().enumerate() {
199197
to_print.push(format!("{}. {}", i + 1, done));
200198
}
@@ -258,7 +256,7 @@ fn write_wallpaper(
258256
} else {
259257
2 * img_width / 3
260258
}),
261-
0u32,
259+
(0.1 * img_height as f32) as u32,
262260
);
263261

264262
// 2. scale the font according to the image dimensions (with min and max - clamp)
@@ -301,15 +299,25 @@ fn write_wallpaper(
301299
.blur(15f32);
302300
img.copy_from(&blurred_img, start_x as u32, 0)?;
303301

304-
// 5. add text to the image leaving a margin of 2% of the image width and height
305-
wrapped_string.iter().enumerate().for_each(|(i, line)| {
302+
// adjust start_x to include the margin
303+
let start_x = start_x + (0.02 * img_width as f32) as u32;
304+
305+
// y position of the text
306+
let mut i: f32 = 0.0;
307+
308+
// 5. add text to the image
309+
wrapped_string.iter().for_each(|line| {
310+
if line.len() > 0 && line[1..].starts_with(". ") {
311+
i += 1.5;
312+
} else {
313+
i += 1.0;
314+
}
315+
306316
drawing::draw_text_mut(
307317
&mut img,
308318
text_color,
309-
start_x as i32 + (0.02 * img_width as f32) as i32,
310-
start_y as i32
311-
+ ((1.15 * i as f32 * font_size.y) as i32)
312-
+ (0.1 * img_height as f32) as i32,
319+
start_x as i32,
320+
start_y as i32 + ((1.15 * i as f32 * font_size.y) as i32),
313321
font_size,
314322
&font,
315323
line,
@@ -396,3 +404,4 @@ fn wrap_string(text: String, bounding_box_width: usize, font: &Font, scale: &Sca
396404
// TODO: use screen dimensions instead of image dimensions for:
397405
// - font size
398406
// - start and end of the image to use since the image is scaled and cropped accordingly by the DE
407+
// TODO: name dark and light wallpapers differently

0 commit comments

Comments
 (0)