pub struct DrawParam {
pub src: Rect,
pub color: Color,
pub transform: Transform,
pub image_scale: bool,
pub z: ZIndex,
}
Expand description
A struct containing all the necessary info for drawing with parameters.
This struct implements the Default
trait, so to set only some parameter
you can just do:
let my_dest = glam::vec2(13.0, 37.0);
canvas.draw(&image, DrawParam::default().dest(my_dest));
As a shortcut, it also implements From
for Into<Point2<f32>>
.
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.
color: Color
Default: white.
transform: Transform
Where to put the object.
image_scale: bool
Whether the scale should be relative to image size.
z: ZIndex
The Z coordinate of the draw.
Implementations
sourceimpl DrawParam
impl DrawParam
sourcepub fn color(self, color: impl Into<Color>) -> Self
pub fn color(self, color: impl Into<Color>) -> Self
Set the color. This will be blended with whatever color the drawn object already is.
sourcepub fn scale<V>(self, scale_: V) -> Self where
V: Into<Vector2<f32>>,
pub fn scale<V>(self, scale_: V) -> Self where
V: Into<Vector2<f32>>,
Set the scaling factors.
sourcepub fn offset<P>(self, offset_: P) -> Self where
P: Into<Point2<f32>>,
pub fn offset<P>(self, offset_: P) -> Self where
P: Into<Point2<f32>>,
Set the transformation offset.
sourcepub fn transform<M>(self, transform: M) -> Self where
M: Into<ColumnMatrix4<f32>>,
pub fn transform<M>(self, transform: M) -> Self where
M: Into<ColumnMatrix4<f32>>,
Set the transformation matrix.
sourcepub fn image_scale(self, image_scale: bool) -> Self
pub fn image_scale(self, image_scale: bool) -> Self
Set the image scale option.
Trait Implementations
sourceimpl<P> From<P> for DrawParam where
P: Into<Point2<f32>>,
impl<P> From<P> for DrawParam where
P: Into<Point2<f32>>,
Create a DrawParam
from a location, like this:
let my_dest = glam::vec2(13.0, 37.0);
canvas.draw(&image, my_dest);
impl Copy for DrawParam
impl StructuralPartialEq for DrawParam
Auto Trait Implementations
impl RefUnwindSafe for DrawParam
impl Send for DrawParam
impl Sync for DrawParam
impl Unpin for DrawParam
impl UnwindSafe for DrawParam
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> HasMut<T> for T
impl<T> HasMut<T> for T
sourcefn retrieve_mut(&mut self) -> &mut T
fn retrieve_mut(&mut self) -> &mut T
Method to retrieve the context type as mutable.