[][src]Struct vxdraw::strtex::Strtex

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

Accessor object to all streaming textures

A streaming texture is a texture which can be edited at run-time. Sprites are made from this texture and drawn to the screen. See crate::strtex for examples.

Methods

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

pub fn add_layer(&mut self, options: &LayerOptions) -> Layer[src]

Add a streaming texture layer to the system

You use a texture to create sprites. Sprites are rectangular views into a texture. Sprites based on different texures are drawn in the order in which the textures were allocated, that means that the first texture's sprites are drawn first, then, the second texture's sprites,and so on.

Each texture has options (See LayerOptions). This decides how the derivative sprites are drawn.

Note: Alpha blending with depth testing will make foreground transparency not be transparent. To make sure transparency works correctly you can turn off the depth test for foreground objects and ensure that the foreground texture is allocated last.

pub fn layer_count(&self) -> usize[src]

Query the amount of layers of this type there are

pub fn hide(&mut self, layer: &Layer)[src]

Disable drawing of the sprites at this layer

pub fn show(&mut self, layer: &Layer)[src]

Enable drawing of the sprites at this layer

pub fn remove_layer(&mut self, texture: Layer)[src]

Remove a texture (layer)

This also stops drawing all associated sprites, so the sprite handles that use this layer that still exist will be invalidated.

pub fn add(&mut self, layer: &Layer, sprite: Sprite) -> Handle[src]

Add a sprite (a rectangular view of a texture) to the system

pub fn remove(&mut self, handle: Handle)[src]

Removes a single sprite, making it not be drawn

The sprite is set to a scale of 0 and its handle is stored internally in a list of holes. Calling Strtex::add with available holes will fill the first available hole with the new sprite.

pub fn remove_all(&mut self, layer: &Layer)[src]

Removes all sprites, clearing the layer

pub fn sprite_count(&mut self, layer: &Layer) -> usize[src]

Get the current number of sprites

pub fn set_pixel(&mut self, id: &Layer, w: u32, h: u32, color: Color)[src]

Set the color of a specific pixel

pub fn set_pixels(
    &mut self,
    id: &Layer,
    modifier: impl Iterator<Item = (u32, u32, Color)>
)
[src]

Set multiple pixels in the texture

pub fn set_pixels_block(
    &mut self,
    id: &Layer,
    start: (u32, u32),
    wh: (u32, u32),
    color: Color
)
[src]

Set a block of pixels

pub fn set_deform(&mut self, handle: &Handle, points: [(f32, f32); 4])[src]

Change the vertices of the model-space

The name set_deform is used to keep consistent Strtex::deform. What this function does is just setting absolute vertex positions for each vertex in the sprite.

pub fn set_opacity(&mut self, handle: &Handle, opacity: u8)[src]

Set a solid color each vertex of a sprite

pub fn set_opacity_raw(&mut self, handle: &Handle, opacity: [u8; 4])[src]

Set a solid color each vertex of a sprite

pub fn set_translation(&mut self, handle: &Handle, position: (f32, f32))[src]

Set the position of a sprite

pub fn set_rotation<T: Copy + Into<Rad<f32>>>(
    &mut self,
    handle: &Handle,
    rotation: T
)
[src]

Set the rotation of a sprite

Positive rotation goes counter-clockwise. The value of the rotation is in radians.

pub fn set_scale(&mut self, handle: &Handle, scale: f32)[src]

Set the scale of a sprite

pub fn set_uv(
    &mut self,
    handle: &Handle,
    uv_begin: (f32, f32),
    uv_end: (f32, f32)
)
[src]

Set the UV values of a single sprite

pub fn set_uv_raw(&mut self, handle: &Handle, uvs: [(f32, f32); 4])[src]

Set the raw UV values of each vertex in a sprite

This may be used to repeat a texture multiple times over the same sprite, or to do something exotic with uv coordinates.

