# ColorToBrushConverter

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-markup-xaml/converters/struct-colortobrushconverter/

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

```rust
struct ColorToBrushConverter
```

Converts a color to a brush when a brush is asked for: what lets a
color resource be used where a brush is expected.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Markup/FerroUI.Markup.Xaml/converters/color_to_brush_converter.rs#L15)

## Members

- [`new`](#function-new)
- [`convert_to`](#function-convert_to)
- [`convert_back_to`](#function-convert_back_to)

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

### new

```rust
fn new() -> Rc<Self>
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Markup/FerroUI.Markup.Xaml/converters/color_to_brush_converter.rs#L26)

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

### convert_to

```rust
fn convert_to(value: Option<BoxedValue>, target_type: Option<ValueType>) -> Option<BoxedValue>
```

If `target_type` is the brush type and `value` is a color: a solid
color brush of that color. Otherwise the value unchanged.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Markup/FerroUI.Markup.Xaml/converters/color_to_brush_converter.rs#L32)

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

### convert_back_to

```rust
fn convert_back_to(value: Option<BoxedValue>, target_type: Option<ValueType>) -> Option<BoxedValue>
```

If `target_type` is the color type and `value` is a solid color
brush: the color of the brush. Otherwise the value unchanged.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Markup/FerroUI.Markup.Xaml/converters/color_to_brush_converter.rs#L45)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- `Borrow<T>`
- `BorrowMut<T>`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- `Any`
- [`AnyValue`](/docs/0.5.0/api/ferroui-base/trait-anyvalue/)
- [`ClassDefaults`](/docs/0.5.0/api/ferroui-base/trait-classdefaults/)
- `ErasedDestructor`
- `IntoEither`
- [`IValueConverter`](/docs/0.5.0/api/ferroui-base/data/converters/trait-ivalueconverter/)
- `PartialEq`
- [`MarkupTyped`](/docs/0.5.0/api/ferroui-base/metadata/trait-markuptyped/)

## Availability

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