Struct kurbo::Rect

source ·
pub struct Rect {
    pub x0: f64,
    pub y0: f64,
    pub x1: f64,
    pub y1: f64,
}
Expand description

A rectangle.

Fields§

§x0: f64

The minimum x coordinate (left edge).

§y0: f64

The minimum y coordinate (top edge in y-down spaces).

§x1: f64

The maximum x coordinate (right edge).

§y1: f64

The maximum y coordinate (bottom edge in y-down spaces).

Implementations§

A new rectangle from minimum and maximum coordinates.

A new rectangle from two points.

The result will have non-negative width and height.

A new rectangle from origin and size.

The result will have non-negative width and height.

The width of the rectangle.

Note: nothing forbids negative width.

The height of the rectangle.

Note: nothing forbids negative height.

The origin of the vector.

This is the top left corner in a y-down space and with non-negative width and height.

The size of the rectangle, as a vector.

The area of the rectangle.

The center point of the rectangle.

Take absolute value of width and height.

The resulting rect has the same extents as the original, but is guaranteed to have non-negative width and height.

The smallest rectangle enclosing two rectangles.

Results are valid only if width and height are non-negative.

Compute the union with one point.

This method includes the perimeter of zero-area rectangles. Thus, a succession of union_pt operations on a series of points yields their enclosing rectangle.

Results are valid only if width and height are non-negative.

The intersection of two rectangles.

The result is zero-area if either input has negative width or height. The result always has non-negative width and height.

Trait Implementations§

The resulting type after applying the + operator.
Performs the + operation. Read more
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.
Converts to this type from the input type.

Note: this function is carefully designed so that if the plane is tiled with rectangles, the winding number will be nonzero for exactly one of them.

The iterator resulting from to_bez_path.
Convert to a Bézier path, as an iterator over path elements. Read more
Signed area. Read more
Total length of perimeter.
The smallest rectangle that encloses the shape.
If the shape is a rectangle, make it available.
If the shape is a line, make it available.
If the shape is stored as a slice of path elements, make that available. Read more
The resulting type after applying the - operator.
Performs the - operation. 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 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.