Struct Color
Represents an ARGB (alpha, red, green, blue) color.
Implements
Inherited Members
Namespace: RGB.NET.Core
Assembly: RGB.NET.Core.dll
Syntax
public readonly struct Color : IEquatable<Color>
Constructors
| Edit this page View SourceColor(in Color)
Declaration
public Color(in Color color)
Parameters
Type | Name | Description |
---|---|---|
Color | color | The Color the values are copied from. |
Color(byte, byte, byte)
Initializes a new instance of the Color struct using RGB-Values. Alpha defaults to 255.
Declaration
public Color(byte r, byte g, byte b)
Parameters
Type | Name | Description |
---|---|---|
byte | r | The red component value of this Color. |
byte | g | The green component value of this Color. |
byte | b | The blue component value of this Color. |
Color(byte, byte, byte, byte)
Initializes a new instance of the Color struct using ARGB values.
Declaration
public Color(byte a, byte r, byte g, byte b)
Parameters
Type | Name | Description |
---|---|---|
byte | a | The alpha component value of this Color. |
byte | r | The red component value of this Color. |
byte | g | The green component value of this Color. |
byte | b | The blue component value of this Color. |
Color(byte, float, float, float)
Initializes a new instance of the Color struct using ARGB-percent values.
Declaration
public Color(byte a, float r, float g, float b)
Parameters
Type | Name | Description |
---|---|---|
byte | a | The alpha component value of this Color. |
float | r | The red component value of this Color. |
float | g | The green component value of this Color. |
float | b | The blue component value of this Color. |
Color(int, int, int)
Initializes a new instance of the Color struct using RGB-Values. Alpha defaults to 255.
Declaration
public Color(int r, int g, int b)
Parameters
Type | Name | Description |
---|---|---|
int | r | The red component value of this Color. |
int | g | The green component value of this Color. |
int | b | The blue component value of this Color. |
Color(int, int, int, int)
Initializes a new instance of the Color struct using ARGB values.
Declaration
public Color(int a, int r, int g, int b)
Parameters
Type | Name | Description |
---|---|---|
int | a | The alpha component value of this Color. |
int | r | The red component value of this Color. |
int | g | The green component value of this Color. |
int | b | The blue component value of this Color. |
Color(int, float, float, float)
Initializes a new instance of the Color struct using ARGB-percent values.
Declaration
public Color(int a, float r, float g, float b)
Parameters
Type | Name | Description |
---|---|---|
int | a | The alpha component value of this Color. |
float | r | The red component value of this Color. |
float | g | The green component value of this Color. |
float | b | The blue component value of this Color. |
Color(float, byte, byte, byte)
Initializes a new instance of the Color struct using ARGB-percent values.
Declaration
public Color(float a, byte r, byte g, byte b)
Parameters
Type | Name | Description |
---|---|---|
float | a | The alpha component value of this Color. |
byte | r | The red component value of this Color. |
byte | g | The green component value of this Color. |
byte | b | The blue component value of this Color. |
Color(float, int, int, int)
Initializes a new instance of the Color struct using ARGB-percent values.
Declaration
public Color(float a, int r, int g, int b)
Parameters
Type | Name | Description |
---|---|---|
float | a | The alpha component value of this Color. |
int | r | The red component value of this Color. |
int | g | The green component value of this Color. |
int | b | The blue component value of this Color. |
Color(float, float, float)
Initializes a new instance of the Color struct using RGB-percent values. Alpha defaults to 1.0.
Declaration
public Color(float r, float g, float b)
Parameters
Type | Name | Description |
---|---|---|
float | r | The red component value of this Color. |
float | g | The green component value of this Color. |
float | b | The blue component value of this Color. |
Color(float, float, float, float)
Initializes a new instance of the Color struct using ARGB-percent values.
Declaration
public Color(float a, float r, float g, float b)
Parameters
Type | Name | Description |
---|---|---|
float | a | The alpha component value of this Color. |
float | r | The red component value of this Color. |
float | g | The green component value of this Color. |
float | b | The blue component value of this Color. |
Fields
| Edit this page View SourceA
Gets the alpha component value of this Color as percentage in the range [0..1].
Declaration
public readonly float A
Field Value
Type | Description |
---|---|
float |
B
Gets the blue component value of this Color as percentage in the range [0..1].
Declaration
public readonly float B
Field Value
Type | Description |
---|---|
float |
G
Gets the green component value of this Color as percentage in the range [0..1].
Declaration
public readonly float G
Field Value
Type | Description |
---|---|
float |
R
Gets the red component value of this Color as percentage in the range [0..1].
Declaration
public readonly float R
Field Value
Type | Description |
---|---|
float |
Properties
| Edit this page View SourceBehavior
Gets or sets the IColorBehavior used to perform operations on colors.
Declaration
public static IColorBehavior Behavior { get; set; }
Property Value
Type | Description |
---|---|
IColorBehavior |
Transparent
Gets an transparent color [A: 0, R: 0, G: 0, B: 0]
Declaration
public static ref readonly Color Transparent { get; }
Property Value
Type | Description |
---|---|
Color |
Methods
| Edit this page View SourceBlend(in Color)
Declaration
public Color Blend(in Color color)
Parameters
Type | Name | Description |
---|---|---|
Color | color | The Color to blend. |
Returns
Type | Description |
---|---|
Color |
Equals(Color)
Declaration
public bool Equals(Color other)
Parameters
Type | Name | Description |
---|---|---|
Color | other | The color to test. |
Returns
Type | Description |
---|---|
bool |
|
Equals(object?)
Tests whether the specified object is a Color and is equivalent to this Color, as defined by the current Behavior.
Declaration
public override bool Equals(object? obj)
Parameters
Type | Name | Description |
---|---|---|
object | obj | The object to test. |
Returns
Type | Description |
---|---|
bool |
|
Overrides
| Edit this page View SourceGetHashCode()
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
int | An integer value that specifies the hash code for this Color. |
Overrides
| Edit this page View SourceToString()
Gets a human-readable string, as defined by the current Behavior.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
string | A string that contains the individual byte values of this Color. Default format: "[A: 255, R: 255, G: 0, B: 0]". |
Overrides
Operators
| Edit this page View Sourceoperator +(in Color, in Color)
Blends the provided colors as if Blend(in Color) would've been called on color1
.
Declaration
public static Color operator +(in Color color1, in Color color2)
Parameters
Type | Name | Description |
---|---|---|
Color | color1 | The base color. |
Color | color2 | The color to blend. |
Returns
Type | Description |
---|---|
Color | The blended color. |
operator ==(in Color, in Color)
Returns a value that indicates whether two specified Color are equal.
Declaration
public static bool operator ==(in Color color1, in Color color2)
Parameters
Type | Name | Description |
---|---|---|
Color | color1 | The first Color to compare. |
Color | color2 | The second Color to compare. |
Returns
Type | Description |
---|---|
bool |
|
implicit operator Color((byte a, byte r, byte g, byte b))
Converts a ValueTuple of ARGB-components to a Color.
Declaration
public static implicit operator Color((byte a, byte r, byte g, byte b) components)
Parameters
Type | Name | Description |
---|---|---|
(byte a, byte r, byte g, byte b) | components | The ValueTuple containing the components. |
Returns
Type | Description |
---|---|
Color | The color. |
implicit operator Color((byte r, byte g, byte b))
Converts a ValueTuple of ARGB-components to a Color.
Declaration
public static implicit operator Color((byte r, byte g, byte b) components)
Parameters
Type | Name | Description |
---|---|---|
(byte r, byte g, byte b) | components | The ValueTuple containing the components. |
Returns
Type | Description |
---|---|
Color | The color. |
implicit operator Color((int a, int r, int g, int b))
Converts a ValueTuple of ARGB-components to a Color.
Declaration
public static implicit operator Color((int a, int r, int g, int b) components)
Parameters
Type | Name | Description |
---|---|---|
(int a, int r, int g, int b) | components | The ValueTuple containing the components. |
Returns
Type | Description |
---|---|
Color | The color. |
implicit operator Color((int r, int g, int b))
Converts a ValueTuple of ARGB-components to a Color.
Declaration
public static implicit operator Color((int r, int g, int b) components)
Parameters
Type | Name | Description |
---|---|---|
(int r, int g, int b) | components | The ValueTuple containing the components. |
Returns
Type | Description |
---|---|
Color | The color. |
implicit operator Color((float a, float r, float g, float b))
Converts a ValueTuple of ARGB-components to a Color.
Declaration
public static implicit operator Color((float a, float r, float g, float b) components)
Parameters
Type | Name | Description |
---|---|---|
(float a, float r, float g, float b) | components | The ValueTuple containing the components. |
Returns
Type | Description |
---|---|
Color | The color. |
implicit operator Color((float r, float g, float b))
Converts a ValueTuple of ARGB-components to a Color.
Declaration
public static implicit operator Color((float r, float g, float b) components)
Parameters
Type | Name | Description |
---|---|---|
(float r, float g, float b) | components | The ValueTuple containing the components. |
Returns
Type | Description |
---|---|
Color | The color. |
operator !=(in Color, in Color)
Returns a value that indicates whether two specified Color are equal.
Declaration
public static bool operator !=(in Color color1, in Color color2)
Parameters
Type | Name | Description |
---|---|---|
Color | color1 | The first Color to compare. |
Color | color2 | The second Color to compare. |
Returns
Type | Description |
---|---|
bool |
|