Table of Contents

Struct Color

Namespace
Avalonia.Media
Assembly
Avalonia.Base.dll

An ARGB color.

public readonly struct Color : IEquatable<Color>
Implements
Inherited Members

Constructors

Color(byte, byte, byte, byte)

Initializes a new instance of the 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.

Properties

A

Gets the Alpha component of the color.

public byte A { get; }

Property Value

byte

B

Gets the Blue component of the color.

public byte B { get; }

Property Value

byte

G

Gets the Green component of the color.

public byte G { get; }

Property Value

byte

R

Gets the Red component of the color.

public byte R { get; }

Property Value

byte

Methods

Equals(Color)

public bool Equals(Color other)

Parameters

other Color

Returns

bool

Equals(object?)

public override bool Equals(object? obj)

Parameters

obj object

Returns

bool

FromArgb(byte, byte, byte, byte)

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

public static 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

Color

The color.

FromRgb(byte, byte, byte)

Creates a Color from red, green and blue components.

public static 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

Color

The color.

FromUInt32(uint)

Creates a Color from an integer.

public static Color FromUInt32(uint value)

Parameters

value uint

The integer value.

Returns

Color

The color.

GetHashCode()

public override int GetHashCode()

Returns

int

Parse(ReadOnlySpan<char>)

Parses a color string.

public static Color Parse(ReadOnlySpan<char> s)

Parameters

s ReadOnlySpan<char>

The color string.

Returns

Color

The Color.

Parse(string)

Parses a color string.

public static Color Parse(string s)

Parameters

s string

The color string.

Returns

Color

The Color.

ToHsl()

Returns the HSL color model equivalent of this RGB color.

public HslColor ToHsl()

Returns

HslColor

The HSL equivalent color.

ToHsl(byte, byte, byte, byte)

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

public static HslColor ToHsl(byte red, byte green, byte blue, byte alpha = 255)

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

HslColor

A new HslColor equivalent to the given RGBA values.

ToHsv()

Returns the HSV color model equivalent of this RGB color.

public HsvColor ToHsv()

Returns

HsvColor

The HSV equivalent color.

ToHsv(byte, byte, byte, byte)

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

public static HsvColor ToHsv(byte red, byte green, byte blue, byte alpha = 255)

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

HsvColor

A new HsvColor equivalent to the given RGBA values.

ToString()

Returns the string representation of the color.

public override string ToString()

Returns

string

The string representation of the color.

ToUInt32()

Returns the integer representation of the color.

public uint ToUInt32()

Returns

uint

The integer representation of the color.

TryParse(ReadOnlySpan<char>, out Color)

Parses a color string.

public static bool TryParse(ReadOnlySpan<char> s, out Color color)

Parameters

s ReadOnlySpan<char>

The color string.

color Color

The parsed color

Returns

bool

The status of the operation.

TryParse(string?, out Color)

Parses a color string.

public static bool TryParse(string? s, out Color color)

Parameters

s string

The color string.

color Color

The parsed color

Returns

bool

The status of the operation.

Operators

operator ==(Color, Color)

Indicates whether the values of two specified Color objects are equal.

public static bool operator ==(Color left, Color right)

Parameters

left Color

The first object to compare.

right Color

The second object to compare.

Returns

bool

True if left and right are equal; otherwise, false.

operator !=(Color, Color)

Indicates whether the values of two specified Color objects are not equal.

public static bool operator !=(Color left, Color right)

Parameters

left Color

The first object to compare.

right Color

The second object to compare.

Returns

bool

True if left and right are not equal; otherwise, false.