SpriteMutRef

Struct SpriteMutRef 

Source
pub struct SpriteMutRef<'spr> { /* private fields */ }

Implementations§

Source§

impl<'spr> SpriteMutRef<'spr>

Source

pub fn get_pixel(&self, p: impl Into<Vu2d>) -> Option<Color>

Source

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>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'spr> DrawSpriteTrait for SpriteMutRef<'spr>

Source§

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)

§Safety

its up to the caller to make sure that the given position is in bounds

Source§

fn get_pixel(&self, pos: Vi2d) -> Option<Color>

Source§

fn set_pixel(&mut self, pos: Vi2d, col: Color)

Source§

fn size(&self) -> Vu2d

Source§

impl<'spr> Drop for SpriteMutRef<'spr>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.