[]Struct piston_window::deform::DeformGrid

pub struct DeformGrid {
    pub cols: usize,
    pub rows: usize,
    pub rect: [f64; 4],
    pub vertices: Vec<[f64; 2]>,
    pub indices: Vec<usize>,
    pub texture_coords: Vec<[f32; 2]>,
    pub ps: Vec<[f64; 2]>,
    pub qs: Vec<[f64; 2]>,
    pub wis: Vec<f64>,
}

Represents a deformed grid.

Fields

cols: usize

The number of columns in the grid.

rows: usize

The number of rows in the grid.

rect: [f64; 4]

The grid undeformed, which is a plain rectangle.

vertices: Vec<[f64; 2]>

The vertices, deformed.

indices: Vec<usize>

The triangle indices.

texture_coords: Vec<[f32; 2]>

The texture coordinates.

ps: Vec<[f64; 2]>

Initial position of control points.

qs: Vec<[f64; 2]>

The current position of control points.

wis: Vec<f64>

A weight computation buffer, one for each control point.

Methods

impl DeformGrid

pub fn new(rect: [f64; 4], cols: usize, rows: usize) -> DeformGrid

Creates a new DeformGrid.

pub fn set_current(&mut self, i: usize, pos: [f64; 2])

Sets current control position.

pub fn set_original(&mut self, i: usize, pos: [f64; 2])

Sets original control position.

pub fn reset_control_points(&mut self)

Removes all control points.

pub fn reset_vertices_and_texture_coords(&mut self)

Sets vertices and texture coords back to default.

pub fn hit(&self, pos: [f64; 2]) -> Option<[f64; 2]>

Finds original coordinate. If the deformed grid is overlapping itself, multiple hits might occur. Returns the first hit it finds.

pub fn draw_image<G>(
    &self,
    texture: &<G as Graphics>::Texture,
    draw_state: &DrawState,
    transform: [[f64; 3]; 2],
    g: &mut G
) where
    G: Graphics

Draws deformed image using default method.

pub fn draw_image_tri<G>(
    &self,
    texture: &<G as Graphics>::Texture,
    draw_state: &DrawState,
    transform: [[f64; 3]; 2],
    g: &mut G
) where
    G: Graphics

Draws deformed image using triangulation.

pub fn add_control_point(&mut self, pos: [f64; 2])

Adds a control point, in original coordinates.

pub fn draw_vertical_lines<G>(
    &self,
    line: &Line,
    draw_state: &DrawState,
    transform: [[f64; 3]; 2],
    g: &mut G
) where
    G: Graphics

Draw vertical grid lines.

pub fn draw_horizontal_lines<G>(
    &self,
    line: &Line,
    draw_state: &DrawState,
    transform: [[f64; 3]; 2],
    g: &mut G
) where
    G: Graphics

Draw horizontal grid lines.

pub fn update(&mut self)

Updates the grid, by deforming the vertices.

Trait Implementations

impl Clone for DeformGrid

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

Auto Trait Implementations

impl Send for DeformGrid

impl Sync for DeformGrid

Blanket Implementations

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

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> Into<U> for T where
    U: From<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> Borrow<T> for T where
    T: ?Sized
[src]

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

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

impl<T> SetParameter for T

fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Result where
    T: Parameter<Self>, 

Sets value as a parameter of self.

impl<T> Erased for T