[−][src]Struct ggez::graphics::DrawParam
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]
P: Into<Point2<f32>>,
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]
V: Into<Vector2<f32>>,
Set the scaling factors of the drawable.
pub fn offset<P>(self, offset: P) -> Self where
P: Into<Point2<f32>>,
[src]
P: Into<Point2<f32>>,
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]
P: Into<Point2<f32>>,
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]
P: Into<Point2<f32>>,
Create a DrawParam
from a location and color
impl<P> From<(P, f32, Color)> for DrawParam where
P: Into<Point2<f32>>,
[src]
P: Into<Point2<f32>>,
Create a DrawParam
from a location, rotation and color
impl<P> From<(P, f32, P, Color)> for DrawParam where
P: Into<Point2<f32>>,
[src]
P: Into<Point2<f32>>,
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]
P: Into<Point2<f32>>,
V: Into<Vector2<f32>>,
Create a DrawParam
from a location, rotation, offset, scale and color
impl PartialEq<DrawParam> for DrawParam
[src]
impl Clone for DrawParam
[src]
fn clone(&self) -> 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
impl Unpin for DrawParam
impl Sync for DrawParam
impl Send for DrawParam
impl RefUnwindSafe for DrawParam
impl UnwindSafe for DrawParam
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Scalar for T where
T: Copy + PartialEq<T> + Any + Debug,
[src]
T: Copy + PartialEq<T> + Any + Debug,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
SS: SubsetOf<SP>,
fn to_subset(&self) -> Option<SS>
fn is_in_subset(&self) -> bool
unsafe fn to_subset_unchecked(&self) -> SS
fn from_subset(element: &SS) -> 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>,
T: Parameter<Self>,
Sets value
as a parameter of self
.