use crate::{
color::TerminalColor,
impl_from_mono_chrome_pixel_for_datacell,
pixel::Pixel,
};
use crate::{
impl_getters,
impl_getters_mut,
impl_new,
widget::DataCell,
};
#[derive(Clone, Copy)]
pub struct SinglePixel {
pixels: [bool; 1],
}
impl SinglePixel {
#[must_use]
pub const fn character(self) -> char {
if self.pixels[0] { '█' } else { ' ' }
}
}
impl Pixel for SinglePixel {
type U = bool;
const WIDTH: usize = 1;
const HEIGHT: usize = 1;
impl_getters!(pixels: [bool; 1]);
impl_getters_mut!(pixels: [bool; 1]);
impl_new!(SinglePixel, pixels: [bool; 1]);
}
impl_from_mono_chrome_pixel_for_datacell!(SinglePixel);
#[derive(Clone, Copy)]
pub struct DualPixel {
pixels: [bool; 2],
}
#[rustfmt::skip]
impl DualPixel {
#[rustfmt::skip]
const CHARS: [char; 4] = [
' ', '▀',
'▄', '█',
];
#[rustfmt::skip]
const fn index(self) -> usize {
(self.pixels[0] as usize) |
(self.pixels[1] as usize) << 1
}
#[must_use]
pub const fn character(self) -> char {
Self::CHARS[self.index()]
}
}
impl Pixel for DualPixel {
type U = bool;
const WIDTH: usize = 1;
const HEIGHT: usize = 2;
impl_getters!(pixels: [bool; 2]);
impl_getters_mut!(pixels: [bool; 2]);
impl_new!(DualPixel, pixels: [bool; 2]);
}
impl_from_mono_chrome_pixel_for_datacell!(DualPixel);
#[derive(Clone, Copy)]
pub struct QuadPixel {
pixels: [bool; 4],
}
#[rustfmt::skip]
impl QuadPixel {
#[rustfmt::skip]
const CHARS: [char; 16] = [
' ', '▘', '▝', '▀',
'▖', '▌', '▞', '▛',
'▗', '▚', '▐', '▜',
'▄', '▙', '▟', '█',
];
#[rustfmt::skip]
const fn index(self) -> usize {
(self.pixels[0] as usize) |
(self.pixels[1] as usize) << 1 |
(self.pixels[2] as usize) << 2 |
(self.pixels[3] as usize) << 3
}
#[must_use]
pub const fn character(self) -> char {
Self::CHARS[self.index()]
}
}
impl Pixel for QuadPixel {
type U = bool;
const WIDTH: usize = 2;
const HEIGHT: usize = 2;
impl_getters!(pixels: [bool; 4]);
impl_getters_mut!(pixels: [bool; 4]);
impl_new!(QuadPixel, pixels: [bool; 4]);
}
impl_from_mono_chrome_pixel_for_datacell!(QuadPixel);
#[derive(Clone, Copy)]
pub struct HexPixel {
pixels: [bool; 6],
}
#[rustfmt::skip]
impl HexPixel {
#[rustfmt::skip]
const CHARS: [char; 64] = [
' ', '🬀', '🬁', '🬂', '🬃', '🬄', '🬅', '🬆', '🬇', '🬈', '🬉', '🬊', '🬋', '🬌', '🬍', '🬎',
'🬏', '🬐', '🬑', '🬒', '🬓', '▌', '🬔', '🬕', '🬖', '🬗', '🬘', '🬙', '🬚', '🬛', '🬜', '🬝',
'🬞', '🬟', '🬠', '🬡', '🬢', '🬣', '🬤', '🬥', '🬦', '🬧', '▐', '🬨', '🬩', '🬪', '🬫', '🬬',
'🬭', '🬮', '🬯', '🬰', '🬱', '🬲', '🬳', '🬴', '🬵', '🬶', '🬷', '🬸', '🬹', '🬺', '🬻', '█'
];
#[rustfmt::skip]
const fn index(self) -> usize {
(self.pixels[0] as usize) |
(self.pixels[1] as usize) << 1 |
(self.pixels[2] as usize) << 2 |
(self.pixels[3] as usize) << 3 |
(self.pixels[4] as usize) << 4 |
(self.pixels[5] as usize) << 5
}
#[must_use]
pub const fn character(self) -> char {
Self::CHARS[self.index()]
}
}
impl Pixel for HexPixel {
type U = bool;
const WIDTH: usize = 2;
const HEIGHT: usize = 3;
impl_getters!(pixels: [bool; 6]);
impl_getters_mut!(pixels: [bool; 6]);
impl_new!(HexPixel, pixels: [bool; 6]);
}
impl_from_mono_chrome_pixel_for_datacell!(HexPixel);
#[derive(Clone, Copy)]
pub struct OctPixel {
pixels: [bool; 8],
}
#[rustfmt::skip]
impl OctPixel {
#[rustfmt::skip]
const CHARS: [char; 256] = [
' ', '', '', '🮂', '', '▘', '', '', '', '', '▝', '', '', '', '', '▀',
'', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '🮅',
'', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '',
'▖', '', '', '', '', '▌', '', '', '', '', '▞', '', '', '', '', '▛',
'', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '',
'▗', '', '', '', '', '▚', '', '', '', '', '▐', '', '', '', '', '▜',
'', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '',
'▂', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '',
'▄', '', '', '', '', '▙', '', '', '', '', '▟', '', '▆', '', '', '█',
];
#[rustfmt::skip]
const fn index(self) -> usize {
(self.pixels[0] as usize) |
(self.pixels[1] as usize) << 1 |
(self.pixels[2] as usize) << 2 |
(self.pixels[3] as usize) << 3 |
(self.pixels[4] as usize) << 4 |
(self.pixels[5] as usize) << 5 |
(self.pixels[6] as usize) << 6 |
(self.pixels[7] as usize) << 7
}
#[must_use]
pub const fn character(self) -> char {
Self::CHARS[self.index()]
}
}
impl Pixel for OctPixel {
type U = bool;
const WIDTH: usize = 2;
const HEIGHT: usize = 4;
impl_getters!(pixels: [bool; 8]);
impl_getters_mut!(pixels: [bool; 8]);
impl_new!(OctPixel, pixels: [bool; 8]);
}
impl_from_mono_chrome_pixel_for_datacell!(OctPixel);
#[derive(Clone, Copy)]
pub struct BrailleOctPixel {
pixels: [bool; 8],
}
impl BrailleOctPixel {
#[rustfmt::skip]
const CHARS: [char; 256] = [
'⠀', '⠁', '⠈', '⠉', '⠂', '⠃', '⠊', '⠋', '⠐', '⠑', '⠘', '⠙', '⠒', '⠓', '⠚', '⠛',
'⠄', '⠅', '⠌', '⠍', '⠆', '⠇', '⠎', '⠏', '⠔', '⠕', '⠜', '⠝', '⠖', '⠗', '⠞', '⠟',
'⠠', '⠡', '⠨', '⠩', '⠢', '⠣', '⠪', '⠫', '⠰', '⠱', '⠸', '⠹', '⠲', '⠳', '⠺', '⠻',
'⠤', '⠥', '⠬', '⠭', '⠦', '⠧', '⠮', '⠯', '⠴', '⠵', '⠼', '⠽', '⠶', '⠷', '⠾', '⠿',
'⡀', '⡁', '⡈', '⡉', '⡂', '⡃', '⡊', '⡋', '⡐', '⡑', '⡘', '⡙', '⡒', '⡓', '⡚', '⡛',
'⡄', '⡅', '⡌', '⡍', '⡆', '⡇', '⡎', '⡏', '⡔', '⡕', '⡜', '⡝', '⡖', '⡗', '⡞', '⡟',
'⡠', '⡡', '⡨', '⡩', '⡢', '⡣', '⡪', '⡫', '⡰', '⡱', '⡸', '⡹', '⡲', '⡳', '⡺', '⡻',
'⡤', '⡥', '⡬', '⡭', '⡦', '⡧', '⡮', '⡯', '⡴', '⡵', '⡼', '⡽', '⡶', '⡷', '⡾', '⡿',
'⢀', '⢁', '⢈', '⢉', '⢂', '⢃', '⢊', '⢋', '⢐', '⢑', '⢘', '⢙', '⢒', '⢓', '⢚', '⢛',
'⢄', '⢅', '⢌', '⢍', '⢆', '⢇', '⢎', '⢏', '⢔', '⢕', '⢜', '⢝', '⢖', '⢗', '⢞', '⢟',
'⢠', '⢡', '⢨', '⢩', '⢢', '⢣', '⢪', '⢫', '⢰', '⢱', '⢸', '⢹', '⢲', '⢳', '⢺', '⢻',
'⢤', '⢥', '⢬', '⢭', '⢦', '⢧', '⢮', '⢯', '⢴', '⢵', '⢼', '⢽', '⢶', '⢷', '⢾', '⢿',
'⣀', '⣁', '⣈', '⣉', '⣂', '⣃', '⣊', '⣋', '⣐', '⣑', '⣘', '⣙', '⣒', '⣓', '⣚', '⣛',
'⣄', '⣅', '⣌', '⣍', '⣆', '⣇', '⣎', '⣏', '⣔', '⣕', '⣜', '⣝', '⣖', '⣗', '⣞', '⣟',
'⣠', '⣡', '⣨', '⣩', '⣢', '⣣', '⣪', '⣫', '⣰', '⣱', '⣸', '⣹', '⣲', '⣳', '⣺', '⣻',
'⣤', '⣥', '⣬', '⣭', '⣦', '⣧', '⣮', '⣯', '⣴', '⣵', '⣼', '⣽', '⣶', '⣷', '⣾', '⣿',
];
#[rustfmt::skip]
const fn index(self) -> usize {
(self.pixels[0] as usize) |
(self.pixels[1] as usize) << 1 |
(self.pixels[2] as usize) << 2 |
(self.pixels[3] as usize) << 3 |
(self.pixels[4] as usize) << 4 |
(self.pixels[5] as usize) << 5 |
(self.pixels[6] as usize) << 6 |
(self.pixels[7] as usize) << 7
}
#[must_use]
pub const fn character(self) -> char {
Self::CHARS[self.index()]
}
}
impl Pixel for BrailleOctPixel {
type U = bool;
const WIDTH: usize = 2;
const HEIGHT: usize = 4;
impl_getters!(pixels: [bool; 8]);
impl_getters_mut!(pixels: [bool; 8]);
impl_new!(BrailleOctPixel, pixels: [bool; 8]);
}
impl_from_mono_chrome_pixel_for_datacell!(BrailleOctPixel);