# IBrush

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-base/media/trait-ibrush/

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

```rust
trait IBrush: 'static
```

Describes how an area is painted.

Implemented by the immutable brush types and, through an adapter, by
every class deriving from [`Brush`](/docs/0.5.0/api/ferroui-base/media/struct-brush/): a handle of such a class converts to
`Rc<dyn IBrush>` with `into()`, so a value of that type can hold either
kind of brush. The `as_*` members replace interface casts
(`brush as ISolidColorBrush`).

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

## Members

- [`opacity`](#function-opacity)
- [`transform`](#function-transform)
- [`transform_origin`](#function-transform_origin)
- [`relative_transform`](#function-relative_transform)
- [`as_any`](#function-as_any)
- [`as_object`](#function-as_object)
- [`as_solid_color_brush`](#function-as_solid_color_brush)
- [`as_gradient_brush`](#function-as_gradient_brush)
- [`as_linear_gradient_brush`](#function-as_linear_gradient_brush)
- [`as_radial_gradient_brush`](#function-as_radial_gradient_brush)
- [`as_conic_gradient_brush`](#function-as_conic_gradient_brush)
- [`as_tile_brush`](#function-as_tile_brush)
- [`as_image_brush`](#function-as_image_brush)
- [`as_scene_brush`](#function-as_scene_brush)
- [`as_mutable_brush`](#function-as_mutable_brush)
- [`as_immutable_brush`](#function-as_immutable_brush)
- [`as_composition_brush`](#function-as_composition_brush)
- [`into_immutable_brush`](#function-into_immutable_brush)
- [`to_shared`](#function-to_shared)
- [`equals`](#function-equals)

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

### opacity

```rust
fn opacity(self: &Self) -> f64
```

The opacity of the brush.

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

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

### transform

```rust
fn transform(self: &Self) -> Option<Rc<dyn ITransform>>
```

The transform of the brush.

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

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

### transform_origin

```rust
fn transform_origin(self: &Self) -> RelativePoint
```

The origin of the brush `transform`.

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

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

### relative_transform

```rust
fn relative_transform(self: &Self) -> Option<Rc<dyn ITransform>>
```

The transform of the brush, relative to the bounds of the painted
area.

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

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

### as_any

```rust
fn as_any(self: &Self) -> &dyn Any
```

The implementing value, for downcasts to immutable brush types. For
mutable brushes use `as_object`.

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

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

### as_object

```rust
fn as_object(self: &Self) -> Option<&FerroObject>
```

The object behind the brush when it is a mutable `Brush`.

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

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

### as_solid_color_brush

```rust
fn as_solid_color_brush(self: &Self) -> Option<&dyn ISolidColorBrush>
```

The brush viewed as `ISolidColorBrush`, when it is one.

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

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

### as_gradient_brush

```rust
fn as_gradient_brush(self: &Self) -> Option<&dyn IGradientBrush>
```

The brush viewed as `IGradientBrush`, when it is one.

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

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

### as_linear_gradient_brush

```rust
fn as_linear_gradient_brush(self: &Self) -> Option<&dyn ILinearGradientBrush>
```

The brush viewed as `ILinearGradientBrush`, when it is one.

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

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

### as_radial_gradient_brush

```rust
fn as_radial_gradient_brush(self: &Self) -> Option<&dyn IRadialGradientBrush>
```

The brush viewed as `IRadialGradientBrush`, when it is one.

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

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

### as_conic_gradient_brush

```rust
fn as_conic_gradient_brush(self: &Self) -> Option<&dyn IConicGradientBrush>
```

The brush viewed as `IConicGradientBrush`, when it is one.

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

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

### as_tile_brush

```rust
fn as_tile_brush(self: &Self) -> Option<&dyn ITileBrush>
```

The brush viewed as `ITileBrush`, when it is one.

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

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

### as_image_brush

```rust
fn as_image_brush(self: &Self) -> Option<&dyn IImageBrush>
```

The brush viewed as `IImageBrush`, when it is one.

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

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

### as_scene_brush

```rust
fn as_scene_brush(self: &Self) -> Option<&dyn ISceneBrush>
```

The brush viewed as `ISceneBrush`, when it is one.

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

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

### as_mutable_brush

```rust
fn as_mutable_brush(self: &Self) -> Option<&dyn IMutableBrush>
```

The brush viewed as `IMutableBrush`, when it is one.

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

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

### as_immutable_brush

```rust
fn as_immutable_brush(self: &Self) -> Option<&dyn IImmutableBrush>
```

The brush viewed as `IImmutableBrush`, when it is one (the `is
IImmutableBrush` test of upstream).

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

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

### as_composition_brush

```rust
fn as_composition_brush(self: &Self) -> Option<&crate::rendering::composition::CompositionBrush>
```

The brush as a composition brush, when it is one (the `is
CompositionBrush` test of upstream).

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

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

### into_immutable_brush

```rust
fn into_immutable_brush(self: Rc<Self>) -> Option<Rc<dyn IImmutableBrush>>
```

The brush as an `IImmutableBrush` handle, when it is immutable.

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

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

### to_shared

```rust
fn to_shared(self: &Self) -> Option<crate::media::SharedBrush>
```

The form of the brush that is sent to the render thread, when the
type keeps one: see `SharedBrush`. An
immutable brush creates it once, so its identity is stable.

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

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

### equals

```rust
fn equals(self: &Self, other: &dyn IBrush) -> bool
```

Whether the brush equals `other`. Brushes compare by reference unless
the type defines structural equality (immutable solid color brushes).

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

## Trait implementations

- [`IBrush`](/docs/0.5.0/api/ferroui-base/media/trait-ibrush/)

## Availability

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