# MediaExtensions

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

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

```rust
struct MediaExtensions
```

Provides extension methods for media types.

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

## Members

- [`calculate_scaling`](#function-calculate_scaling)
- [`calculate_size`](#function-calculate_size)

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

### calculate_scaling

```rust
fn calculate_scaling(stretch: Stretch, destination_size: Size, source_size: Size, stretch_direction: StretchDirection) -> Vector
```

Calculates scaling based on a `Stretch` value.

* `stretch` - The stretch mode.
* `destination_size` - The size of the destination viewport.
* `source_size` - The size of the source.
* `stretch_direction` - The stretch direction (upstream default:
  `StretchDirection::Both`).

Returns a vector with the X and Y scaling factors.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/media_extensions.rs#L18)

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

### calculate_size

```rust
fn calculate_size(stretch: Stretch, destination_size: Size, source_size: Size, stretch_direction: StretchDirection) -> Size
```

Calculates a scaled size based on a `Stretch` value.

* `stretch` - The stretch mode.
* `destination_size` - The size of the destination viewport.
* `source_size` - The size of the source.
* `stretch_direction` - The stretch direction (upstream default:
  `StretchDirection::Both`).

Returns the size of the stretched source.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/media_extensions.rs#L105)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- [`ClassDefaults`](/docs/0.5.0/api/ferroui-base/trait-classdefaults/)
- `Borrow<T>`
- `BorrowMut<T>`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- `Any`
- `ErasedDestructor`
- `IntoEither`

## Availability

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