Struct ggez::graphics::Rect[][src]

pub struct Rect {
    pub x: f32,
    pub y: f32,
    pub w: f32,
    pub h: f32,
}
Expand description

A simple 2D rectangle.

The origin of the rectangle is at the top-left, with x increasing to the right and y increasing down.

Fields

x: f32

X coordinate of the left edge of the rect.

y: f32

Y coordinate of the top edge of the rect.

w: f32

Total width of the rect

h: f32

Total height of the rect.

Implementations

Create a new Rect.

Creates a new Rect a la Love2D’s love.graphics.newQuad, as a fraction of the reference rect’s size.

Create a new rect from i32 coordinates. Loses precision if the integers are too big to fit in f32’s.

Create a new Rect with all values zero.

Creates a new Rect at 0,0 with width and height 1.

Gets the Rect’s x and y coordinates as a Point2.

Gets the Rect’s center x and y coordinates as a Point2.

Returns the left edge of the Rect

Returns the right edge of the Rect

Returns the top edge of the Rect

Returns the bottom edge of the Rect

Checks whether the Rect contains a Point

Checks whether the Rect overlaps another Rect

Translates the Rect by an offset of (x, y)

Moves the Rect’s origin to (x, y)

Scales the Rect by a factor of (sx, sy), growing towards the bottom-left

Calculated the new Rect around the rotated one.

Returns a new Rect that includes all points of these two Rects.

Trait Implementations

Used for specifying relative comparisons.

The default tolerance to use when testing values that are close together. Read more

A test for equality that uses the absolute difference to compute the approximate equality of two numbers. Read more

The inverse of AbsDiffEq::abs_diff_eq.

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

Deserialize this value from the given Serde deserializer. 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 !=.

The default relative tolerance for testing values that are far-apart. Read more

A test for equality that uses a relative comparison if the values are far apart.

The inverse of RelativeEq::relative_eq.

Serialize this value into the given Serde serializer. 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

Performs the conversion.

Performs the conversion.

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

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)

recently added

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.