use crate::{core::checkerboard::*, noise_fns::NoiseFn};
#[derive(Clone, Copy, Debug)]
pub struct Checkerboard {
size: usize,
}
impl Checkerboard {
const DEFAULT_SIZE: usize = 0;
pub fn new(size: usize) -> Self {
Self { size: 1 << size }
}
pub fn set_size(self, size: usize) -> Self {
Self { size: 1 << size }
}
pub fn size(self) -> usize {
self.size
}
}
impl Default for Checkerboard {
fn default() -> Self {
Self {
size: 1 << Checkerboard::DEFAULT_SIZE,
}
}
}
impl NoiseFn<f64, 2> for Checkerboard {
fn get(&self, point: [f64; 2]) -> f64 {
checkerboard_2d(point.into(), self.size as f64)
}
}
impl NoiseFn<f64, 3> for Checkerboard {
fn get(&self, point: [f64; 3]) -> f64 {
checkerboard_3d(point.into(), self.size as f64)
}
}
impl NoiseFn<f64, 4> for Checkerboard {
fn get(&self, point: [f64; 4]) -> f64 {
checkerboard_4d(point.into(), self.size as f64)
}
}