Struct TextureCache

Source
pub struct TextureCache { /* private fields */ }
Expand description

This is the structure for the TextureCache.

Implementations§

Source§

impl TextureCache

This is a Texture cache object that is used by the WidgetCache. This is responsible for loading in images into a cache in memory so that it can be copied multiple times as required by the application.

Source

pub fn new() -> Self

Creates a new TextureCache.

Source

pub fn get_ttf_context(&self) -> &Sdl2TtfContext

Retrieves the current Text Rendering context (Sdl2TtfContext)

Source

pub fn get_image( &mut self, c: &mut Canvas<Window>, image_name: String, ) -> &Texture

Loads an image based on the image_name, which is the filename for the image to load. Returns a reference to the Texture that was loaded.

Source

pub fn render_text( &mut self, c: &mut Canvas<Window>, font_name: String, font_size: u16, font_style: FontStyle, font_string: String, font_color: Color, width: u32, ) -> (Texture, u32, u32)

Renders text, given the font name, size, style, color, string, and max width. Transfers ownership of the Texture to the calling function, returns the width and height of the texture after rendering. By using the identical font name, size, and style, if SDL2 caches the font data, this will allow the font to be cached internally.

Trait Implementations§

Source§

impl Default for TextureCache

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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, 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.