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

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>
Expand description

The position that the graphic should be drawn at. Defaults to (0.0, 0.0).

scale: Vec2<f32>
Expand description

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>
Expand description

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
Expand description

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

color: Color
Expand description

A color to multiply the graphic by. Defaults to Color::WHITE.

Implementations

impl DrawParams[src]

pub fn new() -> DrawParams[src]

Creates a new set of DrawParams.

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

Sets the position that the graphic should be drawn at.

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

Sets the scale that the graphic should be drawn at.

pub fn origin(self, origin: Vec2<f32>) -> 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 to_matrix(&self) -> Mat4<f32>[src]

Creates a new transformation matrix equivalent to this set of params.

This method does not take into account color, as it cannot be represented via a matrix.

Trait Implementations

impl Clone for DrawParams[src]

fn clone(&self) -> DrawParams[src]

Returns a copy of the value. Read more

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

Performs copy-assignment from source. Read more

impl Debug for DrawParams[src]

fn fmt(&self, f: &mut Formatter<'_>) -> Result[src]

Formats the value using the given formatter. Read more

impl Default for DrawParams[src]

fn default() -> DrawParams[src]

Returns the “default value” for a type. Read more

impl From<Vec2<f32>> for DrawParams[src]

fn from(position: Vec2<f32>) -> DrawParams[src]

Performs the conversion.

impl PartialEq<DrawParams> for DrawParams[src]

fn eq(&self, other: &DrawParams) -> bool[src]

This method tests for self and other values to be equal, and is used by ==. Read more

fn ne(&self, other: &DrawParams) -> bool[src]

This method tests for !=.

impl StructuralPartialEq for DrawParams[src]

Auto Trait Implementations

Blanket Implementations

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

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

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

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

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

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

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

pub fn into(self) -> U[src]

Performs the conversion.

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

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

Creates owned data from borrowed data, usually by cloning. Read more

pub fn clone_into(&self, target: &mut T)[src]

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

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

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

type Error = Infallible

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

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

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

The type returned in the event of a conversion error.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.