pub struct ScreenOffset<const RANGE: i8 = 16> { /* private fields */ }Expand description
The picture position: pixels right of and below centre, each within
-RANGE..=RANGE. RANGE defaults to 16, WipEout’s and Hollow Knight’s.
use psx_display::ScreenOffset;
let offset = ScreenOffset::<16>::CENTRE.stepped_x(-3).stepped_y(2);
assert_eq!(offset.label_x().as_str(), "LEFT 3");
assert_eq!(offset.label_y().as_str(), "DOWN 2");
assert_eq!(offset.pixels(), (-3, 2));Implementations§
Source§impl<const RANGE: i8> ScreenOffset<RANGE>
impl<const RANGE: i8> ScreenOffset<RANGE>
Sourcepub const fn new(x: i8, y: i8) -> Self
pub const fn new(x: i8, y: i8) -> Self
The offset x pixels right and y down, each clamped to the range.
Sourcepub const fn stepped_x(self, delta: i8) -> Self
pub const fn stepped_x(self, delta: i8) -> Self
This offset with X moved by delta pixels, stopping at the ends.
Sourcepub const fn stepped_y(self, delta: i8) -> Self
pub const fn stepped_y(self, delta: i8) -> Self
This offset with Y moved by delta pixels, stopping at the ends.
Sourcepub const fn to_bytes(self) -> [u8; 2]
pub const fn to_bytes(self) -> [u8; 2]
The save bytes, X then Y, each in two’s complement; zero is centred, which is also what a save from before the setting reads as.
Sourcepub const fn from_bytes(bytes: [u8; 2]) -> Self
pub const fn from_bytes(bytes: [u8; 2]) -> Self
The offset two save bytes hold. Any bytes decode: a value outside the range is clamped to the nearest end.
Trait Implementations§
Source§impl<const RANGE: i8> Clone for ScreenOffset<RANGE>
impl<const RANGE: i8> Clone for ScreenOffset<RANGE>
Source§fn clone(&self) -> ScreenOffset<RANGE>
fn clone(&self) -> ScreenOffset<RANGE>
Returns a duplicate of the value. Read more
1.0.0§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<const RANGE: i8> Debug for ScreenOffset<RANGE>
impl<const RANGE: i8> Debug for ScreenOffset<RANGE>
Source§impl<const RANGE: i8> Default for ScreenOffset<RANGE>
impl<const RANGE: i8> Default for ScreenOffset<RANGE>
Source§fn default() -> ScreenOffset<RANGE>
fn default() -> ScreenOffset<RANGE>
Returns the “default value” for a type. Read more
Source§impl<const RANGE: i8> Hash for ScreenOffset<RANGE>
impl<const RANGE: i8> Hash for ScreenOffset<RANGE>
Source§impl<const RANGE: i8> PartialEq for ScreenOffset<RANGE>
impl<const RANGE: i8> PartialEq for ScreenOffset<RANGE>
impl<const RANGE: i8> Copy for ScreenOffset<RANGE>
impl<const RANGE: i8> Eq for ScreenOffset<RANGE>
impl<const RANGE: i8> StructuralPartialEq for ScreenOffset<RANGE>
Auto Trait Implementations§
impl<const RANGE: i8> Freeze for ScreenOffset<RANGE>
impl<const RANGE: i8> RefUnwindSafe for ScreenOffset<RANGE>
impl<const RANGE: i8> Send for ScreenOffset<RANGE>
impl<const RANGE: i8> Sync for ScreenOffset<RANGE>
impl<const RANGE: i8> Unpin for ScreenOffset<RANGE>
impl<const RANGE: i8> UnsafeUnpin for ScreenOffset<RANGE>
impl<const RANGE: i8> UnwindSafe for ScreenOffset<RANGE>
Blanket Implementations§
§impl<T> Any for Twhere
T: 'static + ?Sized,
impl<T> Any for Twhere
T: 'static + ?Sized,
§impl<T> Borrow<T> for Twhere
T: ?Sized,
impl<T> Borrow<T> for Twhere
T: ?Sized,
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit)