Struct tetra::graphics::DrawParams
source · pub struct DrawParams { /* private fields */ }
Expand description
Struct representing the parameters that can be used when drawing.
A default instance of DrawParams will draw the associated graphic with the following settings:
- Position: [0.0, 0.0]
- Scale: [1.0, 1.0]
- Origin: [0.0, 0.0]
- Rotation: 0.0
- Color: White
- Clip: Full image
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) -> DrawParams
pub fn position(self, position: Vec2) -> DrawParams
Sets the position that the graphic should be drawn at.
sourcepub fn scale(self, scale: Vec2) -> DrawParams
pub fn scale(self, scale: Vec2) -> DrawParams
Sets the scale that the graphic should be drawn at.
This can be set to a negative value to flip the graphic around the origin.
sourcepub fn origin(self, origin: Vec2) -> DrawParams
pub fn origin(self, origin: Vec2) -> DrawParams
Sets the origin of the graphic.
Positioning and scaling will be calculated relative to this point.
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.
Setting this to white will draw the graphic in its original color.
sourcepub fn clip(self, clip: Rectangle) -> DrawParams
pub fn clip(self, clip: Rectangle) -> DrawParams
Sets the region of the graphic to draw.
This is useful if you’re using spritesheets (which you should be!).
sourcepub fn build_matrix(&self) -> Mat3
pub fn build_matrix(&self) -> Mat3
Construct a transformation matrix using the position, scale, origin and rotation.
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 Default for DrawParams
impl Default for DrawParams
source§fn default() -> DrawParams
fn default() -> 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§
§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> SetParameter for T
impl<T> SetParameter for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).§unsafe fn to_subset_unchecked(&self) -> SS
unsafe fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.