Struct lotus_script::graphics::textures::Texture
source · pub struct Texture(/* private fields */);
Expand description
A texture that can be manipulated and displayed on script texture slots.
Implementations§
source§impl Texture
impl Texture
sourcepub fn create<'a>(options: impl Into<TextureCreationOptions<'a>>) -> Self
pub fn create<'a>(options: impl Into<TextureCreationOptions<'a>>) -> Self
Create a new texture.
sourcepub fn add_action(&mut self, action: TextureAction)
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.
sourcepub fn draw_rect(
&mut self,
start: impl Into<UVec2>,
end: impl Into<UVec2>,
color: Color
)
pub fn draw_rect( &mut self, start: impl Into<UVec2>, end: impl Into<UVec2>, color: Color )
Draw a rectangle on the texture.
sourcepub fn read_pixel(&self, x: u32, y: u32) -> Color
pub fn read_pixel(&self, x: u32, y: u32) -> Color
Read the color of a pixel on the texture.
sourcepub fn draw_pixels<P>(&mut self, pixels: &[P])
pub fn draw_pixels<P>(&mut self, pixels: &[P])
Draw multiple pixels on the texture.
sourcepub fn draw_texture(&mut self, other: &Texture, options: DrawTextureOpts)
pub fn draw_texture(&mut self, other: &Texture, options: DrawTextureOpts)
Draws another texture on top of this one.
sourcepub fn apply_to(&mut self, name: &str)
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.
sourcepub fn flush(&mut self) -> bool
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.
sourcepub fn draw_script_texture(&mut self, other: &Texture, options: DrawTextureOpts)
pub fn draw_script_texture(&mut self, other: &Texture, options: DrawTextureOpts)
Draws another texture on top of this one.
sourcepub 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
)
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.
sourcepub fn handle(&self) -> TextureHandle
pub fn handle(&self) -> TextureHandle
Get the handle of the texture.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Texture
impl RefUnwindSafe for Texture
impl Send for Texture
impl Sync for Texture
impl Unpin for Texture
impl UnwindSafe for Texture
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more