tui/widgets/canvas/
points.rs

1use crate::{
2    style::Color,
3    widgets::canvas::{Painter, Shape},
4};
5
6/// A shape to draw a group of points with the given color
7#[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}