pub struct Transform {
pub position: Vec2,
pub rotation: Angle,
pub scale: Vec2,
pub parent: Option<usize>,
/* private fields */
}Expand description
A 2D transform representing position, rotation, and scale.
Supports parent-child hierarchies so that child transforms inherit their parent’s world-space transform.
Fields§
§position: Vec2Local position relative to parent.
rotation: AngleLocal rotation in radians.
scale: Vec2Local scale (independent X/Y).
parent: Option<usize>Optional parent reference index (used by [SceneNode]).
Implementations§
Source§impl Transform
impl Transform
Sourcepub fn new(x: f32, y: f32, rotation_degrees: f32, scale: f32) -> Self
pub fn new(x: f32, y: f32, rotation_degrees: f32, scale: f32) -> Self
Create a transform with position, rotation (degrees), and uniform scale.
Sourcepub fn set_position(&mut self, pos: Vec2)
pub fn set_position(&mut self, pos: Vec2)
Set position and mark dirty.
Sourcepub fn set_rotation_degrees(&mut self, degrees: f32)
pub fn set_rotation_degrees(&mut self, degrees: f32)
Set rotation in degrees and mark dirty.
Sourcepub fn set_scale_vec(&mut self, s: Vec2)
pub fn set_scale_vec(&mut self, s: Vec2)
Set non-uniform scale and mark dirty.
Sourcepub fn local_matrix(&self) -> Mat4
pub fn local_matrix(&self) -> Mat4
Get the local-space 4×4 matrix (TR × S).
Sourcepub fn world_matrix(&mut self, parent_world: Option<Mat4>) -> Mat4
pub fn world_matrix(&mut self, parent_world: Option<Mat4>) -> Mat4
Get the world-space matrix, recomputing if dirty.
If a parent index is set, the parent’s world matrix should be passed.
Sourcepub fn mark_dirty(&mut self)
pub fn mark_dirty(&mut self)
Invalidate the world matrix, forcing recomputation next frame.
Sourcepub fn world_position(&self) -> Vec2
pub fn world_position(&self) -> Vec2
Extract the world-space position from the world matrix.
Sourcepub fn transform_point(&self, local_point: Vec2) -> Vec2
pub fn transform_point(&self, local_point: Vec2) -> Vec2
Transform a local point to world space.
Sourcepub fn inverse_transform_point(&self, world_point: Vec2) -> Vec2
pub fn inverse_transform_point(&self, world_point: Vec2) -> Vec2
Inverse-transform a world point to local space.