Trait sfml::graphics::Transformable
source · pub trait Transformable {
Show 13 methods
fn set_position<P: Into<Vector2f>>(&mut self, position: P);
fn set_rotation(&mut self, angle: f32);
fn set_scale<S: Into<Vector2f>>(&mut self, scale: S);
fn set_origin<O: Into<Vector2f>>(&mut self, origin: O);
fn position(&self) -> Vector2f;
fn rotation(&self) -> f32;
fn get_scale(&self) -> Vector2f;
fn origin(&self) -> Vector2f;
fn move_<O: Into<Vector2f>>(&mut self, offset: O);
fn rotate(&mut self, angle: f32);
fn scale<F: Into<Vector2f>>(&mut self, factors: F);
fn transform(&self) -> &Transform;
fn inverse_transform(&self) -> &Transform;
}
Expand description
Decomposed transform defined by a position, a rotation and a scale.
Required Methods§
sourcefn set_position<P: Into<Vector2f>>(&mut self, position: P)
fn set_position<P: Into<Vector2f>>(&mut self, position: P)
Sets the position of the object.
This function completely overwrites the previous position.
See move_
to apply an offset based on the previous position instead.
The default position of a transformable object is (0, 0).
sourcefn set_rotation(&mut self, angle: f32)
fn set_rotation(&mut self, angle: f32)
Set the orientation of the object.
This function completely overwrites the previous rotation. See the rotate function to add an angle based on the previous rotation instead. The default rotation of a transformable object is 0.
sourcefn set_scale<S: Into<Vector2f>>(&mut self, scale: S)
fn set_scale<S: Into<Vector2f>>(&mut self, scale: S)
Sets the scale factors of the object.
This function completely overwrites the previous scale. See the scale function to add a factor based on the previous scale instead. The default scale of a transformable object is (1, 1).
sourcefn set_origin<O: Into<Vector2f>>(&mut self, origin: O)
fn set_origin<O: Into<Vector2f>>(&mut self, origin: O)
Sets the local origin of the object.
The origin of an object defines the center point for all transformations (position, scale, rotation). The coordinates of this point must be relative to the top-left corner of the object, and ignore all transformations (position, scale, rotation). The default origin of a transformable object is (0, 0).
sourcefn rotation(&self) -> f32
fn rotation(&self) -> f32
Gets the rotation of the object.
The rotation is always in the range [0, 360].
sourcefn move_<O: Into<Vector2f>>(&mut self, offset: O)
fn move_<O: Into<Vector2f>>(&mut self, offset: O)
Moves the object by a given offset.
This function adds to the current position of the object,
unlike set_position
which overwrites it.
sourcefn rotate(&mut self, angle: f32)
fn rotate(&mut self, angle: f32)
Rotates the object.
This function adds to the current rotation of the object, unlike
set_rotation
, which overwrites it.
sourcefn scale<F: Into<Vector2f>>(&mut self, factors: F)
fn scale<F: Into<Vector2f>>(&mut self, factors: F)
Scales the object.
This function multiplies the current scale of the object, unlike
set_scale
, which overwrites it.
sourcefn inverse_transform(&self) -> &Transform
fn inverse_transform(&self) -> &Transform
Gets the inverse combined transform of the object.