Table of Contents

Struct Color

Namespace
PluginUI
Assembly
PluginUI.dll

Straight (non-premultiplied) RGBA color, components in [0, 1].

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

Constructors

Color(float, float, float, float)

Straight (non-premultiplied) RGBA color, components in [0, 1].

public Color(float R, float G, float B, float A = 1)

Parameters

R float
G float
B float
A float

Properties

A

public float A { get; init; }

Property Value

float

B

public float B { get; init; }

Property Value

float

Black

Opaque black.

public static Color Black { get; }

Property Value

Color

Contrasting

Black or white, whichever reads best on this color.

public Color Contrasting { get; }

Property Value

Color

G

public float G { get; init; }

Property Value

float

IsTransparent

true if the color is fully transparent.

public bool IsTransparent { get; }

Property Value

bool

Luminance

Relative luminance (sRGB approximation).

public float Luminance { get; }

Property Value

float

R

public float R { get; init; }

Property Value

float

Transparent

Fully transparent black.

public static Color Transparent { get; }

Property Value

Color

White

Opaque white.

public static Color White { get; }

Property Value

Color

Methods

Darken(float)

Mixes towards black by amount (0..1).

public Color Darken(float amount)

Parameters

amount float

Returns

Color

Fade(float)

Multiplies the alpha by a factor.

public Color Fade(float factor)

Parameters

factor float

Returns

Color

FromBytes(byte, byte, byte, byte)

Creates a color from 8-bit components.

public static Color FromBytes(byte r, byte g, byte b, byte a = 255)

Parameters

r byte
g byte
b byte
a byte

Returns

Color

FromHsv(float, float, float, float)

Creates a color from hue (degrees), saturation and value (0..1).

public static Color FromHsv(float h, float s, float v, float a = 1)

Parameters

h float
s float
v float
a float

Returns

Color

FromRgb(uint, float)

Creates a color from a 0xRRGGBB value.

public static Color FromRgb(uint rgb, float alpha = 1)

Parameters

rgb uint
alpha float

Returns

Color

Lerp(Color, Color, float)

Linear interpolation between two colors.

public static Color Lerp(Color a, Color b, float t)

Parameters

a Color
b Color
t float

Returns

Color

Lighten(float)

Mixes towards white by amount (0..1).

public Color Lighten(float amount)

Parameters

amount float

Returns

Color

Parse(string)

Parses "#RGB", "#RRGGBB" or "#RRGGBBAA" (the leading '#' is optional).

public static Color Parse(string text)

Parameters

text string

Returns

Color

ToHex()

Formats as "#RRGGBB" or "#RRGGBBAA" when not opaque.

public string ToHex()

Returns

string

ToHsv()

Converts to hue (degrees 0..360), saturation and value (0..1).

public (float H, float S, float V) ToHsv()

Returns

(float H, float S, float V)

ToString()

Returns the fully qualified type name of this instance.

public override string ToString()

Returns

string

The fully qualified type name.

TryParse(string?, out Color)

Tries to parse a hexadecimal color string.

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

Parameters

text string
color Color

Returns

bool

WithAlpha(float)

Returns the color with another alpha.

public Color WithAlpha(float alpha)

Parameters

alpha float

Returns

Color