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

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

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.

clip: Option<Rectangle>

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

Note that clipped texture regions may 'bleed' when drawing at non-integer co-ordinates. To avoid this, either add one pixel of padding around the images in the texture atlas (preferably matching the color of the actual border), or ensure your drawing is clamped to integer co-ordinates.

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 clip(self, clip: Rectangle) -> DrawParams[src]

Sets the region of the graphic to draw.

Trait Implementations

impl Clone for DrawParams[src]

impl Debug for DrawParams[src]

impl Default for DrawParams[src]

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

impl PartialEq<DrawParams> for DrawParams[src]

impl StructuralPartialEq for DrawParams[src]

Auto Trait Implementations

Blanket Implementations

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

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

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

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

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

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

type Owned = T

The resulting type after obtaining ownership.

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.

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.