# RelativeRect

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-base/struct-relativerect/

**struct** · [`ferroui-base`](/docs/0.5.0/api/ferroui-base/) · v0.5.0

```rust
struct RelativeRect
```

Defines a rectangle that may be defined relative to a containing element.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/relative_rect.rs#L11)

## Members

- [`unit`](#struct_field-unit)
- [`rect`](#struct_field-rect)
- [`FILL`](#assoc_const-fill)
- [`new`](#function-new)
- [`from_rect`](#function-from_rect)
- [`from_size`](#function-from_size)
- [`from_position_size`](#function-from_position_size)
- [`from_points`](#function-from_points)
- [`equals`](#function-equals)
- [`to_pixels`](#function-to_pixels)
- [`to_pixels_rect`](#function-to_pixels_rect)
- [`parse`](#function-parse)

<a id="struct_field-unit"></a>

### unit

```rust
unit: crate::RelativeUnit
```

The unit of the rectangle.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/relative_rect.rs#L13)

<a id="struct_field-rect"></a>

### rect

```rust
rect: crate::Rect
```

The rectangle.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/relative_rect.rs#L15)

<a id="assoc_const-fill"></a>

### FILL

```rust
const FILL: RelativeRect
```

A rectangle that represents 100% of an area.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/relative_rect.rs#L20)

<a id="function-new"></a>

### new

```rust
const fn new(x: f64, y: f64, width: f64, height: f64, unit: RelativeUnit) -> Self
```

Initializes a new instance of the `RelativeRect` structure.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/relative_rect.rs#L24)

<a id="function-from_rect"></a>

### from_rect

```rust
const fn from_rect(rect: Rect, unit: RelativeUnit) -> Self
```

Initializes a `RelativeRect` from a `Rect`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/relative_rect.rs#L33)

<a id="function-from_size"></a>

### from_size

```rust
const fn from_size(size: Size, unit: RelativeUnit) -> Self
```

Initializes a `RelativeRect` at the origin with the given size.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/relative_rect.rs#L39)

<a id="function-from_position_size"></a>

### from_position_size

```rust
const fn from_position_size(position: Point, size: Size, unit: RelativeUnit) -> Self
```

Initializes a `RelativeRect` from its position and size.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/relative_rect.rs#L45)

<a id="function-from_points"></a>

### from_points

```rust
fn from_points(top_left: Point, bottom_right: Point, unit: RelativeUnit) -> Self
```

Initializes a `RelativeRect` from its top left and bottom right corners.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/relative_rect.rs#L51)

<a id="function-equals"></a>

### equals

```rust
fn equals(self: &Self, p: RelativeRect) -> bool
```

Checks if the `RelativeRect` equals another rectangle.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/relative_rect.rs#L57)

<a id="function-to_pixels"></a>

### to_pixels

```rust
fn to_pixels(self: &Self, size: Size) -> Rect
```

Converts a `RelativeRect` into pixels, using `size` as the size of the
visual the rectangle is relative to.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/relative_rect.rs#L64)

<a id="function-to_pixels_rect"></a>

### to_pixels_rect

```rust
fn to_pixels_rect(self: &Self, bounding_box: Rect) -> Rect
```

Converts a `RelativeRect` into pixels, using `bounding_box` as the box the
rectangle is relative to.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/relative_rect.rs#L80)

<a id="function-parse"></a>

### parse

```rust
fn parse(s: &str) -> Result<Self, FormatError>
```

Parses a `RelativeRect` string: four numbers (absolute) or four
percentages (relative).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/relative_rect.rs#L95)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- [`PropertyValue`](/docs/0.5.0/api/ferroui-base/trait-propertyvalue/)
- [`AnyValue`](/docs/0.5.0/api/ferroui-base/trait-anyvalue/)
- [`ClassDefaults`](/docs/0.5.0/api/ferroui-base/trait-classdefaults/)
- `Borrow<T>`
- `BorrowMut<T>`
- `CloneToUninit`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- `Any`
- `ToOwned`
- `ErasedDestructor`
- `IntoEither`
- `ServerPropertyValue`
- `BatchValue`
- [`MarkupTyped`](/docs/0.5.0/api/ferroui-base/metadata/trait-markuptyped/)
- [`ValueTypeRegistration`](/docs/0.5.0/api/ferroui-base/data/core/trait-valuetyperegistration/)
- `Clone`
- `Copy`
- `Debug`
- `StructuralPartialEq`
- `PartialEq`
- `Default`
- `FromStr`

## Availability

Extracted for `aarch64-apple-darwin`. Cargo features are listed in the [crate index](/docs/0.5.0/api/).
