Skip to main content

HsvColor Struct

Definition

Namespace:Avalonia.Media
Assembly:Avalonia.Base
Package:Avalonia

Defines a color using the hue/saturation/value (HSV) model. This uses a cylindrical-coordinate representation of a color.

public struct HsvColor

Inheritance: ValueType -> HsvColor

Implements: IEquatable<HsvColor>

Constructors

NameDescription
HsvColor (2 overloads)Initializes a new instance of the Avalonia.Media.HsvColor struct.

HsvColor overloads

HsvColor Constructor

Initializes a new instance of the Avalonia.Media.HsvColor struct.

public HsvColor(Avalonia.Media.Color color)
Parameters

color Avalonia.Media.Color

The RGB color to convert to HSV.

HsvColor Constructor

Initializes a new instance of the Avalonia.Media.HsvColor struct.

public HsvColor(double alpha, double hue, double saturation, double value)
Parameters

alpha double

The Alpha (transparency) component in the range from 0..1.

hue double

The Hue component in the range from 0..360. Note that 360 is equivalent to 0 and will be adjusted automatically.

saturation double

The Saturation component in the range from 0..1.

value double

The Value component in the range from 0..1.

Methods

NameDescription
Equals (2 overloads)No summary available.
FromAhsvCreates a new Avalonia.Media.HsvColor from individual color component values.
FromHsvCreates a new Avalonia.Media.HsvColor from individual color component values.
GetHashCodeGets a hashcode for this object. Hashcode is not guaranteed to be unique.
ParseParses an HSV color string.
ToHsl (2 overloads)Returns the HSL color model equivalent of this HSV color.
ToRgb (2 overloads)Returns the RGB color model equivalent of this HSV color.
ToStringNo summary available.
TryParseNo summary available.

Equals overloads

Equals Method

public bool Equals(Avalonia.Media.HsvColor other)
Parameters

other Avalonia.Media.HsvColor

Returns

bool

Equals Method

public bool Equals(object obj)
Parameters

obj object

Returns

bool

FromAhsv Method

Creates a new Avalonia.Media.HsvColor from individual color component values.

public Avalonia.Media.HsvColor FromAhsv(double a, double h, double s, double v)

Parameters

a double

The Alpha (transparency) component in the range from 0..1.

h double

The Hue component in the range from 0..360.

s double

The Saturation component in the range from 0..1.

v double

The Value component in the range from 0..1.

Returns

Avalonia.Media.HsvColor

A new Avalonia.Media.HsvColor built from the individual color component values.

Remarks

This exists for symmetry with the Avalonia.Media.Color struct; however, the appropriate constructor should commonly be used instead.

FromHsv Method

Creates a new Avalonia.Media.HsvColor from individual color component values.

public Avalonia.Media.HsvColor FromHsv(double h, double s, double v)

Parameters

h double

The Hue component in the range from 0..360.

s double

The Saturation component in the range from 0..1.

v double

The Value component in the range from 0..1.

Returns

Avalonia.Media.HsvColor

A new Avalonia.Media.HsvColor built from the individual color component values.

Remarks

This exists for symmetry with the Avalonia.Media.Color struct; however, the appropriate constructor should commonly be used instead.

GetHashCode Method

Gets a hashcode for this object. Hashcode is not guaranteed to be unique.

public int GetHashCode()

Returns

int

The hashcode for this object.

Parse Method

Parses an HSV color string.

public Avalonia.Media.HsvColor Parse(string s)

Parameters

s string

The HSV color string to parse.

Returns

Avalonia.Media.HsvColor

The parsed Avalonia.Media.HsvColor.

ToHsl overloads

ToHsl Method

Returns the HSL color model equivalent of this HSV color.

public Avalonia.Media.HslColor ToHsl()
Returns

Avalonia.Media.HslColor

The HSL equivalent color.

ToHsl Method

Converts the given HSVA color component values to their HSL color equivalent.

public Avalonia.Media.HslColor ToHsl(double hue, double saturation, double value, double alpha)
Parameters

hue double

The Hue component in the HSV color model in the range from 0..360.

saturation double

The Saturation component in the HSV color model in the range from 0..1.

value double

The Value component in the HSV color model in the range from 0..1.

alpha double

The Alpha component in the range from 0..1.

Returns

Avalonia.Media.HslColor

A new Avalonia.Media.HslColor equivalent to the given HSVA values.

ToRgb overloads

ToRgb Method

Returns the RGB color model equivalent of this HSV color.

public Avalonia.Media.Color ToRgb()
Returns

Avalonia.Media.Color

The RGB equivalent color.

ToRgb Method

Converts the given HSVA color component values to their RGB color equivalent.

public Avalonia.Media.Color ToRgb(double hue, double saturation, double value, double alpha)
Parameters

hue double

The Hue component in the HSV color model in the range from 0..360.

saturation double

The Saturation component in the HSV color model in the range from 0..1.

value double

The Value component in the HSV color model in the range from 0..1.

alpha double

The Alpha component in the range from 0..1.

Returns

Avalonia.Media.Color

A new RGB Avalonia.Media.Color equivalent to the given HSVA values.

ToString Method

public string ToString()

Returns

string

TryParse Method

public bool TryParse(string s, Avalonia.Media.HsvColor& hsvColor)

Parameters

s string

hsvColor Avalonia.Media.HsvColor&

Returns

bool

Properties

NameDescription
AGets the Alpha (transparency) component in the range from 0..1 (percentage).
HGets the Hue component in the range from 0..360 (degrees). This is the color's location, in degrees, on a color wheel/circle from 0 to 360. Note that 360 is equivalent to 0 and will be adjusted automatically.
SGets the Saturation component in the range from 0..1 (percentage).
VGets the Value (or Brightness/Intensity) component in the range from 0..1 (percentage).

A Property

Gets the Alpha (transparency) component in the range from 0..1 (percentage).

public double A { get; set; }

Remarks

  • 0 is fully transparent.
  • 1 is fully opaque.

H Property

Gets the Hue component in the range from 0..360 (degrees). This is the color's location, in degrees, on a color wheel/circle from 0 to 360. Note that 360 is equivalent to 0 and will be adjusted automatically.

public double H { get; set; }

Remarks

  • 0/360 degrees is Red.
  • 60 degrees is Yellow.
  • 120 degrees is Green.
  • 180 degrees is Cyan.
  • 240 degrees is Blue.
  • 300 degrees is Magenta.

S Property

Gets the Saturation component in the range from 0..1 (percentage).

public double S { get; set; }

Remarks

  • 0 is fully white (or a shade of gray) and shows no color.
  • 1 is the full color.

V Property

Gets the Value (or Brightness/Intensity) component in the range from 0..1 (percentage).

public double V { get; set; }

Remarks

  • 0 is fully black and shows no color.
  • 1 is the brightest and shows full color.