feat: add periodic image saving
This commit is contained in:
parent
6da19152ca
commit
0502f3dacb
6 changed files with 1085 additions and 6 deletions
17
src/grid.rs
17
src/grid.rs
|
|
@ -1,5 +1,7 @@
|
|||
use std::cell::SyncUnsafeCell;
|
||||
|
||||
use image::{DynamicImage, GenericImage, GenericImageView, ImageBuffer, Pixel, Rgb, Rgba};
|
||||
|
||||
use crate::Coordinate;
|
||||
|
||||
pub trait Grid<I, V> {
|
||||
|
|
@ -63,6 +65,21 @@ impl<T> Grid<Coordinate, T> for Flut<T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl GenericImageView for Flut<u32> {
|
||||
type Pixel = Rgb<u8>;
|
||||
|
||||
fn dimensions(&self) -> (u32, u32) {
|
||||
let (x, y) = self.get_size();
|
||||
(x as u32, y as u32)
|
||||
}
|
||||
|
||||
fn get_pixel(&self, x: u32, y: u32) -> Self::Pixel {
|
||||
let pixel = self.get_unchecked(x as u16, y as u16);
|
||||
let [r, g, b, _a] = pixel.to_be_bytes();
|
||||
Rgb::from([r, g, b])
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[allow(clippy::needless_return)]
|
||||
mod tests {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue