[][src]Struct yagl::AppContext

pub struct AppContext<'a> { /* fields omitted */ }

A reference to an instance of this struct is passed to most methods on Game. This struct allows Game methods to be able to interact with yagl about App related things (e.g. requesting to exit)

Implementations

impl<'a> AppContext<'a>[src]

pub fn exit(&mut self)[src]

impl<'a> AppContext<'a>[src]

Graphics methods

pub fn scale(&self) -> [f32; 2][src]

Returns the bounds of the visible screen

By default, the scale is set such that they correspond to the size of the screen in pixels, but this can be overriden by explicitly calling set_scale

When the window is resized, the scale will always be rescaled to match the default. To override this behavior, you should implement Game::resize

pub fn set_scale(&mut self, scale: [f32; 2])[src]

pub fn new_sheet_from_bytes(&mut self, bytes: &[u8]) -> Result<Rc<SpriteSheet>>[src]

Creates a new sprite sheet from the bytes of some image file. The data is ultimately parsed passing to the load_from_memory function in the image crate.

pub fn new_sheet_from_colors<C, V>(
    &mut self,
    width: u32,
    height: u32,
    colors: V
) -> Result<Rc<SpriteSheet>> where
    C: Into<Color>,
    V: IntoIterator<Item = C>, 
[src]

Creates a new sprite sheet from explicitly specified colors

pub fn new_sheet_from_color<C: Into<Color>>(
    &mut self,
    color: C
) -> Result<Rc<SpriteSheet>>
[src]

Creates a new sprite sheet 1 pixel by 1 pixel wide with the given color

pub fn new_sheet_from_rgba_bytes(
    &mut self,
    width: u32,
    height: u32,
    bytes: Vec<u8>
) -> Result<Rc<SpriteSheet>>
[src]

Creates a new sprite sheet from a Vec of rgba data

pub fn load_courier_font_sheet(&mut self) -> Result<Rc<SpriteSheet>>[src]

pub fn new_batch(&mut self, sheet: Rc<SpriteSheet>) -> Result<SpriteBatch>[src]

Creates a new SpriteBatch from a SpriteSheet

pub fn new_batch_from_color<C: Into<Color>>(
    &mut self,
    color: C
) -> Result<SpriteBatch>
[src]

pub fn new_text_grid(
    &mut self,
    char_width: f32,
    dim: [u32; 2]
) -> Result<TextGrid>
[src]

Create a new text grid from a character width and [nrows, ncols] pair. Uses the default courier font bundled with A2D

Auto Trait Implementations

impl<'a> !RefUnwindSafe for AppContext<'a>

impl<'a> !Send for AppContext<'a>

impl<'a> !Sync for AppContext<'a>

impl<'a> Unpin for AppContext<'a>

impl<'a> !UnwindSafe for AppContext<'a>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> SetParameter for T

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.