Struct agb::display::bitmap4::Bitmap4

source ·
#[non_exhaustive]
pub struct Bitmap4<'gba> { /* private fields */ }

Implementations§

source§

impl Bitmap4<'_>

source

pub fn draw_point_page(&mut self, x: i32, y: i32, colour: u8, page: Page)

Draws point on specified page at (x, y) coordinates with colour index whose colour is specified in the background palette. Panics if (x, y) is out of the bounds of the screen.

Examples found in repository?
examples/multiple_video.rs (lines 57-62)
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
fn bitmap4_mode(
    bitmap: &mut display::bitmap4::Bitmap4,
    vblank: &agb::interrupt::VBlank,
    input: &mut agb::input::ButtonController,
) {
    bitmap.set_palette_entry(1, 0x001F);
    bitmap.set_palette_entry(2, 0x03E0);

    bitmap.draw_point_page(
        display::WIDTH / 2,
        display::HEIGHT / 2,
        1,
        display::bitmap4::Page::Front,
    );
    bitmap.draw_point_page(
        display::WIDTH / 2 + 5,
        display::HEIGHT / 2,
        2,
        display::bitmap4::Page::Back,
    );

    let mut count = 0;
    loop {
        vblank.wait_for_vblank();

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

        count += 1;
        if count % 6 == 0 {
            bitmap.flip_page();
        }
    }
}
source

pub fn draw_point(&mut self, x: i32, y: i32, colour: u8)

Draws point on the non-current page at (x, y) coordinates with colour index whose colour is specified in the background palette. Panics if (x, y) is out of the bounds of the screen.

source

pub fn set_palette_entry(&mut self, entry: u32, colour: u16)

Sets the colour of colour index in the background palette.

Examples found in repository?
examples/multiple_video.rs (line 54)
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
fn bitmap4_mode(
    bitmap: &mut display::bitmap4::Bitmap4,
    vblank: &agb::interrupt::VBlank,
    input: &mut agb::input::ButtonController,
) {
    bitmap.set_palette_entry(1, 0x001F);
    bitmap.set_palette_entry(2, 0x03E0);

    bitmap.draw_point_page(
        display::WIDTH / 2,
        display::HEIGHT / 2,
        1,
        display::bitmap4::Page::Front,
    );
    bitmap.draw_point_page(
        display::WIDTH / 2 + 5,
        display::HEIGHT / 2,
        2,
        display::bitmap4::Page::Back,
    );

    let mut count = 0;
    loop {
        vblank.wait_for_vblank();

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

        count += 1;
        if count % 6 == 0 {
            bitmap.flip_page();
        }
    }
}
source

pub fn flip_page(&mut self)

Flips page, changing the Gameboy advance to draw the contents of the other page

Examples found in repository?
examples/multiple_video.rs (line 81)
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
fn bitmap4_mode(
    bitmap: &mut display::bitmap4::Bitmap4,
    vblank: &agb::interrupt::VBlank,
    input: &mut agb::input::ButtonController,
) {
    bitmap.set_palette_entry(1, 0x001F);
    bitmap.set_palette_entry(2, 0x03E0);

    bitmap.draw_point_page(
        display::WIDTH / 2,
        display::HEIGHT / 2,
        1,
        display::bitmap4::Page::Front,
    );
    bitmap.draw_point_page(
        display::WIDTH / 2 + 5,
        display::HEIGHT / 2,
        2,
        display::bitmap4::Page::Back,
    );

    let mut count = 0;
    loop {
        vblank.wait_for_vblank();

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

        count += 1;
        if count % 6 == 0 {
            bitmap.flip_page();
        }
    }
}

Auto Trait Implementations§

§

impl<'gba> RefUnwindSafe for Bitmap4<'gba>

§

impl<'gba> Send for Bitmap4<'gba>

§

impl<'gba> Sync for Bitmap4<'gba>

§

impl<'gba> Unpin for Bitmap4<'gba>

§

impl<'gba> UnwindSafe for Bitmap4<'gba>

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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, U> TryFrom<U> for Twhere 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 Twhere 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.