pub fn deform(&mut self, handle: &Handle, delta: [(f32, f32); 4])[src]

Deform a sprite by adding delta vertices

Adds the delta vertices to the sprite. Beware: This changes model space form.

pub fn translate(&mut self, handle: &Handle, movement: (f32, f32))[src]

Translate a sprite by a vector

Translation does not mutate the model-space of a sprite.

pub fn rotate<T: Copy + Into<Rad<f32>>>(&mut self, handle: &Handle, angle: T)[src]

Rotate a sprite

Rotation does not mutate the model-space of a sprite.

pub fn scale(&mut self, handle: &Handle, scale: f32)[src]

Scale a sprite

Scale does not mutate the model-space of a sprite.

pub fn deform_all(
    &mut self,
    layer: &Layer,
    delta: impl FnMut(usize) -> [(f32, f32); 4]
)
[src]

Deform all strtexs by adding delta vertices

Applies Strtex::deform to each dynamic texture.

pub fn translate_all(
    &mut self,
    layer: &Layer,
    delta: impl FnMut(usize) -> (f32, f32)
)
[src]

Translate all strtexs by adding delta vertices

Applies Strtex::translate to each dynamic texture.

pub fn set_opacity_all(&mut self, layer: &Layer, delta: impl FnMut(usize) -> u8)[src]

Set opacity on all sprites

pub fn rotate_all<T: Copy + Into<Rad<f32>>>(
    &mut self,
    layer: &Layer,
    delta: impl FnMut(usize) -> T
)
[src]

Rotate all strtexs by adding delta rotations

Applies Strtex::rotate to each dynamic texture.

pub fn scale_all(&mut self, layer: &Layer, delta: impl FnMut(usize) -> f32)[src]

Scale all strtexs by multiplying a delta scale

Applies Strtex::scale to each dynamic texture.

pub fn set_deform_all(
    &mut self,
    layer: &Layer,
    delta: impl FnMut(usize) -> [(f32, f32); 4]
)
[src]

Deform all strtexs by setting delta vertices

Applies Strtex::set_deform to each dynamic texture.

pub fn set_translation_all(
    &mut self,
    layer: &Layer,
    delta: impl FnMut(usize) -> (f32, f32)
)
[src]

Set the translation on all strtexs

Applies Strtex::set_translation to each dynamic texture.

pub fn set_uv_all(
    &mut self,
    layer: &Layer,
    delta: impl FnMut(usize) -> [(f32, f32); 2]
)
[src]

Set the uv on all strtexs

Applies Strtex::set_uv to each dynamic texture.

pub fn set_rotation_all<T: Copy + Into<Rad<f32>>>(
    &mut self,
    layer: &Layer,
    delta: impl FnMut(usize) -> T
)
[src]

Set the rotation on all strtexs

Applies Strtex::set_rotation to each dynamic texture.

pub fn set_scale_all(&mut self, layer: &Layer, delta: impl FnMut(usize) -> f32)[src]

Set the scale on all strtexs

Applies Strtex::set_scale to each dynamic texture. Note: This may re-enable removed sprites, see Strtex::remove.

pub fn read(&mut self, id: &Layer, map: impl FnMut(&[(u8, u8, u8, u8)], usize))[src]

Read pixels from arbitrary coordinates

pub fn write(
    &mut self,
    id: &Layer,
    map: impl FnMut(&mut [(u8, u8, u8, u8)], usize)
)
[src]

Write pixels to arbitrary coordinates

pub fn write_all(&mut self, id: &Layer, color: (u8, u8, u8, u8))[src]

Write a color to all pixels

pub fn fill_with_perlin_noise(&mut self, blitid: &Layer, seed: [f32; 3])[src]

Fills the streaming texture with perlin noise generated from an input seed

Auto Trait Implementations

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

impl<'a> Unpin for Strtex<'a>

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

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

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

Blanket Implementations

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

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

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.

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

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

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

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

impl<T> SetParameter for T

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,