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§
source§impl 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§
source§impl Clone for DrawParams
impl Clone for DrawParams
source§fn clone(&self) -> DrawParams
fn clone(&self) -> DrawParams
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for DrawParams
impl Debug for DrawParams
source§impl Default for DrawParams
impl Default for DrawParams
source§fn default() -> DrawParams
fn default() -> DrawParams
source§impl From<DrawParams> for Mat4<f32>
impl From<DrawParams> for Mat4<f32>
source§fn from(params: DrawParams) -> Self
fn from(params: DrawParams) -> Self
source§impl PartialEq<DrawParams> for DrawParams
impl PartialEq<DrawParams> for DrawParams
source§fn eq(&self, other: &DrawParams) -> bool
fn eq(&self, other: &DrawParams) -> bool
self
and other
values to be equal, and is used
by ==
.