# ColorToHexConverter

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-controls-color-picker/converters/struct-colortohexconverter/

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

```rust
struct ColorToHexConverter
```

Converts a color to a hex string and vice versa.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls.ColorPicker/converters/color_to_hex_converter.rs#L15)

## Members

- [`new`](#function-new)
- [`is_alpha_visible`](#function-is_alpha_visible)
- [`set_is_alpha_visible`](#function-set_is_alpha_visible)
- [`alpha_position`](#function-alpha_position)
- [`set_alpha_position`](#function-set_alpha_position)
- [`to_hex_string`](#function-to_hex_string)
- [`parse_hex_string`](#function-parse_hex_string)

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

### new

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

Initializes a new instance of the `ColorToHexConverter` class.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls.ColorPicker/converters/color_to_hex_converter.rs#L28)

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

### is_alpha_visible

```rust
fn is_alpha_visible(self: &Self) -> bool
```

Gets a value indicating whether the alpha component is visible in the Hex formatted text.

When hidden the existing alpha component value is maintained. Also when hidden the user is still
able to input an 8-digit number with alpha. Alpha will be processed but then removed when displayed.

Because this property only controls whether alpha is displayed (and it is still processed regardless)
it is termed 'Visible' instead of 'Enabled'.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls.ColorPicker/converters/color_to_hex_converter.rs#L39)

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

### set_is_alpha_visible

```rust
fn set_is_alpha_visible(self: &Self, value: bool)
```

Sets `is_alpha_visible`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls.ColorPicker/converters/color_to_hex_converter.rs#L44)

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

### alpha_position

```rust
fn alpha_position(self: &Self) -> AlphaComponentPosition
```

Gets the position of a color's alpha component relative to all other components.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls.ColorPicker/converters/color_to_hex_converter.rs#L49)

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

### set_alpha_position

```rust
fn set_alpha_position(self: &Self, value: AlphaComponentPosition)
```

Sets `alpha_position`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls.ColorPicker/converters/color_to_hex_converter.rs#L54)

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

### to_hex_string

```rust
fn to_hex_string(color: Color, alpha_position: AlphaComponentPosition, include_alpha: bool, include_symbol: bool) -> String
```

Converts the given color to its hex color value string representation.

- `color`: the color to represent as a hex value string.
- `alpha_position`: the output position of the alpha component.
- `include_alpha`: whether the alpha component will be included in the hex string
  (upstream's default is `true`).
- `include_symbol`: whether the hex symbol '#' will be added (upstream's default is `false`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls.ColorPicker/converters/color_to_hex_converter.rs#L65)

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

### parse_hex_string

```rust
fn parse_hex_string(hex_color: &str, alpha_position: AlphaComponentPosition) -> Option<Color>
```

Parses a hex color value string into a new `Color`.

`hex_color` is the hex color string to parse (with or without the
'#' symbol); `alpha_position` is the input position of the alpha
component. Returns the parsed color; otherwise, `None`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls.ColorPicker/converters/color_to_hex_converter.rs#L102)

## 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`
- `Debug`
- `Default`
- [`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/).
