mechthild/core/src/lib.rs
2025-04-22 08:52:10 -04:00

38 lines
749 B
Rust

#[cfg(feature = "bytemuck")]
pub mod impl_bytemuck;
pub mod color;
use color::Rgba;
pub struct Scene;
impl Scene {
pub fn new() -> Self {
Self
}
pub fn render(&self, width: usize, height: usize) -> Box<[Rgba]> {
let mut data = Box::new_uninit_slice(width * height);
for (i, pixel) in data.iter_mut().enumerate() {
let x = (i % width) as f32;
let y = (i / width) as f32;
pixel.write(Rgba::new(
x / (width - 1) as f32,
y / (height - 1) as f32,
0.5,
1.0,
));
}
unsafe { data.assume_init() }
}
}
impl Default for Scene {
fn default() -> Self {
Self::new()
}
}