pub trait Rect: Sized {
type Scalar: Float;
Show 26 methods
// Required methods
fn from_x_y_w_h(
_: Self::Scalar,
_: Self::Scalar,
_: Self::Scalar,
_: Self::Scalar,
) -> Self;
fn x(&self) -> Self::Scalar;
fn y(&self) -> Self::Scalar;
fn w(&self) -> Self::Scalar;
fn h(&self) -> Self::Scalar;
fn set_x(&mut self, val: Self::Scalar);
fn set_y(&mut self, val: Self::Scalar);
fn set_w(&mut self, val: Self::Scalar);
fn set_h(&mut self, val: Self::Scalar);
// Provided methods
fn from_u32(rect: [u32; 4]) -> Self { ... }
fn from_i32(rect: [i32; 4]) -> Self { ... }
fn xy(&self) -> (Self::Scalar, Self::Scalar) { ... }
fn wh(&self) -> (Self::Scalar, Self::Scalar) { ... }
fn xw(&self) -> (Self::Scalar, Self::Scalar) { ... }
fn yh(&self) -> (Self::Scalar, Self::Scalar) { ... }
fn x1x2(&self) -> (Self::Scalar, Self::Scalar) { ... }
fn y1y2(&self) -> (Self::Scalar, Self::Scalar) { ... }
fn p1p2(&self) -> ([Self::Scalar; 2], [Self::Scalar; 2]) { ... }
fn xywh(&self) -> (Self::Scalar, Self::Scalar, Self::Scalar, Self::Scalar) { ... }
fn center(&self) -> [Self::Scalar; 2] { ... }
fn is_empty(&self) -> bool { ... }
fn margin(&self, val: Self::Scalar) -> Self { ... }
fn split_left(
&self,
val: Self::Scalar,
factor: Self::Scalar,
) -> (Self, Self) { ... }
fn split_right(
&self,
val: Self::Scalar,
factor: Self::Scalar,
) -> (Self, Self) { ... }
fn split_top(&self, val: Self::Scalar, factor: Self::Scalar) -> (Self, Self) { ... }
fn split_bottom(
&self,
val: Self::Scalar,
factor: Self::Scalar,
) -> (Self, Self) { ... }
}Expand description
Helper methods for computing simple rectangle layout.
Required Associated Types§
Required Methods§
Provided Methods§
Sourcefn p1p2(&self) -> ([Self::Scalar; 2], [Self::Scalar; 2])
fn p1p2(&self) -> ([Self::Scalar; 2], [Self::Scalar; 2])
Returns upper left and lower right corner.
Sourcefn margin(&self, val: Self::Scalar) -> Self
fn margin(&self, val: Self::Scalar) -> Self
Computes a margin rectangle. If the margin is too large, an empty rectangle in the middle is returned.
Sourcefn split_left(&self, val: Self::Scalar, factor: Self::Scalar) -> (Self, Self)
fn split_left(&self, val: Self::Scalar, factor: Self::Scalar) -> (Self, Self)
Splits from the left side of rectangle up to a factor.
Sourcefn split_right(&self, val: Self::Scalar, factor: Self::Scalar) -> (Self, Self)
fn split_right(&self, val: Self::Scalar, factor: Self::Scalar) -> (Self, Self)
Splits from the right side of rectangle.
Sourcefn split_top(&self, val: Self::Scalar, factor: Self::Scalar) -> (Self, Self)
fn split_top(&self, val: Self::Scalar, factor: Self::Scalar) -> (Self, Self)
Splits from the top side of rectangle.
Sourcefn split_bottom(&self, val: Self::Scalar, factor: Self::Scalar) -> (Self, Self)
fn split_bottom(&self, val: Self::Scalar, factor: Self::Scalar) -> (Self, Self)
Splits from the bottom side of the rectangle.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".