Struct tetra::graphics::DrawParams
source · [−]pub struct DrawParams {
pub position: Vec2<f32>,
pub scale: Vec2<f32>,
pub origin: Vec2<f32>,
pub rotation: f32,
pub color: Color,
}
Expand description
Parameters that can be manipulated when drawing an object.
You can either use this as a builder by calling DrawParams::new
and then chaining methods, or
construct it manually - whichever you find more pleasant to write.
Fields
position: Vec2<f32>
The position that the graphic should be drawn at. Defaults to (0.0, 0.0)
.
scale: Vec2<f32>
The scale that the graphic should be drawn at. Defaults to (1.0, 1.0)
.
This can be set to a negative value to flip the graphic around the origin.
origin: Vec2<f32>
The origin of the graphic. Defaults to (0.0, 0.0)
(the top left).
This offset is applied before scaling, rotation and positioning. For example, if you have a 16x16 image and set the origin to [8.0, 8.0], subsequent transformations will be performed relative to the center of the image.
rotation: f32
The rotation of the graphic, in radians. Defaults to 0.0
.
color: Color
A color to multiply the graphic by. Defaults to Color::WHITE
.
Implementations
sourceimpl DrawParams
impl DrawParams
sourcepub fn new() -> DrawParams
pub fn new() -> DrawParams
Creates a new set of DrawParams
.
sourcepub fn position(self, position: Vec2<f32>) -> DrawParams
pub fn position(self, position: Vec2<f32>) -> DrawParams
Sets the position that the graphic should be drawn at.
sourcepub fn scale(self, scale: Vec2<f32>) -> DrawParams
pub fn scale(self, scale: Vec2<f32>) -> DrawParams
Sets the scale that the graphic should be drawn at.
sourcepub fn origin(self, origin: Vec2<f32>) -> DrawParams
pub fn origin(self, origin: Vec2<f32>) -> DrawParams
Sets the origin of the graphic.
sourcepub fn rotation(self, rotation: f32) -> DrawParams
pub fn rotation(self, rotation: f32) -> DrawParams
Sets the rotation of the graphic, in radians.
sourcepub fn color(self, color: Color) -> DrawParams
pub fn color(self, color: Color) -> DrawParams
Sets the color to multiply the graphic by.
Trait Implementations
sourceimpl Clone for DrawParams
impl Clone for DrawParams
sourcefn clone(&self) -> DrawParams
fn clone(&self) -> DrawParams
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for DrawParams
impl Debug for DrawParams
sourceimpl Default for DrawParams
impl Default for DrawParams
sourcefn default() -> DrawParams
fn default() -> DrawParams
Returns the “default value” for a type. Read more
sourceimpl From<DrawParams> for Mat4<f32>
impl From<DrawParams> for Mat4<f32>
sourcefn from(params: DrawParams) -> Self
fn from(params: DrawParams) -> Self
Converts to this type from the input type.
sourceimpl From<Vec2<f32>> for DrawParams
impl From<Vec2<f32>> for DrawParams
sourcefn from(position: Vec2<f32>) -> DrawParams
fn from(position: Vec2<f32>) -> DrawParams
Converts to this type from the input type.
sourceimpl PartialEq<DrawParams> for DrawParams
impl PartialEq<DrawParams> for DrawParams
sourcefn eq(&self, other: &DrawParams) -> bool
fn eq(&self, other: &DrawParams) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &DrawParams) -> bool
fn ne(&self, other: &DrawParams) -> bool
This method tests for !=
.
impl StructuralPartialEq for DrawParams
Auto Trait Implementations
impl RefUnwindSafe for DrawParams
impl Send for DrawParams
impl Sync for DrawParams
impl Unpin for DrawParams
impl UnwindSafe for DrawParams
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T> Pointable for T
impl<T> Pointable for T
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more