pub struct TileRegion {
pub col: u32,
pub row: u32,
pub x: u32,
pub y: u32,
pub width: u32,
pub height: u32,
}Expand description
Pixel coordinates and dimensions of a single tile within a frame.
use oximedia_codec::tile_encoder::TileRegion;
let region = TileRegion::new(1, 0, 512, 0, 512, 288);
assert_eq!(region.area(), 512 * 288);
assert!(region.contains(600, 100));
assert!(!region.contains(200, 100)); // left of tileFields§
§col: u32Tile column index (0-based).
row: u32Tile row index (0-based).
x: u32X pixel offset from the left of the frame.
y: u32Y pixel offset from the top of the frame.
width: u32Tile width in pixels.
height: u32Tile height in pixels.
Implementations§
Source§impl TileRegion
impl TileRegion
Sourcepub const fn new(
col: u32,
row: u32,
x: u32,
y: u32,
width: u32,
height: u32,
) -> Self
pub const fn new( col: u32, row: u32, x: u32, y: u32, width: u32, height: u32, ) -> Self
Create a new TileRegion.
Sourcepub const fn contains(&self, px: u32, py: u32) -> bool
pub const fn contains(&self, px: u32, py: u32) -> bool
Returns true if the pixel (px, py) falls within this tile.
Sourcepub fn pixel_range_x(&self) -> Range<u32>
pub fn pixel_range_x(&self) -> Range<u32>
Pixel column range x..(x + width).
Sourcepub fn pixel_range_y(&self) -> Range<u32>
pub fn pixel_range_y(&self) -> Range<u32>
Pixel row range y..(y + height).
Trait Implementations§
Source§impl Clone for TileRegion
impl Clone for TileRegion
Source§fn clone(&self) -> TileRegion
fn clone(&self) -> TileRegion
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for TileRegion
impl Debug for TileRegion
Source§impl PartialEq for TileRegion
impl PartialEq for TileRegion
impl Eq for TileRegion
impl StructuralPartialEq for TileRegion
Auto Trait Implementations§
impl Freeze for TileRegion
impl RefUnwindSafe for TileRegion
impl Send for TileRegion
impl Sync for TileRegion
impl Unpin for TileRegion
impl UnsafeUnpin for TileRegion
impl UnwindSafe for TileRegion
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more