draw x for no sample

This commit is contained in:
🪞👃🪞 2024-12-28 18:55:58 +01:00
parent b63a5e31ba
commit f09a6072f8

View file

@ -6,16 +6,23 @@ pub struct SampleViewer<'a>(pub Option<&'a Arc<RwLock<Sample>>>);
render!(<Tui>|self: SampleViewer<'a>|render(|to|{ render!(<Tui>|self: SampleViewer<'a>|render(|to|{
let [x, y, width, height] = to.area(); let [x, y, width, height] = to.area();
let area = Rect { x, y, width, height }; let area = Rect { x, y, width, height };
Canvas::default() let (x_bounds, y_bounds, coords): ([f64;2], [f64;2], &[(f64,f64)]) =
.x_bounds([0.0, f64::from(width)]) if let Some(sample) = self.0 {
.y_bounds([0.0, f64::from(height)]) let sample = sample.read().unwrap();
.paint(|ctx|{ (
ctx.draw(&Points { [sample.start as f64, sample.end as f64],
coords: &[(0., 0.), (1., 2.), (3., 4.)], [0 as f64, f32::MAX as f64],
color: Color::Rgb(255,0,0) &[]
}) )
// TODO } else {
}) (
.render(area, &mut to.buffer); [0.0, f64::from(width)],
[0.0, f64::from(height)],
&[(0., 0.), (1., 1.), (2., 2.), (0., 2.), (2., 0.)]
)
};
Canvas::default().x_bounds(x_bounds).y_bounds(y_bounds).paint(|ctx|{
ctx.draw(&Points { coords, color: Color::Rgb(255,0,0) })
}).render(area, &mut to.buffer);
Ok(()) Ok(())
})); }));