Skip to content

Commit

Permalink
API to get screen size
Browse files Browse the repository at this point in the history
  • Loading branch information
Seldom-SE committed Jun 2, 2024
1 parent d1dcaf4 commit a1c7638
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
5 changes: 1 addition & 4 deletions src/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@ impl<P: Pixel> PxImage<P> {
}

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 {
Expand Down
10 changes: 9 additions & 1 deletion src/screen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Image>,
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;

Expand Down
1 change: 1 addition & 0 deletions src/sprite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ fn image_to_sprite(
.total_cmp(&color_2.distance_squared(color))
})
.unwrap();

*pixel = Some(index as u8);
}
});
Expand Down

0 comments on commit a1c7638

Please sign in to comment.