pub struct Texture(/* private fields */);
Expand description

A texture that can be manipulated and displayed on script texture slots.

Implementations§

source§

impl Texture

source

pub fn create<'a>(options: impl Into<TextureCreationOptions<'a>>) -> Self

Create a new texture.

source

pub fn add_action(&mut self, action: TextureAction)

Add an action to the texture. You may want to call the helper methods instead of this.

source

pub fn draw_rect( &mut self, start: impl Into<UVec2>, end: impl Into<UVec2>, color: Color )

Draw a rectangle on the texture.

source

pub fn clear(&mut self, color: Color)

Clear the texture with a color.

source

pub fn read_pixel(&self, x: u32, y: u32) -> Color

Read the color of a pixel on the texture.

source

pub fn draw_pixels<P>(&mut self, pixels: &[P])
where P: Into<DrawPixel> + Copy,

Draw multiple pixels on the texture.

source

pub fn draw_texture(&mut self, other: &Texture, options: DrawTextureOpts)

Draws another texture on top of this one.

source

pub fn apply_to(&mut self, name: &str)

Call this once for every game-texture you want to apply this to. You can define the name in the content tool.

source

pub fn flush(&mut self) -> bool

Only call this if you need your actions to be applied immediately. Cause of streaming assets, this method will return false if the actions are not yet applied. Just call this method again until it returns true.

source

pub fn draw_script_texture(&mut self, other: &Texture, options: DrawTextureOpts)

Draws another texture on top of this one.

source

pub fn draw_text( &mut self, font: ContentId, text: impl Into<String>, top_left: impl Into<UVec2>, letter_spacing: u32, full_color: impl Into<Option<Color>>, alpha_mode: AlphaMode )

Draws a text on the texture.

source

pub fn handle(&self) -> TextureHandle

Get the handle of the texture.

source

pub fn forget(self)

Forget the texture. This means it will not be disposed when the texture is dropped. Use this only if you want to keep the texture alive without keeping a reference to it.

Trait Implementations§

source§

impl Debug for Texture

source§

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

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

impl Drop for Texture

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl From<&Texture> for DrawableTexture

source§

fn from(texture: &Texture) -> Self

Converts to this type from the input type.

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

§

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

§

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.