[][src]Struct tetra::graphics::DrawParams

pub struct DrawParams {
    pub position: Vec2,
    pub scale: Vec2,
    pub origin: Vec2,
    pub rotation: f32,
    pub color: Color,
    pub clip: Option<Rectangle>,
}

Struct representing the parameters that can be used when drawing.

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

The position that the graphic should be drawn at. Defaults to [0.0, 0.0].

scale: Vec2

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

The origin of the graphic. Defaults to [0.0, 0.0] (the top left).

Positioning and scaling will be calculated relative to this point.

rotation: f32

The rotation of the graphic, in radians. Defaults to 0.0.

color: Color

A color to multiply the graphic by. Defaults to white.

clip: Option<Rectangle>

A sub-region of the graphic to draw. Defaults to None, which means the the full graphic will be drawn.

This is useful if you're using spritesheets (which you should be!).

Methods

impl DrawParams[src]

pub fn new() -> DrawParams[src]

Creates a new set of DrawParams.

pub fn position(self, position: Vec2) -> DrawParams[src]

Sets the position that the graphic should be drawn at.

pub fn scale(self, scale: Vec2) -> DrawParams[src]

Sets the scale that the graphic should be drawn at.

pub fn origin(self, origin: Vec2) -> DrawParams[src]

Sets the origin of the graphic.

pub fn rotation(self, rotation: f32) -> DrawParams[src]

Sets the rotation of the graphic, in radians.

pub fn color(self, color: Color) -> DrawParams[src]

Sets the color to multiply the graphic by.

pub fn clip(self, clip: Rectangle) -> DrawParams[src]

Sets the region of the graphic to draw.

Trait Implementations

impl Clone for DrawParams[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl PartialEq<DrawParams> for DrawParams[src]

impl Default for DrawParams[src]

impl From<Matrix<f32, U2, U1, <DefaultAllocator as Allocator<f32, U2, U1>>::Buffer>> for DrawParams[src]

impl Debug for DrawParams[src]

Auto Trait Implementations

impl Send for DrawParams

impl Sync for DrawParams

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

impl<T> From for T[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T> Same for T

type Output = T

Should always be Self

impl<SS, SP> SupersetOf for SP where
    SS: SubsetOf<SP>, 

impl<T> SetParameter for T

fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Result where
    T: Parameter<Self>, 

Sets value as a parameter of self.