pub struct Rect(/* private fields */);
Implementations§
Source§impl Rect
impl Rect
Sourcepub fn alloc() -> Rect
pub fn alloc() -> Rect
Creates a new, empty Rect
.
You can use Rect::init
to initialize the returned rectangle,
for instance:
rect = clutter_rect_init (clutter_rect_alloc (), x, y, width, height);
§Returns
the newly allocated Rect
.
Use Rect::free
to free its resources
Sourcepub fn clamp_to_pixel(&mut self)
pub fn clamp_to_pixel(&mut self)
Rounds the origin of self
downwards to the nearest integer, and rounds
the size of self
upwards to the nearest integer, so that self
is
updated to the smallest rectangle capable of fully containing the
original, fractional rectangle.
Sourcepub fn contains_point(&mut self, point: &mut Point) -> bool
pub fn contains_point(&mut self, point: &mut Point) -> bool
Sourcepub fn contains_rect(&mut self, b: &mut Rect) -> bool
pub fn contains_rect(&mut self, b: &mut Rect) -> bool
Sourcepub fn get_center(&mut self) -> Point
pub fn get_center(&mut self) -> Point
Retrieves the center of self
, after normalizing the rectangle,
and updates center
with the correct coordinates.
§center
a Point
Sourcepub fn get_height(&mut self) -> f32
pub fn get_height(&mut self) -> f32
Sourcepub fn get_x(&mut self) -> f32
pub fn get_x(&mut self) -> f32
Retrieves the X coordinate of the origin of self
.
§Returns
the X coordinate of the origin of the rectangle
Sourcepub fn get_y(&mut self) -> f32
pub fn get_y(&mut self) -> f32
Retrieves the Y coordinate of the origin of self
.
§Returns
the Y coordinate of the origin 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)
Normalizes the self
and offsets its origin by the d_x
and d_y
values;
the size is adjusted by (2 * d_x
, 2 * d_y
).
If d_x
and d_y
are positive the size of the rectangle is decreased; if
the values are negative, the size of the rectangle is increased.
If the resulting rectangle has a negative width or height, the size is set to 0.
§d_x
an horizontal value; a positive d_x
will create an inset rectangle,
and a negative value will create a larger rectangle
§d_y
a vertical value; a positive d_x
will create an inset rectangle,
and a negative value will create a larger rectangle
Sourcepub fn intersection(&mut self, b: &mut Rect) -> Option<Rect>
pub fn intersection(&mut self, b: &mut Rect) -> Option<Rect>
Computes the intersection of self
and b
, and places it in res
, if res
is not None
.
This function will normalize both self
and b
prior to computing their
intersection.
This function can be used to simply check if the intersection of self
and b
is not empty, by using None
for res
.
§b
a Rect
§res
a Rect
, or None
§Returns
true
if the intersection of self
and b
is not empty
Sourcepub fn normalize(&mut self) -> Option<Rect>
pub fn normalize(&mut self) -> Option<Rect>
Normalizes a Rect
.
A Rect
is defined by the area covered by its size; this means
that a Rect
with Rect.origin
in [ 0, 0 ] and a
Rect.size
of [ 10, 10 ] is equivalent to a Rect
with
Rect.origin
in [ 10, 10 ] and a Rect.size
of [ -10, -10 ].
This function is useful to ensure that a rectangle has positive width
and height; it will modify the passed self
and normalize its size.
Trait Implementations§
Source§impl Ord for Rect
impl Ord for Rect
Source§impl PartialOrd for Rect
impl PartialOrd for Rect
Source§impl StaticType for Rect
impl StaticType for Rect
Source§fn static_type() -> Type
fn static_type() -> Type
Self
.