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