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
Properties
A
public float A { get; init; }
Property Value
B
public float B { get; init; }
Property Value
Black
Opaque black.
public static Color Black { get; }
Property Value
Contrasting
Black or white, whichever reads best on this color.
public Color Contrasting { get; }
Property Value
G
public float G { get; init; }
Property Value
IsTransparent
true if the color is fully transparent.
public bool IsTransparent { get; }
Property Value
Luminance
Relative luminance (sRGB approximation).
public float Luminance { get; }
Property Value
R
public float R { get; init; }
Property Value
Transparent
Fully transparent black.
public static Color Transparent { get; }
Property Value
White
Opaque white.
public static Color White { get; }
Property Value
Methods
Darken(float)
Mixes towards black by amount (0..1).
public Color Darken(float amount)
Parameters
amountfloat
Returns
Fade(float)
Multiplies the alpha by a factor.
public Color Fade(float factor)
Parameters
factorfloat
Returns
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
Returns
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
Returns
FromRgb(uint, float)
Creates a color from a 0xRRGGBB value.
public static Color FromRgb(uint rgb, float alpha = 1)
Parameters
Returns
Lerp(Color, Color, float)
Linear interpolation between two colors.
public static Color Lerp(Color a, Color b, float t)
Parameters
Returns
Lighten(float)
Mixes towards white by amount (0..1).
public Color Lighten(float amount)
Parameters
amountfloat
Returns
Parse(string)
Parses "#RGB", "#RRGGBB" or "#RRGGBBAA" (the leading '#' is optional).
public static Color Parse(string text)
Parameters
textstring
Returns
ToHex()
Formats as "#RRGGBB" or "#RRGGBBAA" when not opaque.
public string ToHex()
Returns
ToHsv()
Converts to hue (degrees 0..360), saturation and value (0..1).
public (float H, float S, float V) ToHsv()
Returns
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
Returns
WithAlpha(float)
Returns the color with another alpha.
public Color WithAlpha(float alpha)
Parameters
alphafloat