diff --git a/src/bubble.rs b/src/bubble.rs index 6801fe9..5b73745 100644 --- a/src/bubble.rs +++ b/src/bubble.rs @@ -1288,9 +1288,12 @@ fn paint_bubble_pixmap(layout: &BubbleLayout, inputs: &PaintInputs) -> Option Option 0.0 { - paint_pill(&mut pixmap, bar_x, bar_y, fill_w.min(bar_w), bar_h, cap, time_fill); + // Anchor on the right edge so the bar shrinks toward the right as time passes. + let fill_x = bar_x + bar_w - fill_w; + paint_pill(&mut pixmap, fill_x, bar_y, fill_w, bar_h, cap, time_fill); } } } @@ -1391,6 +1396,34 @@ fn build_arc(cx: f32, cy: f32, radius: f32, sweep_fraction: f32) -> Option Option { + let frac = remaining_fraction.clamp(0.0, 1.0); + let segments = ((frac * 64.0).ceil() as usize).max(1); + let mut pb = PathBuilder::new(); + let twelve: f32 = -std::f32::consts::FRAC_PI_2; + let total = frac * std::f32::consts::TAU; + let start_angle = twelve + (std::f32::consts::TAU - total); + for i in 0..=segments { + let t = i as f32 / segments as f32; + let a = start_angle + t * total; + let x = cx + a.cos() * radius; + let y = cy + a.sin() * radius; + if i == 0 { + pb.move_to(x, y); + } else { + pb.line_to(x, y); + } + } + pb.finish() +} + /// Copy a premultiplied-RGBA `Pixmap` into the 32bpp BI_RGB DIB the bubble /// uses for `UpdateLayeredWindow`. The DIB stores BGRA bytes (little-endian /// `0xAARRGGBB` when read as u32); tiny-skia's premultiplied alpha is exactly