# CanvasViewport

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-designer/struct-canvasviewport/

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

```rust
struct CanvasViewport
```

Maps authored artboard coordinates to a clipped native canvas without remeasuring
application content: `viewport = artboard * zoom + offset`.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Designer/viewport.rs#L17)

## Members

- [`MIN_ZOOM`](#assoc_const-min_zoom)
- [`MAX_ZOOM`](#assoc_const-max_zoom)
- [`new`](#function-new)
- [`zoom`](#function-zoom)
- [`offset`](#function-offset)
- [`transform`](#function-transform)
- [`artboard_to_viewport`](#function-artboard_to_viewport)
- [`viewport_to_artboard`](#function-viewport_to_artboard)
- [`zoom_at`](#function-zoom_at)
- [`pan`](#function-pan)
- [`fit`](#function-fit)

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

### MIN_ZOOM

```rust
const MIN_ZOOM: f64
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Designer/viewport.rs#L32)

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

### MAX_ZOOM

```rust
const MAX_ZOOM: f64
```



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

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

### new

```rust
fn new(zoom: f64, offset: Vector) -> Result<Self, String>
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Designer/viewport.rs#L37)

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

### zoom

```rust
fn zoom(self: Self) -> f64
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Designer/viewport.rs#L54)

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

### offset

```rust
fn offset(self: Self) -> Vector
```



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

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

### transform

```rust
fn transform(self: Self) -> Matrix
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Designer/viewport.rs#L61)

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

### artboard_to_viewport

```rust
fn artboard_to_viewport(self: Self, point: Point) -> Point
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Designer/viewport.rs#L65)

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

### viewport_to_artboard

```rust
fn viewport_to_artboard(self: Self, point: Point) -> Point
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Designer/viewport.rs#L72)

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

### zoom_at

```rust
fn zoom_at(self: Self, zoom: f64, anchor: Point) -> Result<Self, String>
```

Keep the authored point under `anchor` stationary, including when a limit is reached.

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

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

### pan

```rust
fn pan(self: Self, delta: Vector) -> Result<Self, String>
```

Translation is in logical viewport pixels, independently of the current zoom.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Designer/viewport.rs#L96)

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

### fit

```rust
fn fit(bounds: Rect, viewport: Size, padding: Thickness) -> Result<Self, String>
```

Center the bounds using the largest supported zoom that fits inside the padding.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Designer/viewport.rs#L101)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- `Borrow<T>`
- `BorrowMut<T>`
- `CloneToUninit`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- `Any`
- `ToOwned`
- [`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/)
- `ErasedDestructor`
- `IntoEither`
- `Same`
- [`TreeModel`](/docs/0.5.0/api/ferroui-treedatagrid-core/accessor/trait-treemodel/)
- `Clone`
- `Copy`
- `Debug`
- `StructuralPartialEq`
- `PartialEq`
- `Default`

## Availability

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