ratatui/widgets/canvas/points.rs
1use crate::{
2 style::Color,
3 widgets::canvas::{Painter, Shape},
4};
5
6/// A group of points with a given color
7#[derive(Debug, Default, Clone, PartialEq)]
8pub struct Points<'a> {
9 /// List of points to draw
10 pub coords: &'a [(f64, f64)],
11 /// Color of the points
12 pub color: Color,
13}
14
15impl<'a> Shape for Points<'a> {
16 fn draw(&self, painter: &mut Painter) {
17 for (x, y) in self.coords {
18 if let Some((x, y)) = painter.get_point(*x, *y) {
19 painter.paint(x, y, self.color);
20 }
21 }
22 }
23}