# ImmediateDrawingContext

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

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

```rust
struct ImmediateDrawingContext<'a>
```

A drawing context that draws immediately to a platform drawing context
implementation, using immutable resources only. This is what custom draw
operations render with.

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

## Members

- [`current_transform`](#function-current_transform)
- [`draw_bitmap`](#function-draw_bitmap)
- [`draw_bitmap_rects`](#function-draw_bitmap_rects)
- [`draw_line`](#function-draw_line)
- [`draw_rectangle`](#function-draw_rectangle)
- [`draw_rectangle_outline`](#function-draw_rectangle_outline)
- [`draw_ellipse`](#function-draw_ellipse)
- [`draw_glyph_run`](#function-draw_glyph_run)
- [`fill_rectangle`](#function-fill_rectangle)
- [`pop`](#function-pop)
- [`push_rounded_clip`](#function-push_rounded_clip)
- [`push_clip`](#function-push_clip)
- [`push_opacity`](#function-push_opacity)
- [`push_opacity_mask`](#function-push_opacity_mask)
- [`push_post_transform`](#function-push_post_transform)
- [`push_pre_transform`](#function-push_pre_transform)
- [`push_set_transform`](#function-push_set_transform)
- [`push_transform_container`](#function-push_transform_container)
- [`dispose`](#function-dispose)
- [`try_get_feature`](#function-try_get_feature)

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

### current_transform

```rust
fn current_transform(self: &Self) -> Matrix
```

The current transform of the drawing context.

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

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

### draw_bitmap

```rust
fn draw_bitmap(self: &mut Self, source: &Bitmap, rect: Rect)
```

Draws a bitmap into `rect`.

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

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

### draw_bitmap_rects

```rust
fn draw_bitmap_rects(self: &mut Self, source: &Bitmap, source_rect: Rect, dest_rect: Rect)
```

Draws the part of a bitmap inside `source_rect` into `dest_rect`.

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

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

### draw_line

```rust
fn draw_line(self: &mut Self, pen: &ImmutablePen, p1: Point, p2: Point)
```

Draws a line.

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

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

### draw_rectangle

```rust
fn draw_rectangle(self: &mut Self, brush: Option<&dyn IImmutableBrush>, pen: Option<&ImmutablePen>, rect: Rect, radius_x: f64, radius_y: f64, box_shadows: &BoxShadows)
```

Draws a rectangle with the specified brush and pen.

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

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

### draw_rectangle_outline

```rust
fn draw_rectangle_outline(self: &mut Self, pen: &ImmutablePen, rect: Rect, corner_radius: f32)
```

Draws the outline of a rectangle.

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

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

### draw_ellipse

```rust
fn draw_ellipse(self: &mut Self, brush: Option<&dyn IImmutableBrush>, pen: Option<&ImmutablePen>, center: Point, radius_x: f64, radius_y: f64)
```

Draws an ellipse with the specified brush and pen.

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

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

### draw_glyph_run

```rust
fn draw_glyph_run(self: &mut Self, foreground: &dyn IImmutableBrush, glyph_run: &dyn IImmutableGlyphRunReference)
```

Draws a glyph run, if the reference still holds its platform glyph
run.

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

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

### fill_rectangle

```rust
fn fill_rectangle(self: &mut Self, brush: &dyn IImmutableBrush, rect: Rect, corner_radius: f32)
```

Draws a filled rectangle.

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

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

### pop

```rust
fn pop(self: &mut Self, state: ImmediatePushedState)
```

Pops a pushed state (C# `PushedState.Dispose`). Panics if the state
is not the most recently pushed one.

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

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

### push_rounded_clip

```rust
fn push_rounded_clip(self: &mut Self, clip: RoundedRect) -> ImmediatePushedState
```

Pushes a rounded clip rectangle.

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

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

### push_clip

```rust
fn push_clip(self: &mut Self, clip: Rect) -> ImmediatePushedState
```

Pushes a clip rectangle.

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

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

### push_opacity

```rust
fn push_opacity(self: &mut Self, opacity: f64, bounds: Rect) -> ImmediatePushedState
```

Pushes an opacity value.

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

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

### push_opacity_mask

```rust
fn push_opacity_mask(self: &mut Self, mask: &dyn IImmutableBrush, bounds: Rect) -> ImmediatePushedState
```

Pushes an opacity mask.

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

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

### push_post_transform

```rust
fn push_post_transform(self: &mut Self, matrix: Matrix) -> ImmediatePushedState
```

Pushes a matrix post-transformation.

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

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

### push_pre_transform

```rust
fn push_pre_transform(self: &mut Self, matrix: Matrix) -> ImmediatePushedState
```

Pushes a matrix pre-transformation.

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

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

### push_set_transform

```rust
fn push_set_transform(self: &mut Self, matrix: Matrix) -> ImmediatePushedState
```

Sets the current matrix transformation.

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

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

### push_transform_container

```rust
fn push_transform_container(self: &mut Self) -> ImmediatePushedState
```

Pushes a new transform context.

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

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

### dispose

```rust
fn dispose(self: Self)
```

Pops every state still pushed and releases the context (and the
platform implementation, if the context owns it).

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

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

### try_get_feature

```rust
fn try_get_feature(self: &mut Self, feature_type: TypeId) -> Option<Rc<dyn Any>>
```

Queries the platform drawing context implementation for an optional
feature.

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

## 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`
- `Drop`

## Availability

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