# CompositionEffectBrush

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-base/rendering/composition/brushes/struct-compositioneffectbrush/

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

```rust
struct CompositionEffectBrush
```

A brush that draws an effect graph over its sources (WinUI
`Microsoft.UI.Composition.CompositionEffectBrush`), made by
`CompositionEffectFactory::create_brush`.

The source parameters of the graph are bound to composition brushes
with `set_source_parameter`; the brush
draws the graph over the area of the visual that shows it: a Gaussian
blur is the blur effect of the drawing context around its source
(nothing is blurred on a drawing context without effects), an opacity
pushes an opacity, a cross-fade paints `source1` with `1 - weight` and
`source2` with `weight` over it, a composite paints its sources in
order, a colour source fills the area.

The properties named as animatable when the factory was made
(`Blur.BlurAmount`, `Crossfade.Weight`) are entries of
`properties`, set to the values of the description:
a change of an entry, or an animation of it (`start_animation` on the
brush or on its properties), redraws the brush.

As the effect of a `LayerVisual`,
the first source parameter of the graph is the composed children of the
layer.

Deviation (winui-composition.md): the cross-fade draws its second source
over the first, each with its weight, rather than adding them; animations
of the effect properties under an animation controller are started on
the properties, not on the brush.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/rendering/composition/brushes/composition_effect_brush.rs#L91)

## Members

- [`from_brush`](#function-from_brush)
- [`brush`](#function-brush)
- [`properties`](#function-properties)
- [`source_parameter_names`](#function-source_parameter_names)
- [`get_source_parameter`](#function-get_source_parameter)
- [`set_source_parameter`](#function-set_source_parameter)

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

### from_brush

```rust
fn from_brush(brush: &Rc<CompositionBrush>) -> Option<CompositionEffectBrush>
```

The handle of `brush` as an effect brush, if it is one.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/rendering/composition/brushes/composition_effect_brush.rs#L124)

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

### brush

```rust
fn brush(self: &Self) -> &Rc<CompositionBrush>
```

The brush as a composition brush.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/rendering/composition/brushes/composition_effect_brush.rs#L136)

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

### properties

```rust
fn properties(self: &Self) -> Rc<CompositionPropertySet>
```

`Properties`: the property set whose entries are the animatable
properties of the effect (`Blur.BlurAmount`). Inserting a value of
such an entry or animating it changes what the brush draws; other
entries are the application's.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/rendering/composition/brushes/composition_effect_brush.rs#L144)

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

### source_parameter_names

```rust
fn source_parameter_names(self: &Self) -> Vec<String>
```

The names of the source parameters of the graph, in graph order
(empty when the factory did not load its effect).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/rendering/composition/brushes/composition_effect_brush.rs#L150)

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

### get_source_parameter

```rust
fn get_source_parameter(self: &Self, name: &str) -> Option<Rc<CompositionBrush>>
```

`GetSourceParameter(name)`: the brush bound to the source parameter
`name`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/rendering/composition/brushes/composition_effect_brush.rs#L156)

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

### set_source_parameter

```rust
fn set_source_parameter(self: &Self, name: &str, source: Option<Rc<CompositionBrush>>)
```

`SetSourceParameter(name, source)`: binds the source parameter `name`
to `source` (`None` unbinds it; an unbound parameter draws nothing).

Panics when the loaded graph has no source parameter of that name
(WinUI throws). A brush whose factory did not load its effect accepts
any name.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/rendering/composition/brushes/composition_effect_brush.rs#L166)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- [`ClassDefaults`](/docs/0.5.0/api/ferroui-base/trait-classdefaults/)
- `Borrow<T>`
- `BorrowMut<T>`
- `CloneToUninit`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- [`Receiver`](/docs/0.5.0/api/ferroui-system/task/oneshot/struct-receiver/)
- `Any`
- `ToOwned`
- `ErasedDestructor`
- `IntoEither`
- `Clone`
- `Deref`

## Availability

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