SceneColor Struct

An sRGB color with an alpha channel, 8 bits per channel.

public readonly struct SceneColor : IEquatable<SceneColor>
Implements

Constructors

NameDescription
SceneColor(byte, byte, byte, byte)An sRGB color with an alpha channel, 8 bits per channel.

SceneColor(byte, byte, byte, byte)

An sRGB color with an alpha channel, 8 bits per channel.

public SceneColor(byte R, byte G, byte B, byte A = 255)

Parameters

R byte
The red channel.
G byte
The green channel.
B byte
The blue channel.
A byte
The alpha channel: 0 is transparent, 255 is opaque.

Properties

NameDescription
AThe alpha channel: 0 is transparent, 255 is opaque.
BThe blue channel.
BlackGets the opaque black color.
GThe green channel.
IsOpaqueGets a value that indicates whether the color is fully opaque.
OpacityGets the opacity of the color, from 0 to 1.
RThe red channel.
TransparentGets the transparent color.
WhiteGets the opaque white color.

The alpha channel: 0 is transparent, 255 is opaque.

public byte A { get; init; }

Property value

byte

The blue channel.

public byte B { get; init; }

Property value

byte

Gets the opaque black color.

public static SceneColor Black { get; }

Property value

SceneColor

The green channel.

public byte G { get; init; }

Property value

byte

Gets a value that indicates whether the color is fully opaque.

public bool IsOpaque { get; }

Property value

bool

Gets the opacity of the color, from 0 to 1.

public double Opacity { get; }

Property value

double

The red channel.

public byte R { get; init; }

Property value

byte

Transparent

SceneColor.cs

Gets the transparent color.

public static SceneColor Transparent { get; }

Property value

SceneColor

Gets the opaque white color.

public static SceneColor White { get; }

Property value

SceneColor

Methods

NameDescription
Deconstruct(byte, byte, byte, byte)
Equals(SceneColor)
Equals(object)
FromHsl(double, double, double, double)Creates a color from its hue, saturation and lightness, as the CSS function hsl().
GetHashCode()
Parse(string)Parses a CSS color: #rgb, #rgba, #rrggbb, #rrggbbaa, a CSS color name such as steelblue, or the functions rgb(), rgba(), hsl() and hsla(), with commas or spaces.
ToHexRgb()Returns the color as #rrggbb, without its alpha channel.
ToString()Returns the color as #rrggbb, or #rrggbbaa when it is not opaque.
TryParse(string?, SceneColor)Tries to parse a CSS color: #rgb, #rgba, #rrggbb, #rrggbbaa, a CSS color name, or rgb(), rgba(), hsl() and hsla().
WithOpacity(double)Returns a copy of the color with another opacity.

Deconstruct(byte, byte, byte, byte)

public void Deconstruct(out byte R, out byte G, out byte B, out byte A)

Parameters

R byte
G byte
B byte
A byte

No documentation is available.

Equals overloads

Equals(SceneColor)

public bool Equals(SceneColor other)
Parameters
other SceneColor
Returns

bool

No documentation is available.

Equals(object)

public override bool Equals(object obj)
Parameters
obj object
Returns

bool

No documentation is available.

FromHsl(double, double, double, double)

SceneColor.cs

Creates a color from its hue, saturation and lightness, as the CSS function hsl().

public static SceneColor FromHsl(double hue, double saturation, double lightness, double alpha = 1d)

Parameters

hue double
The hue, in degrees; it wraps around 360.
saturation double
The saturation, from 0 to 1.
lightness double
The lightness, from 0 to 1.
alpha double
The opacity, from 0 to 1.

Returns

SceneColor The color, its channels rounded to the nearest integer.

Exceptions

ArgumentOutOfRangeException
A value is not finite.

GetHashCode()

public override int GetHashCode()

Returns

int

No documentation is available.

Parse(string)

SceneColor.cs

Parses a CSS color: #rgb, #rgba, #rrggbb, #rrggbbaa, a CSS color name such as steelblue, or the functions rgb(), rgba(), hsl() and hsla(), with commas or spaces.

public static SceneColor Parse(string value)

Parameters

value string
The text to parse.

Returns

SceneColor The color.

Exceptions

FormatException
value is not a supported color.

ToHexRgb()

SceneColor.cs

Returns the color as #rrggbb, without its alpha channel.

public string ToHexRgb()

Returns

string The hexadecimal notation of the color.

ToString()

SceneColor.cs

Returns the color as #rrggbb, or #rrggbbaa when it is not opaque.

public override string ToString()

Returns

string The hexadecimal notation of the color.

TryParse(string?, SceneColor)

SceneColor.cs

Tries to parse a CSS color: #rgb, #rgba, #rrggbb, #rrggbbaa, a CSS color name, or rgb(), rgba(), hsl() and hsla().

public static bool TryParse(string? value, out SceneColor color)

Parameters

value string?
The text to parse.
color SceneColor
The color, when the method returns true.

Returns

bool true when value is a supported color.

WithOpacity(double)

SceneColor.cs

Returns a copy of the color with another opacity.

public SceneColor WithOpacity(double opacity)

Parameters

opacity double
The opacity, from 0 to 1.

Returns

SceneColor The color.

Operators

NameDescription
operator ==(SceneColor, SceneColor)
implicit operator SceneColor(string)Converts a text to a color with SceneColor.Parse.
operator !=(SceneColor, SceneColor)

operator ==(SceneColor, SceneColor)

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

Parameters

left SceneColor
right SceneColor

Returns

bool

No documentation is available.

implicit operator SceneColor(string)

SceneColor.cs

Converts a text to a color with SceneColor.Parse.

public static implicit operator SceneColor(string value)

Parameters

value string
The text to parse.

Returns

SceneColor

operator !=(SceneColor, SceneColor)

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

Parameters

left SceneColor
right SceneColor

Returns

bool

No documentation is available.