Struct graphics::deform::DeformGrid
[−]
[src]
pub struct DeformGrid { pub cols: usize, pub rows: usize, pub rect: [Scalar; 4], pub vertices: Vec<Vec2d>, pub indices: Vec<usize>, pub texture_coords: Vec<[f32; 2]>, pub ps: Vec<[Scalar; 2]>, pub qs: Vec<[Scalar; 2]>, pub wis: Vec<Scalar>, }
Represents a deformed grid.
Fields
cols | The number of columns in the grid. |
rows | The number of rows in the grid. |
rect | The grid undeformed, which is a plain rectangle. |
vertices | The vertices, deformed. |
indices | The triangle indices. |
texture_coords | The texture coordinates. |
ps | Initial position of control points. |
qs | The current position of control points. |
wis | A weight computation buffer, one for each control point. |
Methods
impl DeformGrid
fn new(rect: Rectangle, cols: usize, rows: usize) -> DeformGrid
Creates a new DeformGrid.
fn set_current(&mut self, i: usize, pos: Vec2d)
Sets current control position.
fn set_original(&mut self, i: usize, pos: Vec2d)
Sets original control position.
fn reset_control_points(&mut self)
Removes all control points.
fn reset_vertices_and_texture_coords(&mut self)
Sets vertices and texture coords back to default.
fn hit(&self, pos: Vec2d) -> Option<Vec2d>
Finds original coordinate. If the deformed grid is overlapping itself, multiple hits might occur. Returns the first hit it finds.
fn draw_image<G>(&self, texture: &G::Texture, draw_state: &DrawState, transform: Matrix2d, g: &mut G) where G: Graphics
Draws deformed image.
fn add_control_point(&mut self, pos: Vec2d)
Adds a control point, in original coordinates.
fn draw_vertical_lines<G>(&self, line: &Line, draw_state: &DrawState, transform: Matrix2d, g: &mut G) where G: Graphics
Draw vertical grid lines.
fn draw_horizontal_lines<G>(&self, line: &Line, draw_state: &DrawState, transform: Matrix2d, g: &mut G) where G: Graphics
Draw horizontal grid lines.
fn update(&mut self)
Updates the grid, by deforming the vertices.