use crate::elements::view::{utils, ColChar, Pixel, Vec2D, ViewElement};
pub struct Rect {
pub pos: Vec2D,
pub size: Vec2D,
pub fill_char: ColChar,
}
impl Rect {
pub const fn new(pos: Vec2D, size: Vec2D, fill_char: ColChar) -> Self {
Self {
pos,
size,
fill_char,
}
}
pub fn draw(pos: Vec2D, size: Vec2D) -> Vec<Vec2D> {
(0..size.x)
.flat_map(|x| (0..size.y).map(move |y| pos + Vec2D { x, y }))
.collect()
}
}
impl ViewElement for Rect {
fn active_pixels(&self) -> Vec<Pixel> {
utils::points_to_pixels(Rect::draw(self.pos, self.size), self.fill_char)
}
}