pub struct SpriteMutRef<'spr> { /* private fields */ }Implementations§
Source§impl<'spr> SpriteMutRef<'spr>
impl<'spr> SpriteMutRef<'spr>
pub fn get_pixel(&self, p: impl Into<Vu2d>) -> Option<Color>
Sourcepub fn set_pixel(&mut self, p: impl Into<Vu2d>, col: impl Into<Color>)
pub fn set_pixel(&mut self, p: impl Into<Vu2d>, col: impl Into<Color>)
Examples found in repository?
examples/sub_sprite.rs (line 25)
8fn main() {
9 let spr = Sprite::new_with_color(20, 20, Color::GREEN);
10 let sub1 = spr.create_sub_sprite((0, 0).into(), (10, 10).into());
11 let sub2 = spr.create_sub_sprite((0, 10).into(), (10, 10).into());
12 let sub3 = spr.create_sub_sprite((10, 0).into(), (10, 10).into());
13 let sub4 = spr.create_sub_sprite((10, 10).into(), (10, 10).into());
14 let subs = [
15 (sub1, Color::BLUE),
16 (sub2, Color::YELLOW),
17 (sub3, Color::WHITE),
18 (sub4, Color::BLACK),
19 ];
20
21 for (sub, col) in subs {
22 let mut sub = sub.unwrap();
23 for y in 0..10u32 {
24 for x in 0..10u32 {
25 sub.set_pixel(Vu2d { x, y }, col);
26 }
27 }
28 }
29
30 print_sprite(&spr);
31}Trait Implementations§
Source§impl<'spr> Debug for SpriteMutRef<'spr>
impl<'spr> Debug for SpriteMutRef<'spr>
Source§impl<'spr> DrawSpriteTrait for SpriteMutRef<'spr>
impl<'spr> DrawSpriteTrait for SpriteMutRef<'spr>
Source§unsafe fn get_pixel_unchecked(&self, pos: Vu2d) -> Color
unsafe fn get_pixel_unchecked(&self, pos: Vu2d) -> Color
§Safety
its up to the caller to make sure that the given position is in bounds
Source§unsafe fn set_pixel_unchecked(&mut self, pos: Vu2d, col: Color)
unsafe fn set_pixel_unchecked(&mut self, pos: Vu2d, col: Color)
§Safety
its up to the caller to make sure that the given position is in bounds
fn get_pixel(&self, pos: Vi2d) -> Option<Color>
fn set_pixel(&mut self, pos: Vi2d, col: Color)
fn size(&self) -> Vu2d
Source§impl<'spr> Drop for SpriteMutRef<'spr>
impl<'spr> Drop for SpriteMutRef<'spr>
impl<'spr> Send for SpriteMutRef<'spr>
Auto Trait Implementations§
impl<'spr> Freeze for SpriteMutRef<'spr>
impl<'spr> !RefUnwindSafe for SpriteMutRef<'spr>
impl<'spr> !Sync for SpriteMutRef<'spr>
impl<'spr> Unpin for SpriteMutRef<'spr>
impl<'spr> !UnwindSafe for SpriteMutRef<'spr>
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> 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