Skip to main content

Color Struct

Definition​

Namespace:Avalonia.Media
Assembly:Avalonia.Base
Package:Avalonia
Source:Color.cs

An ARGB color.

public struct Color

Inheritance: ValueType -> Color

Implements: IEquatable<Color>

Constructors​

NameDescription
ColorInitializes a new instance of the Avalonia.Media.Color struct.

Color Constructor​

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

public Color(byte a, byte r, byte g, byte b)

Parameters​

a byte

The alpha component.

r byte

The red component.

g byte

The green component.

b byte

The blue component.

Methods​

NameDescription
Equals (2 overloads)No summary available.
FromArgbCreates a Avalonia.Media.Color from alpha, red, green and blue components.
FromRgbCreates a Avalonia.Media.Color from red, green and blue components.
FromUInt32Creates a Avalonia.Media.Color from an integer.
GetHashCodeNo summary available.
Parse (2 overloads)No summary available.
ToHsl (2 overloads)Returns the HSL color model equivalent of this RGB color.
ToHsv (2 overloads)Returns the HSV color model equivalent of this RGB color.
ToStringReturns the string representation of the color.
ToUInt32Returns the integer representation of the color.
TryParse (2 overloads)No summary available.

Equals overloads​

Equals Method​

public bool Equals(Avalonia.Media.Color other)
Parameters​

other Avalonia.Media.Color

Returns​

bool

Equals Method​

public bool Equals(object obj)
Parameters​

obj object

Returns​

bool

FromArgb Method​

Creates a Avalonia.Media.Color from alpha, red, green and blue components.

public Avalonia.Media.Color FromArgb(byte a, byte r, byte g, byte b)

Parameters​

a byte

The alpha component.

r byte

The red component.

g byte

The green component.

b byte

The blue component.

Returns​

Avalonia.Media.Color

The color.

FromRgb Method​

Creates a Avalonia.Media.Color from red, green and blue components.

public Avalonia.Media.Color FromRgb(byte r, byte g, byte b)

Parameters​

r byte

The red component.

g byte

The green component.

b byte

The blue component.

Returns​

Avalonia.Media.Color

The color.

FromUInt32 Method​

Creates a Avalonia.Media.Color from an integer.

public Avalonia.Media.Color FromUInt32(uint value)

Parameters​

value uint

The integer value.

Returns​

Avalonia.Media.Color

The color.

GetHashCode Method​

public int GetHashCode()

Returns​

int

Parse overloads​

Parse Method​

public Avalonia.Media.Color Parse(ReadOnlySpan<char> s)
Parameters​

s ReadOnlySpan<char>

Returns​

Avalonia.Media.Color

Parse Method​

Parses a color string.

public Avalonia.Media.Color Parse(string s)
Parameters​

s string

The color string.

Returns​

Avalonia.Media.Color

The Avalonia.Media.Color.

ToHsl overloads​

ToHsl Method​

Returns the HSL color model equivalent of this RGB color.

public Avalonia.Media.HslColor ToHsl()
Returns​

Avalonia.Media.HslColor

The HSL equivalent color.

ToHsl Method​

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

public Avalonia.Media.HslColor ToHsl(byte red, byte green, byte blue, byte alpha)
Parameters​

red byte

The Red component in the RGB color model.

green byte

The Green component in the RGB color model.

blue byte

The Blue component in the RGB color model.

alpha byte

The Alpha component.

Returns​

Avalonia.Media.HslColor

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

ToHsv overloads​

ToHsv Method​

Returns the HSV color model equivalent of this RGB color.

public Avalonia.Media.HsvColor ToHsv()
Returns​

Avalonia.Media.HsvColor

The HSV equivalent color.

ToHsv Method​

Converts the given RGBA color component values to their HSV color equivalent.

public Avalonia.Media.HsvColor ToHsv(byte red, byte green, byte blue, byte alpha)
Parameters​

red byte

The Red component in the RGB color model.

green byte

The Green component in the RGB color model.

blue byte

The Blue component in the RGB color model.

alpha byte

The Alpha component.

Returns​

Avalonia.Media.HsvColor

A new Avalonia.Media.HsvColor equivalent to the given RGBA values.

ToString Method​

Returns the string representation of the color.

public string ToString()

Returns​

string

The string representation of the color.

ToUInt32 Method​

Returns the integer representation of the color.

public uint ToUInt32()

Returns​

uint

The integer representation of the color.

TryParse overloads​

TryParse Method​

public bool TryParse(ReadOnlySpan<char> s, Avalonia.Media.Color& color)
Parameters​

s ReadOnlySpan<char>

color Avalonia.Media.Color&

Returns​

bool

TryParse Method​

public bool TryParse(string s, Avalonia.Media.Color& color)
Parameters​

s string

color Avalonia.Media.Color&

Returns​

bool

Properties​

NameDescription
AGets the Alpha component of the color.
BGets the Blue component of the color.
GGets the Green component of the color.
RGets the Red component of the color.

A Property​

Gets the Alpha component of the color.

public byte A { get; set; }

B Property​

Gets the Blue component of the color.

public byte B { get; set; }

G Property​

Gets the Green component of the color.

public byte G { get; set; }

R Property​

Gets the Red component of the color.

public byte R { get; set; }