#[repr(transparent)]pub struct Rectangle { /* private fields */ }
Expand description
A Rectangle
data type for representing rectangles.
Rectangle
is identical to cairo_rectangle_t
. Together with Cairo’s
cairo::Region
data type, these are the central types for representing
sets of pixels.
The intersection of two rectangles can be computed with
intersect()
; to find the union of two rectangles use
union()
.
The cairo::Region
type provided by Cairo is usually used for managing
non-rectangular clipping of graphical operations.
The Graphene library has a number of other data types for regions and volumes in 2D and 3D.
Implementations
sourceimpl Rectangle
impl Rectangle
sourcepub fn contains_point(&self, x: i32, y: i32) -> bool
pub fn contains_point(&self, x: i32, y: i32) -> bool
sourcepub fn intersect(&self, src2: &Rectangle) -> Option<Rectangle>
pub fn intersect(&self, src2: &Rectangle) -> Option<Rectangle>
Calculates the intersection of two rectangles.
It is allowed for @dest to be the same as either @self or @src2.
If the rectangles do not intersect, @dest’s width and height is set
to 0 and its x and y values are undefined. If you are only interested
in whether the rectangles intersect, but not in the intersecting area
itself, pass None
for @dest.
src2
Returns
true
if the rectangles intersect.
dest
return location for the intersection of @self and @src2
sourcepub fn union(&self, src2: &Rectangle) -> Rectangle
pub fn union(&self, src2: &Rectangle) -> Rectangle
Calculates the union of two rectangles.
The union of rectangles @self and @src2 is the smallest rectangle which includes both @self and @src2 within it. It is allowed for @dest to be the same as either @self or @src2.
Note that this function does not ignore ‘empty’ rectangles (ie. with zero width or height).
src2
Returns
dest
return location for the union of @self and @src2
sourceimpl Rectangle
impl Rectangle
pub fn new(x: i32, y: i32, width: i32, height: i32) -> Self
pub fn x(&self) -> i32
pub fn set_x(&mut self, x: i32)
pub fn y(&self) -> i32
pub fn set_y(&mut self, y: i32)
pub fn width(&self) -> i32
pub fn set_width(&mut self, width: i32)
pub fn height(&self) -> i32
pub fn set_height(&mut self, height: i32)
Trait Implementations
sourceimpl AsRef<RectangleInt> for Rectangle
impl AsRef<RectangleInt> for Rectangle
sourcefn as_ref(&self) -> &RectangleInt
fn as_ref(&self) -> &RectangleInt
Converts this type into a shared reference of the (usually inferred) input type.
sourceimpl From<Rectangle> for RectangleInt
impl From<Rectangle> for RectangleInt
sourceimpl From<Rectangle> for Rectangle
impl From<Rectangle> for Rectangle
sourcefn from(r: Rectangle) -> Self
fn from(r: Rectangle) -> Self
Note that converting between a cairo::Rectangle
and Rectangle
will probably lead to precisison errors. Use cautiously.
sourceimpl From<RectangleInt> for Rectangle
impl From<RectangleInt> for Rectangle
sourcefn from(r: RectangleInt) -> Self
fn from(r: RectangleInt) -> Self
Converts to this type from the input type.
sourceimpl StaticType for Rectangle
impl StaticType for Rectangle
sourcefn static_type() -> Type
fn static_type() -> Type
Returns the type identifier of Self
.
impl Copy for Rectangle
impl Eq for Rectangle
Auto Trait Implementations
impl RefUnwindSafe for Rectangle
impl Send for Rectangle
impl Sync for Rectangle
impl Unpin for Rectangle
impl UnwindSafe for Rectangle
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> StaticTypeExt for T where
T: StaticType,
impl<T> StaticTypeExt for T where
T: StaticType,
sourcefn ensure_type()
fn ensure_type()
Ensures that the type has been registered with the type system.
sourceimpl<T> ToClosureReturnValue for T where
T: ToValue,
impl<T> ToClosureReturnValue for T where
T: ToValue,
fn to_closure_return_value(&self) -> Option<Value>
sourceimpl<T> ToSendValue for T where
T: Send + ToValue + ?Sized,
impl<T> ToSendValue for T where
T: Send + ToValue + ?Sized,
sourcefn to_send_value(&self) -> SendValue
fn to_send_value(&self) -> SendValue
Returns a SendValue
clone of self
.