diff --git a/src/image.rs b/src/image.rs index 37323db..af35cda 100644 --- a/src/image.rs +++ b/src/image.rs @@ -23,10 +23,7 @@ impl PxImage

{ } pub(crate) fn empty_from_image(image: &Image) -> Self { - Self { - image: vec![default(); image.data.len()], - width: image.texture_descriptor.size.width as usize, - } + Self::empty(image.size()) } pub(crate) fn pixel(&self, position: IVec2) -> P { diff --git a/src/screen.rs b/src/screen.rs index 0bdfdba..e903e56 100644 --- a/src/screen.rs +++ b/src/screen.rs @@ -87,13 +87,21 @@ impl ScreenSize { } } +/// The image that `seldom_pixel` draws to #[derive(Clone, Resource)] -pub(crate) struct Screen { +pub struct Screen { pub(crate) image: Handle, pub(crate) size: ScreenSize, pub(crate) computed_size: UVec2, } +impl Screen { + /// Computed size of the screen + pub fn size(&self) -> UVec2 { + self.computed_size + } +} + #[derive(Component)] pub(crate) struct ScreenMarker; diff --git a/src/sprite.rs b/src/sprite.rs index a186946..a899853 100644 --- a/src/sprite.rs +++ b/src/sprite.rs @@ -254,6 +254,7 @@ fn image_to_sprite( .total_cmp(&color_2.distance_squared(color)) }) .unwrap(); + *pixel = Some(index as u8); } });