pub struct Texture(/* private fields */);Expand description
Textur, die bearbeitet und auf Script-Textur-Slots angezeigt werden kann.
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
Erstellt eine neue Script-Textur.
Creates a new script texture.
Sourcepub fn add_action(&mut self, action: TextureAction)
pub fn add_action(&mut self, action: TextureAction)
Fügt eine Zeichenaktion zur Textur hinzu. Bevorzugt die Hilfsmethoden statt direktem Aufruf.
Adds a drawing action to the texture. Prefer the helper methods over calling this directly.
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, )
Zeichnet ein Rechteck auf die Textur.
Draws a rectangle on the texture.
Sourcepub fn clear(&mut self, color: Color)
pub fn clear(&mut self, color: Color)
Füllt die Textur mit einer Farbe.
Clears the texture with a color.
Sourcepub fn read_pixel(&self, x: u32, y: u32) -> Color
pub fn read_pixel(&self, x: u32, y: u32) -> Color
Liest die Farbe eines Pixels auf der Textur.
Reads 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])
Zeichnet mehrere Pixel auf die Textur.
Draws 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)
Zeichnet eine andere Textur über diese.
Draws another texture on top of this one.
Sourcepub fn apply_to(&mut self, name: &str)
pub fn apply_to(&mut self, name: &str)
Wendet die Textur auf einen benannten Spiel-Textur-Slot an (Name im Content-Tool). Einmal pro Ziel-Slot aufrufen.
Applies the texture to a named in-game texture slot (name defined in the content tool). Call once per target slot.
Sourcepub fn flush(&mut self) -> bool
pub fn flush(&mut self) -> bool
Wendet ausstehende Aktionen sofort an.
Kann false liefern, solange Assets noch streamen — erneut aufrufen, bis true.
Applies pending actions immediately.
May return false while assets are still streaming; call again until true.
Sourcepub fn draw_script_texture(&mut self, other: &Texture, options: DrawTextureOpts)
pub fn draw_script_texture(&mut self, other: &Texture, options: DrawTextureOpts)
Zeichnet eine andere Script-Textur über diese.
Draws another script texture on top of this one.
Sourcepub fn draw_text(
&mut self,
font: ContentId,
text: impl Into<String>,
top_left: impl Into<IVec2>,
letter_spacing: u32,
full_color: impl Into<Option<Color>>,
alpha_mode: AlphaMode,
target_rect: impl Into<Option<Rectangle>>,
)
pub fn draw_text( &mut self, font: ContentId, text: impl Into<String>, top_left: impl Into<IVec2>, letter_spacing: u32, full_color: impl Into<Option<Color>>, alpha_mode: AlphaMode, target_rect: impl Into<Option<Rectangle>>, )
Zeichnet Text auf die Textur.
Draws text on the texture.
Sourcepub fn handle(&self) -> TextureHandle
pub fn handle(&self) -> TextureHandle
Gibt den Handle der Textur zurück.
Returns the handle of the texture.
Sourcepub fn forget(self)
pub fn forget(self)
Verhindert das Freigeben beim Drop — Textur bleibt ohne Referenz bestehen. Nur verwenden, wenn die Textur absichtlich ohne Handle weiterleben soll.
Prevents disposal on drop so the texture outlives this handle. Use only when the texture should stay alive without a reference.