# Brush

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

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

```rust
struct Brush
```

Describes how an area is painted. Abstract base class of the mutable
brushes.

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

## Members

- [`TYPE`](#assoc_const-type)
- [`to_ref`](#function-to_ref)
- [`on_referenced_from_compositor`](#function-on_referenced_from_compositor)
- [`on_unreferenced_from_compositor`](#function-on_unreferenced_from_compositor)
- [`prepare_serialization`](#function-prepare_serialization)
- [`opacity_property`](#function-opacity_property)
- [`transform_property`](#function-transform_property)
- [`transform_origin_property`](#function-transform_origin_property)
- [`relative_transform_property`](#function-relative_transform_property)
- [`construct`](#function-construct)
- [`opacity`](#function-opacity)
- [`set_opacity`](#function-set_opacity)
- [`transform`](#function-transform)
- [`set_transform`](#function-set_transform)
- [`transform_origin`](#function-transform_origin)
- [`set_transform_origin`](#function-set_transform_origin)
- [`relative_transform`](#function-relative_transform)
- [`set_relative_transform`](#function-set_relative_transform)
- [`parse`](#function-parse)
- [`invalidated`](#function-invalidated)

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

### TYPE

```rust
const TYPE: &'static $crate::TypeInfo
```

The runtime type of this class.

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

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

### to_ref

```rust
fn to_ref(self: &Self) -> $crate::Ref<Brush>
```

Returns a strong reference to this object.

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

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

### on_referenced_from_compositor

```rust
fn on_referenced_from_compositor(self: &Self, c: &Rc<Compositor>)
```

Called when the brush got its counterpart on a compositor.

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

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

### on_unreferenced_from_compositor

```rust
fn on_unreferenced_from_compositor(self: &Self, c: &Rc<Compositor>)
```

Called when the brush lost its counterpart on a compositor.

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

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

### prepare_serialization

```rust
fn prepare_serialization(self: &Self, c: &Rc<Compositor>)
```

Creates the server objects the state of the brush refers to,
before the state is written for its counterpart on a compositor
(see `ICompositorSerializable::prepare_serialization`).

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

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

### opacity_property

```rust
fn opacity_property() -> &'static StyledProperty<f64>
```



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

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

### transform_property

```rust
fn transform_property() -> &'static StyledProperty<Option<Rc<dyn ITransform>>>
```



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

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

### transform_origin_property

```rust
fn transform_origin_property() -> &'static StyledProperty<RelativePoint>
```



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

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

### relative_transform_property

```rust
fn relative_transform_property() -> &'static StyledProperty<Option<Rc<dyn ITransform>>>
```



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

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

### construct

```rust
fn construct() -> Self
```

Creates the class data; see `FerroObject::construct`.

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

<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/brush.rs#L188)

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

### set_opacity

```rust
fn set_opacity(self: &Self, value: f64)
```



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

<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/brush.rs#L197)

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

### set_transform

```rust
fn set_transform(self: &Self, value: Option<Rc<dyn ITransform>>)
```



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

<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/brush.rs#L206)

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

### set_transform_origin

```rust
fn set_transform_origin(self: &Self, value: RelativePoint)
```



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

<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/brush.rs#L216)

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

### set_relative_transform

```rust
fn set_relative_transform(self: &Self, value: Option<Rc<dyn ITransform>>)
```



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

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

### parse

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

Parses a brush string: a known color name or any color format
accepted by `Color::parse`.

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

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

### invalidated

```rust
fn invalidated(self: &Self, handler: impl Fn() -> () + 'static) -> Subscription
```

Subscribes to invalidation of the brush: raised whenever a change
requires the brush to be redrawn. Dropping the returned guard removes
the handler; `Subscription::detach` keeps it for the life of the
brush.

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

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- [`BrushImplExt`](/docs/0.5.0/api/ferroui-base/media/trait-brushimplext/)
- [`FerroObjectImplExt`](/docs/0.5.0/api/ferroui-base/trait-ferroobjectimplext/)
- [`ClassDefaults`](/docs/0.5.0/api/ferroui-base/trait-classdefaults/)
- `Borrow<T>`
- `BorrowMut<T>`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- [`Receiver`](/docs/0.5.0/api/ferroui-system/task/oneshot/struct-receiver/)
- `Any`
- `ErasedDestructor`
- `IntoEither`
- `Deref`
- [`Upcast<T>`](/docs/0.5.0/api/ferroui-base/trait-upcast/)
- [`Upcast<Brush>`](/docs/0.5.0/api/ferroui-base/trait-upcast/)
- [`StaticType`](/docs/0.5.0/api/ferroui-base/trait-statictype/)
- [`ObjectType`](/docs/0.5.0/api/ferroui-base/trait-objecttype/)
- [`Subclassable<T>`](/docs/0.5.0/api/ferroui-base/trait-subclassable/)
- [`FerroObjectImpl`](/docs/0.5.0/api/ferroui-base/trait-ferroobjectimpl/)
- [`BrushImpl`](/docs/0.5.0/api/ferroui-base/media/trait-brushimpl/)
- `ICompositionRenderResource`
- [`IAffectsRender`](/docs/0.5.0/api/ferroui-base/media/trait-iaffectsrender/)

## Availability

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