pub struct ProjectiveTransform { /* private fields */ }Expand description
A projective mapping of a two-dimensional coordinate plane.
Implementations§
Source§impl ProjectiveTransform
impl ProjectiveTransform
Sourcepub const fn identity() -> ProjectiveTransform
pub const fn identity() -> ProjectiveTransform
Leaves positions unchanged.
Sourcepub fn translation(tx: f32, ty: f32) -> ProjectiveTransform
pub fn translation(tx: f32, ty: f32) -> ProjectiveTransform
Translates positions by the supplied logical-pixel offsets.
Sourcepub fn uniform_scale(scale: f32) -> ProjectiveTransform
pub fn uniform_scale(scale: f32) -> ProjectiveTransform
Uniform scale about the origin (device-scale root transform: render graphs stay in logical dp; density applies at execution).
Sourcepub fn from_rect_to_quad(rect: Rect, quad: [[f32; 2]; 4]) -> ProjectiveTransform
pub fn from_rect_to_quad(rect: Rect, quad: [[f32; 2]; 4]) -> ProjectiveTransform
Maps a rectangle to corners ordered top-left, top-right, bottom-left, bottom-right, with the whole rectangle in front of the eye.
Sourcepub const fn from_rows(matrix: [[f32; 3]; 3]) -> ProjectiveTransform
pub const fn from_rows(matrix: [[f32; 3]; 3]) -> ProjectiveTransform
The transform of a row-major homogeneous matrix, kept as it is: its
bottom row gives each point’s w, which NEAR_W cuts.
Sourcepub fn from_homogeneous(matrix: [[f32; 3]; 3]) -> ProjectiveTransform
pub fn from_homogeneous(matrix: [[f32; 3]; 3]) -> ProjectiveTransform
The transform a homogeneous matrix describes, scaled so its last entry
is one or minus one wherever that entry is not zero: its other entries
then read as the scale, turn, translation and perspective they are.
The scale is positive, so every point keeps the side of the eye its
homogeneous w puts it on.
Sourcepub fn then(self, next: ProjectiveTransform) -> ProjectiveTransform
pub fn then(self, next: ProjectiveTransform) -> ProjectiveTransform
Returns the composed transform that applies self first and next second.
Sourcepub fn inverse(self) -> Option<ProjectiveTransform>
pub fn inverse(self) -> Option<ProjectiveTransform>
Maps destination coordinates back to the source, unless the matrix is singular.
Sourcepub fn map_rect(&self, rect: Rect) -> [[f32; 2]; 4]
pub fn map_rect(&self, rect: Rect) -> [[f32; 2]; 4]
Maps a rectangle’s top-left, top-right, bottom-left and bottom-right corners.
Sourcepub fn in_front(&self, point: Point) -> bool
pub fn in_front(&self, point: Point) -> bool
Whether point lies in front of the eye of the transform’s
perspective, so that it maps to a position: its homogeneous w is at
least NEAR_W. Always true without perspective.
Sourcepub fn rect_in_front(&self, rect: Rect) -> bool
pub fn rect_in_front(&self, rect: Rect) -> bool
Whether all of rect lies in front of the eye.
Sourcepub fn map_point_in_front(&self, point: Point) -> Option<Point>
pub fn map_point_in_front(&self, point: Point) -> Option<Point>
Sourcepub fn front_polygon(&self, rect: Rect) -> FrontPolygon
pub fn front_polygon(&self, rect: Rect) -> FrontPolygon
Maps the part of rect in front of the eye: the rectangle cut where
its homogeneous w falls below NEAR_W, corners in order top-left,
top-right, bottom-right, bottom-left with the cut’s corners between.
Sourcepub fn bounds_for_rect(&self, rect: Rect) -> Rect
pub fn bounds_for_rect(&self, rect: Rect) -> Rect
Returns the axis-aligned bounds of the transformed rectangle’s part in front of the eye; empty when no part is.
Trait Implementations§
Source§impl Clone for ProjectiveTransform
impl Clone for ProjectiveTransform
Source§fn clone(&self) -> ProjectiveTransform
fn clone(&self) -> ProjectiveTransform
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more