tui/widgets/canvas/
points.rs1use crate::{
2 style::Color,
3 widgets::canvas::{Painter, Shape},
4};
5
6#[derive(Debug, Clone)]
8pub struct Points<'a> {
9 pub coords: &'a [(f64, f64)],
10 pub color: Color,
11}
12
13impl<'a> Shape for Points<'a> {
14 fn draw(&self, painter: &mut Painter) {
15 for (x, y) in self.coords {
16 if let Some((x, y)) = painter.get_point(*x, *y) {
17 painter.paint(x, y, self.color);
18 }
19 }
20 }
21}
22
23impl<'a> Default for Points<'a> {
24 fn default() -> Points<'a> {
25 Points {
26 coords: &[],
27 color: Color::Reset,
28 }
29 }
30}