Struct Rect

Source
pub struct Rect(/* private fields */);

Implementations§

Source§

impl Rect

Source

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

Source

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.

Source

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

Checks whether point is contained by self, after normalizing the rectangle.

§point

the point to check

§Returns

true if the point is contained by self.

Source

pub fn contains_rect(&mut self, b: &mut Rect) -> bool

Checks whether self contains b.

The first rectangle contains the second if the union of the two Rect is equal to the first rectangle.

§b

a Rect

§Returns

true if the first rectangle contains the second.

Source

pub fn equals(&mut self, b: &mut Rect) -> bool

Checks whether self and b are equals.

This function will normalize both self and b before comparing their origin and size.

§b

a Rect

§Returns

true if the rectangles match in origin and size.

Source

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

Source

pub fn get_height(&mut self) -> f32

Retrieves the height of self.

§Returns

the height of the rectangle

Source

pub fn get_width(&mut self) -> f32

Retrieves the width of self.

§Returns

the width of the rectangle

Source

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

Source

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

Source

pub fn init(&mut self, x: f32, y: f32, width: f32, height: f32) -> Option<Rect>

Initializes a Rect with the given origin and size.

§x

X coordinate of the origin

§y

Y coordinate of the origin

§width

width of the rectangle

§height

height of the rectangle

§Returns

the updated rectangle

Source

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

Source

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

Source

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.

Source

pub fn offset(&mut self, d_x: f32, d_y: f32)

Offsets the origin of self by the given values, after normalizing the rectangle.

§d_x

the horizontal offset value

§d_y

the vertical offset value

Source

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

Computes the smallest possible rectangle capable of fully containing both self and b, and places it into res.

This function will normalize both self and b prior to computing their union.

§b

a Rect

§res

a Rect

Source

pub fn zero() -> Option<Rect>

A Rect with Rect.origin set at (0, 0) and a size of 0.

The returned value can be used as a guard.

§Returns

a rectangle with origin in (0, 0) and a size of 0. The returned Rect is owned by Clutter and it should not be modified or freed.

Trait Implementations§

Source§

impl Clone for Rect

Source§

fn clone(&self) -> Rect

Returns a duplicate 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 Hash for Rect

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for Rect

Source§

fn cmp(&self, other: &Rect) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for Rect

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for Rect

Source§

fn partial_cmp(&self, other: &Rect) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl StaticType for Rect

Source§

fn static_type() -> Type

Returns the type identifier of Self.
Source§

impl Eq 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GList> for T

Source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GPtrArray> for T

Source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GSList> for T

Source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GList> for T

Source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GPtrArray> for T

Source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GSList> for T

Source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GList> for T

Source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GPtrArray> for T

Source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GSList> for T

Source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GList> for T

Source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GPtrArray> for T

Source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GSList> for T

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,

Source§

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> ToValue for T
where T: SetValue + ?Sized,

Source§

fn to_value(&self) -> Value

Returns a Value clone of self.
Source§

fn to_value_type(&self) -> Type

Returns the type identifer of self. Read more
Source§

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

Source§

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>,

Source§

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.