2019-01-14 18:49:53 +00:00
|
|
|
use crate::vol::Vox;
|
2019-06-06 14:48:41 +00:00
|
|
|
use vek::*;
|
2019-01-14 18:49:53 +00:00
|
|
|
|
2019-05-17 09:22:32 +00:00
|
|
|
/// A type representing a single voxel in a figure.
|
2019-08-19 02:57:41 +00:00
|
|
|
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
2019-01-13 20:53:55 +00:00
|
|
|
pub enum Cell {
|
|
|
|
Filled([u8; 3]),
|
|
|
|
Empty,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Cell {
|
|
|
|
pub fn new(rgb: Rgb<u8>) -> Self {
|
|
|
|
Cell::Filled(rgb.into_array())
|
|
|
|
}
|
|
|
|
|
2019-01-14 18:49:53 +00:00
|
|
|
pub fn get_color(&self) -> Option<Rgb<u8>> {
|
2019-01-13 20:53:55 +00:00
|
|
|
match self {
|
2019-01-14 18:49:53 +00:00
|
|
|
Cell::Filled(col) => Some(Rgb::from(*col)),
|
|
|
|
Cell::Empty => None,
|
2019-01-13 20:53:55 +00:00
|
|
|
}
|
|
|
|
}
|
2019-01-14 18:49:53 +00:00
|
|
|
}
|
2019-01-13 20:53:55 +00:00
|
|
|
|
2019-01-14 18:49:53 +00:00
|
|
|
impl Vox for Cell {
|
|
|
|
fn empty() -> Self {
|
|
|
|
Cell::Empty
|
|
|
|
}
|
|
|
|
|
|
|
|
fn is_empty(&self) -> bool {
|
2019-01-13 20:53:55 +00:00
|
|
|
match self {
|
2019-01-14 18:49:53 +00:00
|
|
|
Cell::Filled(_) => false,
|
|
|
|
Cell::Empty => true,
|
2019-01-13 20:53:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|