use super::braille::{BrailleGrid, Shape};
use crate::style::Color;
pub struct Layer {
grid: BrailleGrid,
visible: bool,
opacity: f32,
}
impl Layer {
pub fn new(term_width: u16, term_height: u16) -> Self {
Self {
grid: BrailleGrid::new(term_width, term_height),
visible: true,
opacity: 1.0,
}
}
pub fn set_visible(&mut self, visible: bool) {
self.visible = visible;
}
pub fn is_visible(&self) -> bool {
self.visible
}
pub fn set_opacity(&mut self, opacity: f32) {
self.opacity = opacity.clamp(0.0, 1.0);
}
pub fn opacity(&self) -> f32 {
self.opacity
}
pub fn width(&self) -> usize {
self.grid.width()
}
pub fn height(&self) -> usize {
self.grid.height()
}
pub fn set(&mut self, x: usize, y: usize, color: Color) {
self.grid.set(x, y, color);
}
pub fn clear(&mut self) {
self.grid.clear();
}
pub fn draw<S: Shape>(&mut self, shape: &S) {
self.grid.draw(shape);
}
pub fn grid(&self) -> &BrailleGrid {
&self.grid
}
pub fn grid_mut(&mut self) -> &mut BrailleGrid {
&mut self.grid
}
#[doc(hidden)]
pub fn cells(&self) -> &[u8] {
self.grid.cells()
}
#[doc(hidden)]
pub fn colors(&self) -> &[Option<Color>] {
self.grid.colors()
}
}