Struct tetra::graphics::DrawParams

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

Struct representing the parameters that can be used when drawing.

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

The position that the graphic should be drawn at. Defaults to [0.0, 0.0].

§scale: Vec2

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

The origin of the graphic. Defaults to [0.0, 0.0] (the top left).

Positioning and scaling will be calculated relative to this point.

§rotation: f32

The rotation of the graphic, in radians. Defaults to 0.0.

§color: Color

A color to multiply the graphic by. Defaults to white.

§clip: Option<Rectangle>

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

This is useful if you’re using spritesheets (which you should be!).

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.

Sets the region of the graphic to draw.

Construct a transformation matrix using the position, scale, origin and rotation.

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
Converts to this type from the input type.
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

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

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The alignment of pointer.
The type for initializers.
Initializes a with the given initializer. Read more
Dereferences the given pointer. Read more
Mutably dereferences the given pointer. Read more
Drops the object pointed to by the given pointer. Read more
Should always be Self
Sets value as a parameter of self.
The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Checks if self is actually part of its subset T (and can be converted to it).
Use with care! Same as self.to_subset but without any property checks. Always succeeds.
The inclusion map: converts self to the equivalent element of its superset.
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
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.