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]
- 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 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!).
Trait Implementations§
source§impl Default for DrawParams
impl Default for DrawParams
source§fn default() -> DrawParams
fn default() -> DrawParams
Returns the “default value” for a type. Read more
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>
The inverse inclusion map: attempts to construct
self
from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
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
Use with care! Same as
self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self
to the equivalent element of its superset.