[][src]Struct vxdraw::dyntex::Dyntex

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

Accessor object to all dynamic textures

A dynamic texture is a texture which is used to display textured sprites. See crate::dyntex for examples.

Methods

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

pub fn new(s: &'a mut VxDraw) -> Self[src]

Prepare to edit dynamic textures

You're not supposed to use this function directly (although you can). The recommended way of spawning a dyntex is via VxDraw::dyntex().

pub fn add_layer<'x>(
    &mut self,
    img_data: &ImgData<'x>,
    options: &LayerOptions
) -> Layer
[src]

Add a 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, layer: Layer)[src]

Remove a layer

Removes the layer from memory and destroys all sprites associated with it. All lingering sprite handles that were spawned using this layer handle 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

The sprite is automatically drawn on each VxDraw::draw_frame call, and must be removed by Dyntex::remove to stop it from being drawn.

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 Dyntex::add with available holes will fill the first available hole with the new sprite.

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 Dyntex::deform. What this function does is just setting absolute vertex positions for each vertex in the sprite.

pub fn set_solid_color(&mut self, handle: &Handle, rgba: Color)[src]

Set a solid color of a quad

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

Set an opacity each vertex of a sprite

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

Set an opacity 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,
    angle: 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 dyntexs by adding delta vertices

Applies Dyntex::deform to each dynamic texture.

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

Translate all dyntexs by adding delta vertices

Applies Dyntex::translate to each dynamic texture.

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

Rotate all dyntexs by adding delta rotations

Applies Dyntex::rotate to each dynamic texture.

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

Scale all dyntexs by multiplying a delta scale

Applies Dyntex::scale to each dynamic texture.

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

Deform all dyntexs by setting delta vertices

Applies Dyntex::set_deform to each dynamic texture.

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

Set the color on all dyntexs

Applies Dyntex::set_solid_color to each dynamic texture.

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

Set the color on all dyntexs

Applies Dyntex::set_solid_color 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 dyntexs

Applies Dyntex::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 dyntexs

Applies Dyntex::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 dyntexs

Applies Dyntex::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 dyntexs

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

pub fn set_uvs<'b>(
    &mut self,
    uvs: impl Iterator<Item = (&'b Handle, (f32, f32), (f32, f32))>
)
[src]

Set the UV values of multiple sprites

Auto Trait Implementations

impl<'a> Unpin for Dyntex<'a>

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

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

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

impl<'a> !RefUnwindSafe for Dyntex<'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>,