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>

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.

Implementations

Creates a new set of DrawParams.

Sets the position that the graphic should be drawn at.

Sets the scale that the graphic should be drawn at.

Sets the origin of the graphic.

Sets the rotation of the graphic, in radians.

Sets the color to multiply the graphic by.

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

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

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

Performs the conversion.

Performs the conversion.

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

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

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

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

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.