gemini-engine 0.14.2

A 2D/3D monospaced ASCII rendering engine for the terminal
Documentation
use super::ViewElement;

pub mod colchar;
pub mod vec2d;

use colchar::ColChar;
use vec2d::Vec2D;

/// Old name for [`Pixel`], this is now deprecated
#[deprecated = "Renamed to Pixel, please use that instead"]
pub type Point = Pixel;

/// The `Pixel` 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 Pixel {
    /// The position of the `Pixel`
    pub pos: Vec2D,
    /// The appearance/colour of the `Pixel`
    pub fill_char: ColChar,
}

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

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

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