mirl 9.2.0

Miners Rust Lib - A massive collection of ever growing and changing functions, structs, and enums. Check the description for compatibility and toggleable features! (Most of the lib is controlled by flags/features so the lib can continue to be lightweight despite its size)
use super::ConstBuffer;

impl<const WIDTH: usize, const HEIGHT: usize> ConstBuffer<WIDTH, HEIGHT>
where
    [(); WIDTH * HEIGHT]:,
{
    #[must_use]
    /// Create a new buffer
    pub const fn new(data: [u32; WIDTH * HEIGHT]) -> Self {
        Self {
            data,
        }
    }

    #[must_use]
    /// Create a new, empty, [`ConstBuffer`]
    pub const fn new_empty() -> Self {
        Self {
            data: [0; WIDTH * HEIGHT],
        }
    }
    #[must_use]
    /// Create a new [`ConstBuffer`] filled with the specified color
    pub const fn new_empty_with_color(color: u32) -> Self {
        Self {
            data: [color; WIDTH * HEIGHT],
        }
    }
    #[must_use]
    #[allow(clippy::missing_panics_doc)]
    /// Generate a error texture with the desired size
    pub fn generate_fallback(squares: usize) -> Self {
        let mut data = [0; WIDTH * HEIGHT];
        let square_size = WIDTH.midpoint(HEIGHT) / squares;

        let purple = crate::graphics::rgba_to_u32(128, 0, 128, 255);
        let black = crate::graphics::rgba_to_u32(0, 0, 0, 255);

        for y in 0..HEIGHT {
            for x in 0..WIDTH {
                let square_x = x / square_size;
                let square_y = y / square_size;

                let color = if (square_x + square_y).is_multiple_of(2) {
                    purple
                } else {
                    black
                };
                data[y * WIDTH + x] = color;
            }
        }
        Self::new(data)
    }
}