Struct accesskit::Rect

source ·
#[repr(C)]
pub struct Rect { pub x0: f64, pub y0: f64, pub x1: f64, pub y1: f64, }
Expand description

A rectangle. Derived from kurbo.

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§

source§

impl Rect

source

pub const ZERO: Rect = _

The empty rectangle at the origin.

source

pub const fn new(x0: f64, y0: f64, x1: f64, y1: f64) -> Rect

A new rectangle from minimum and maximum coordinates.

source

pub fn from_points(p0: impl Into<Point>, p1: impl Into<Point>) -> Rect

A new rectangle from two points.

The result will have non-negative width and height.

source

pub fn from_origin_size(origin: impl Into<Point>, size: impl Into<Size>) -> Rect

A new rectangle from origin and size.

The result will have non-negative width and height.

source

pub fn with_origin(self, origin: impl Into<Point>) -> Rect

Create a new Rect with the same size as self and a new origin.

source

pub fn with_size(self, size: impl Into<Size>) -> Rect

Create a new Rect with the same origin as self and a new size.

source

pub fn width(&self) -> f64

The width of the rectangle.

Note: nothing forbids negative width.

source

pub fn height(&self) -> f64

The height of the rectangle.

Note: nothing forbids negative height.

source

pub fn min_x(&self) -> f64

Returns the minimum value for the x-coordinate of the rectangle.

source

pub fn max_x(&self) -> f64

Returns the maximum value for the x-coordinate of the rectangle.

source

pub fn min_y(&self) -> f64

Returns the minimum value for the y-coordinate of the rectangle.

source

pub fn max_y(&self) -> f64

Returns the maximum value for the y-coordinate of the rectangle.

source

pub fn origin(&self) -> Point

The origin of the rectangle.

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

source

pub fn size(&self) -> Size

The size of the rectangle.

source

pub fn abs(&self) -> Rect

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.

source

pub fn area(&self) -> f64

The area of the rectangle.

source

pub fn is_empty(&self) -> bool

Whether this rectangle has zero area.

Note: a rectangle with negative area is not considered empty.

source

pub fn contains(&self, point: Point) -> bool

Returns true if point lies within self.

source

pub fn union(&self, other: Rect) -> Rect

The smallest rectangle enclosing two rectangles.

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

source

pub fn union_pt(&self, pt: Point) -> Rect

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.

source

pub fn intersect(&self, other: Rect) -> Rect

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§

source§

impl Add<Vec2> for Rect

§

type Output = Rect

The resulting type after applying the + operator.
source§

fn add(self, v: Vec2) -> Rect

Performs the + operation. Read more
source§

impl Clone for Rect

source§

fn clone(&self) -> Rect

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Rect

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Rect

source§

fn default() -> Rect

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

impl<'de> Deserialize<'de> for Rect

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl From<(Point, Point)> for Rect

source§

fn from(points: (Point, Point)) -> Rect

Converts to this type from the input type.
source§

impl From<(Point, Size)> for Rect

source§

fn from(params: (Point, Size)) -> Rect

Converts to this type from the input type.
source§

impl JsonSchema for Rect

source§

fn schema_name() -> String

The name of the generated JSON Schema. Read more
source§

fn schema_id() -> Cow<'static, str>

Returns a string that uniquely identifies the schema produced by this type. Read more
source§

fn json_schema(gen: &mut SchemaGenerator) -> Schema

Generates a JSON Schema for this type. Read more
source§

fn is_referenceable() -> bool

Whether JSON Schemas generated for this type should be re-used where possible using the $ref keyword. Read more
source§

impl PartialEq for Rect

source§

fn eq(&self, other: &Rect) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for Rect

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl Sub<Vec2> for Rect

§

type Output = Rect

The resulting type after applying the - operator.
source§

fn sub(self, v: Vec2) -> Rect

Performs the - operation. Read more
source§

impl Copy for Rect

source§

impl StructuralPartialEq for Rect

Auto Trait Implementations§

§

impl Freeze for Rect

§

impl RefUnwindSafe for Rect

§

impl Send for Rect

§

impl Sync for Rect

§

impl Unpin for Rect

§

impl UnwindSafe for Rect

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> DynClone for T
where T: Clone,

source§

fn __clone_box(&self, _: Private) -> *mut ()

source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,