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|{
let [x, y, width, height] = to.area();
let area = Rect { x, y, width, height };
Canvas::default()
.x_bounds([0.0, f64::from(width)])
.y_bounds([0.0, f64::from(height)])
.paint(|ctx|{
ctx.draw(&Points {
coords: &[(0., 0.), (1., 2.), (3., 4.)],
color: Color::Rgb(255,0,0)
})
// TODO
})
.render(area, &mut to.buffer);
let (x_bounds, y_bounds, coords): ([f64;2], [f64;2], &[(f64,f64)]) =
if let Some(sample) = self.0 {
let sample = sample.read().unwrap();
(
[sample.start as f64, sample.end as f64],
[0 as f64, f32::MAX as f64],
&[]
)
} else {
(
[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(())
}));