pub struct Rect { /* private fields */ }
Expand description
The location and size of a rectangle region.
The width and height of a Rect
can be negative; for instance,
a Rect
with an origin of [ 0, 0 ] and a size of [ 10, 10 ] is
equivalent to a Rect
with an origin of [ 10, 10 ] and a size
of [ -10, -10 ].
Application code can normalize rectangles using normalize()
;
this function will ensure that the width and height of a rectangle are
positive values. All functions taking a Rect
as an argument
will internally operate on a normalized copy; all functions returning a
Rect
will always return a normalized rectangle.
GLib type: Inline allocated boxed type with stack copy semantics.
Implementations§
Source§impl Rect
impl Rect
pub fn as_ptr(&self) -> *mut graphene_rect_t
Sourcepub unsafe fn from_glib_ptr_borrow<'a>(ptr: *const graphene_rect_t) -> &'a Self
pub unsafe fn from_glib_ptr_borrow<'a>(ptr: *const graphene_rect_t) -> &'a Self
Borrows the underlying C value.
Sourcepub unsafe fn from_glib_ptr_borrow_mut<'a>(
ptr: *mut graphene_rect_t,
) -> &'a mut Self
pub unsafe fn from_glib_ptr_borrow_mut<'a>( ptr: *mut graphene_rect_t, ) -> &'a mut Self
Borrows the underlying C value mutably.
Source§impl Rect
impl Rect
Sourcepub fn contains_point(&self, p: &Point) -> bool
pub fn contains_point(&self, p: &Point) -> bool
Sourcepub fn contains_rect(&self, b: &Rect) -> bool
pub fn contains_rect(&self, b: &Rect) -> bool
Sourcepub fn bottom_left(&self) -> Point
pub fn bottom_left(&self) -> Point
Sourcepub fn bottom_right(&self) -> Point
pub fn bottom_right(&self) -> Point
Sourcepub fn height(&self) -> f32
pub fn height(&self) -> f32
Retrieves the normalized height of the given rectangle.
§Returns
the normalized height of the rectangle
Sourcepub fn width(&self) -> f32
pub fn width(&self) -> f32
Retrieves the normalized width of the given rectangle.
§Returns
the normalized width of the rectangle
Sourcepub fn x(&self) -> f32
pub fn x(&self) -> f32
Retrieves the normalized X coordinate of the origin of the given rectangle.
§Returns
the normalized X coordinate of the rectangle
Sourcepub fn y(&self) -> f32
pub fn y(&self) -> f32
Retrieves the normalized Y coordinate of the origin of the given rectangle.
§Returns
the normalized Y coordinate of the rectangle
Sourcepub fn inset(&mut self, d_x: f32, d_y: f32)
pub fn inset(&mut self, d_x: f32, d_y: f32)
Changes the given rectangle to be smaller, or larger depending on the given inset parameters.
To create an inset rectangle, use positive d_x
or d_y
values; to
create a larger, encompassing rectangle, use negative d_x
or d_y
values.
The origin of the rectangle is offset by d_x
and d_y
, while the size
is adjusted by (2 *
d_x, 2 *
d_y)
. If d_x
and d_y
are positive
values, the size of the rectangle is decreased; if d_x
and d_y
are
negative values, the size of the rectangle is increased.
If the size of the resulting inset rectangle has a negative width or height then the size will be set to zero.
§d_x
the horizontal inset
§d_y
the vertical inset
§Returns
the inset rectangle
Sourcepub fn inset_r(&self, d_x: f32, d_y: f32) -> Rect
pub fn inset_r(&self, d_x: f32, d_y: f32) -> Rect
Changes the given rectangle to be smaller, or larger depending on the given inset parameters.
To create an inset rectangle, use positive d_x
or d_y
values; to
create a larger, encompassing rectangle, use negative d_x
or d_y
values.
The origin of the rectangle is offset by d_x
and d_y
, while the size
is adjusted by (2 *
d_x, 2 *
d_y)
. If d_x
and d_y
are positive
values, the size of the rectangle is decreased; if d_x
and d_y
are
negative values, the size of the rectangle is increased.
If the size of the resulting inset rectangle has a negative width or height then the size will be set to zero.
§d_x
the horizontal inset
§d_y
the vertical inset
§Returns
§res
return location for the inset rectangle
Sourcepub fn interpolate(&self, b: &Rect, factor: f64) -> Rect
pub fn interpolate(&self, b: &Rect, factor: f64) -> Rect
Sourcepub fn intersection(&self, b: &Rect) -> Option<Rect>
pub fn intersection(&self, b: &Rect) -> Option<Rect>
Computes the intersection of the two given rectangles.
The intersection in the image above is the blue outline.
If the two rectangles do not intersect, res
will contain
a degenerate rectangle with origin in (0, 0) and a size of 0.
§b
a Rect
§Returns
true
if the two rectangles intersect
§res
return location for
a Rect
Sourcepub fn normalize(&mut self)
pub fn normalize(&mut self)
Normalizes the passed rectangle.
This function ensures that the size of the rectangle is made of positive values, and that the origin is the top-left corner of the rectangle.
§Returns
the normalized rectangle
Sourcepub fn normalize_r(&self) -> Rect
pub fn normalize_r(&self) -> Rect
Sourcepub fn round_extents(&self) -> Rect
pub fn round_extents(&self) -> Rect
Rounds the origin of the given rectangle to its nearest integer value and and recompute the size so that the rectangle is large enough to contain all the conrners of the original rectangle.
This function is the equivalent of calling floor
on
the coordinates of the origin, and recomputing the size
calling ceil
on the bottom-right coordinates.
If you want to be sure that the rounded rectangle completely covers the area that was covered by the original rectangle — i.e. you want to cover the area including all its corners — this function will make sure that the size is recomputed taking into account the ceiling of the coordinates of the bottom-right corner. If the difference between the original coordinates and the coordinates of the rounded rectangle is greater than the difference between the original size and and the rounded size, then the move of the origin would not be compensated by a move in the anti-origin, leaving the corners of the original rectangle outside the rounded one.
§Returns
§res
return location for the rectangle with rounded extents
Trait Implementations§
Source§impl HasParamSpec for Rect
impl HasParamSpec for Rect
Source§impl StaticType for Rect
impl StaticType for Rect
Source§fn static_type() -> Type
fn static_type() -> Type
Self
.impl Copy for Rect
impl Eq 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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)Source§impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
Source§impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GPtrArray> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GPtrArray> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
Source§impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GSList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GSList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
Source§impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
Source§impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GPtrArray> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GPtrArray> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
Source§impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GSList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GSList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
Source§impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
Source§impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GPtrArray> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GPtrArray> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
Source§impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GSList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GSList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
Source§impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
Source§impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GPtrArray> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GPtrArray> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
Source§impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GSList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GSList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
Source§impl<T> IntoClosureReturnValue for T
impl<T> IntoClosureReturnValue for T
fn into_closure_return_value(self) -> Option<Value>
Source§impl<T> PropertyGet for Twhere
T: HasParamSpec,
impl<T> PropertyGet for Twhere
T: HasParamSpec,
Source§impl<T> StaticTypeExt for Twhere
T: StaticType,
impl<T> StaticTypeExt for Twhere
T: StaticType,
Source§fn ensure_type()
fn ensure_type()
Source§impl<T> ToSendValue for T
impl<T> ToSendValue for T
Source§fn to_send_value(&self) -> SendValue
fn to_send_value(&self) -> SendValue
SendValue
clone of self
.