Enum agb::display::object::Size

source ·
pub enum Size {
    S8x8 = 0,
    S16x16 = 1,
    S32x32 = 2,
    S64x64 = 3,
    S16x8 = 4,
    S32x8 = 5,
    S32x16 = 6,
    S64x32 = 7,
    S8x16 = 8,
    S8x32 = 9,
    S16x32 = 10,
    S32x64 = 11,
}
Expand description

The sizes of sprite supported by the GBA.

Variants§

§

S8x8 = 0

§

S16x16 = 1

§

S32x32 = 2

§

S64x64 = 3

§

S16x8 = 4

§

S32x8 = 5

§

S32x16 = 6

§

S64x32 = 7

§

S8x16 = 8

§

S8x32 = 9

§

S16x32 = 10

§

S32x64 = 11

Implementations§

source§

impl Size

source

pub const fn from_width_height(width: usize, height: usize) -> Self

Creates a size from width and height in pixels, panics if the width and height is not representable by GBA sprites.

source

pub const fn to_width_height(self) -> (usize, usize)

Returns the width and height of the size in pixels.

Examples found in repository?
examples/sprites.rs (line 86)
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
fn all_tags(gfx: &OamManaged) {
    let mut input = agb::input::ButtonController::new();
    let mut objs = Vec::new();

    for (i, v) in TAG_MAP.values().enumerate() {
        let x = (i % 7) as i32;
        let y = (i / 7) as i32;
        let sprite = v.sprite(0);
        let (size_x, size_y) = sprite.size().to_width_height();
        let (size_x, size_y) = (size_x as i32, size_y as i32);
        let mut obj = gfx.object_sprite(sprite);
        obj.show();
        obj.set_position((x * 32 + 16 - size_x / 2, y * 32 + 16 - size_y / 2));
        objs.push((obj, v));
    }

    let mut count = 0;
    let mut image = 0;

    let vblank = agb::interrupt::VBlank::get();

    loop {
        vblank.wait_for_vblank();

        input.update();

        if input.is_just_pressed(agb::input::Button::A) {
            break;
        }

        count += 1;

        if count % 5 == 0 {
            image += 1;
            for (obj, tag) in objs.iter_mut() {
                obj.set_sprite(gfx.sprite(tag.animation_sprite(image)));
            }
            gfx.commit();
        }
    }
}
source

pub const fn to_tiles_width_height(self) -> (usize, usize)

Returns the width and height of the size in pixels.

Trait Implementations§

source§

impl Clone for Size

source§

fn clone(&self) -> Size

Returns a copy of the value. Read more
1.0.0§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Size

source§

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

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

impl Hash for Size

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given [Hasher]. Read more
1.3.0§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given [Hasher]. Read more
source§

impl PartialEq for Size

source§

fn eq(&self, other: &Size) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Copy for Size

source§

impl Eq for Size

source§

impl StructuralPartialEq for Size

Auto Trait Implementations§

§

impl RefUnwindSafe for Size

§

impl Send for Size

§

impl Sync for Size

§

impl Unpin for Size

§

impl UnwindSafe for Size

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn into(self) -> U

Calls U::from(self).

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

§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
§

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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

§

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

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

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

Performs the conversion.