Struct RGBWColor
Represents an RGBW color that can be applied to an LED.
public readonly record struct RGBWColor : IEquatable<RGBWColor>
- Implements
- Inherited Members
Constructors
RGBWColor()
Creates a new RGBW color where all components are off.
public RGBWColor()
RGBWColor(byte, byte, byte, byte)
Represents an RGBW color that can be applied to an LED.
public RGBWColor(byte Red, byte Green, byte Blue, byte White = 0)
Parameters
RedbyteThe red component of the color, within [0, 255].
GreenbyteThe green component of the color, within [0, 255].
BluebyteThe blue component of the color, within [0, 255].
WhitebyteThe white component of the color, within [0, 255]. Note that not all LED strips support the white component.
Properties
Blue
The blue component of the color, within [0, 255].
public byte Blue { get; init; }
Property Value
Green
The green component of the color, within [0, 255].
public byte Green { get; init; }
Property Value
Red
The red component of the color, within [0, 255].
public byte Red { get; init; }
Property Value
White
The white component of the color, within [0, 255]. Note that not all LED strips support the white component.
public byte White { get; init; }
Property Value
Methods
FromHSV(double, double, double)
Creates a new RGBW color from the given HSV color.
public static RGBWColor FromHSV(double h, double s, double v)
Parameters
hdoubleThe hue as an angle from [0, 360) deg, where 0 is red.
sdoubleThe saturation as a scalar from [0, 1].
vdoubleThe value as a scalar from [0, 1].
Returns
- RGBWColor
The corresponding RGB color; the white component will be 0.
FromHex(string)
Creates a new RGBW color from the given hex string.
public static RGBWColor? FromHex(string hex)
Parameters
hexstringThe color hex in the form "#RRGGBBWW" or "#RRGGBB".
Returns
- RGBWColor?
The color if the hex is valid, otherwise null
ToHexString()
Returns this RGBW color as a hex string.
public string ToHexString()
Returns
- string
A hex string in the format "#RRGGBBWW"
ToString()
Returns this RGBW color as a string.
public override string ToString()
Returns
- string
A string in the format "RGBW(Red, Green, Blue, White)"
Operators
operator *(RGBWColor, double)
Scales down the components of the color by the given brightness.
public static RGBWColor operator *(RGBWColor color, double brightness)
Parameters
Returns
- RGBWColor
New color scaled by the given brightness