[][src]Struct ggez::graphics::DrawParam

pub struct DrawParam {
    pub src: Rect,
    pub dest: Point2<f32>,
    pub rotation: f32,
    pub scale: Vector2<f32>,
    pub offset: Point2<f32>,
    pub color: Color,
}

A struct containing all the necessary info for drawing a Drawable.

This struct implements the Default trait, so to set only some parameter you can just do:

let my_dest = nalgebra::Point2::new(13.0, 37.0);
graphics::draw(ctx, drawable, DrawParam::default().dest(my_dest) );

As a shortcut, it also implements From for a variety of tuple types.

Fields

src: Rect

A portion of the drawable to clip, as a fraction of the whole image. Defaults to the whole image (0,0 to 1,1) if omitted.

dest: Point2<f32>

The position to draw the graphic expressed as a Point2.

rotation: f32

The orientation of the graphic in radians.

scale: Vector2<f32>

The x/y scale factors expressed as a Vector2.

offset: Point2<f32>

An offset from the center for transform operations like scale/rotation, with 0,0 meaning the origin and 1,1 meaning the opposite corner from the origin. By default these operations are done from the top-left corner, so to rotate something from the center specify Point2::new(0.5, 0.5) here.

color: Color

A color to draw the target with. Default: white.

Methods

impl DrawParam[src]

pub fn new() -> Self[src]

Create a new DrawParam with default values.

pub fn src(self, src: Rect) -> Self[src]

Set the source rect

pub fn dest<P>(self, dest: P) -> Self where
    P: Into<Point2<f32>>, 
[src]

Set the dest point

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

Set the drawable color. This will be blended with whatever color the drawn object already is.

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

Set the rotation of the drawable.

pub fn scale<V>(self, scale: V) -> Self where
    V: Into<Vector2<f32>>, 
[src]

Set the scaling factors of the drawable.

pub fn offset<P>(self, offset: P) -> Self where
    P: Into<Point2<f32>>, 
[src]

Set the transformation offset of the drawable.

pub fn to_matrix(&self) -> ColumnMatrix4<f32>[src]

A DrawParam that has been crunched down to a single matrix. Because of this it only contains the transform part (rotation/scale/etc), with no src/dest/color info.

Trait Implementations

impl<P> From<(P,)> for DrawParam where
    P: Into<Point2<f32>>, 
[src]

Create a DrawParam from a location. Note that this takes a single-element tuple. It's a little weird but keeps the trait implementations from clashing.

impl<P> From<(P, Color)> for DrawParam where
    P: Into<Point2<f32>>, 
[src]

Create a DrawParam from a location and color

impl<P> From<(P, f32, Color)> for DrawParam where
    P: Into<Point2<f32>>, 
[src]

Create a DrawParam from a location, rotation and color

impl<P> From<(P, f32, P, Color)> for DrawParam where
    P: Into<Point2<f32>>, 
[src]

Create a DrawParam from a location, rotation, offset and color

impl<P, V> From<(P, f32, P, V, Color)> for DrawParam where
    P: Into<Point2<f32>>,
    V: Into<Vector2<f32>>, 
[src]

Create a DrawParam from a location, rotation, offset, scale and color

impl PartialEq<DrawParam> for DrawParam[src]

impl Clone for DrawParam[src]

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

Performs copy-assignment from source. Read more

impl Default for DrawParam[src]

impl Copy for DrawParam[src]

impl Debug for DrawParam[src]

Auto Trait Implementations

Blanket Implementations

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

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

type Owned = T

The resulting type after obtaining ownership.

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

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.

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

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

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

impl<T> Scalar for T where
    T: Copy + PartialEq<T> + Any + Debug
[src]

fn is<T>() -> bool where
    T: Scalar
[src]

Tests if Self the same as the type T Read more

impl<T> Same<T> for T

type Output = T

Should always be Self

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

impl<T> Erased for T

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.