1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
use super::{ColChar, Vec2D, ViewElement};

/// The `Point` holds a single [`Vec2D`] (the coordinates at which it is printed when blit to a [`View`](super::View)) and a [`ColChar`]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct Point {
    /// The position of the `Point`
    pub pos: Vec2D,
    /// The appearance/colour of the `Point`
    pub fill_char: ColChar,
}

impl Point {
    /// Create a new Point from a [`Vec2D`] and [`ColChar`]
    pub fn new(pos: Vec2D, fill_char: ColChar) -> Self {
        Self { pos, fill_char }
    }
}

impl From<(Vec2D, ColChar)> for Point {
    fn from(value: (Vec2D, ColChar)) -> Self {
        Self {
            pos: value.0,
            fill_char: value.1,
        }
    }
}

impl ViewElement for Point {
    fn active_pixels(&self) -> Vec<Point> {
        vec![*self]
    }
}