Show / Hide Table of Contents

Struct Color

Represents an ARGB (alpha, red, green, blue) color.

Implements
IEquatable<Color>
Inherited Members
object.Equals(object, object)
object.GetType()
object.ReferenceEquals(object, object)
Namespace: RGB.NET.Core
Assembly: RGB.NET.Core.dll
Syntax
public readonly struct Color : IEquatable<Color>

Constructors

| Edit this page View Source

Color(in Color)

Initializes a new instance of the Color struct by cloning a existing Color.

Declaration
public Color(in Color color)
Parameters
Type Name Description
Color color

The Color the values are copied from.

| Edit this page View Source

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.

| Edit this page View Source

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.

| Edit this page View Source

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.

| Edit this page View Source

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.

| Edit this page View Source

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.

| Edit this page View Source

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.

| Edit this page View Source

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.

| Edit this page View Source

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.

| Edit this page View Source

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.

| Edit this page View Source

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 Source

A

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
| Edit this page View Source

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
| Edit this page View Source

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
| Edit this page View Source

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 Source

Behavior

Gets or sets the IColorBehavior used to perform operations on colors.

Declaration
public static IColorBehavior Behavior { get; set; }
Property Value
Type Description
IColorBehavior
| Edit this page View Source

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 Source

Blend(in Color)

Blends a Color over this color, as defined by the current Behavior.

Declaration
public Color Blend(in Color color)
Parameters
Type Name Description
Color color

The Color to blend.

Returns
Type Description
Color
| Edit this page View Source

Equals(Color)

Tests whether the specified Color is equivalent to this Color, as defined by the current Behavior.

Declaration
public bool Equals(Color other)
Parameters
Type Name Description
Color other

The color to test.

Returns
Type Description
bool

true if other is equivalent to this Color; otherwise, false.

| Edit this page View Source

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

true if obj is a Color equivalent to this Color; otherwise, false.

Overrides
ValueType.Equals(object)
| Edit this page View Source

GetHashCode()

Returns a hash code for this Color, as defined by the current Behavior.

Declaration
public override int GetHashCode()
Returns
Type Description
int

An integer value that specifies the hash code for this Color.

Overrides
ValueType.GetHashCode()
| Edit this page View Source

ToString()

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
ValueType.ToString()

Operators

| Edit this page View Source

operator +(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.

| Edit this page View Source

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

true if color1 and color2 are equal; otherwise, false.

| Edit this page View Source

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.

| Edit this page View Source

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.

| Edit this page View Source

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.

| Edit this page View Source

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.

| Edit this page View Source

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.

| Edit this page View Source

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.

| Edit this page View Source

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

true if color1 and color2 are not equal; otherwise, false.

Implements

IEquatable<T>

Extension Methods

ColorExtensions.DistanceTo(in Color, in Color)
HSVColor.AddHSV(in Color, float, float, float)
HSVColor.DivideHSV(in Color, float, float, float)
HSVColor.GetHSV(in Color)
HSVColor.GetHue(in Color)
HSVColor.GetSaturation(in Color)
HSVColor.GetValue(in Color)
HSVColor.MultiplyHSV(in Color, float, float, float)
HSVColor.SetHSV(in Color, float?, float?, float?)
HSVColor.SubtractHSV(in Color, float, float, float)
HclColor.AddHcl(in Color, float, float, float)
HclColor.DivideHcl(in Color, float, float, float)
HclColor.GetHcl(in Color)
HclColor.GetHclC(in Color)
HclColor.GetHclH(in Color)
HclColor.GetHclL(in Color)
HclColor.MultiplyHcl(in Color, float, float, float)
HclColor.SetHcl(in Color, float?, float?, float?)
HclColor.SubtractHcl(in Color, float, float, float)
LabColor.AddLab(in Color, float, float, float)
LabColor.DivideLab(in Color, float, float, float)
LabColor.GetLab(in Color)
LabColor.GetLabA(in Color)
LabColor.GetLabB(in Color)
LabColor.GetLabL(in Color)
LabColor.MultiplyLab(in Color, float, float, float)
LabColor.SetLab(in Color, float?, float?, float?)
LabColor.SubtractLab(in Color, float, float, float)
RGBColor.AddA(in Color, int)
RGBColor.AddA(in Color, float)
RGBColor.AddRGB(in Color, int, int, int)
RGBColor.AddRGB(in Color, float, float, float)
RGBColor.AsARGBHexString(in Color, bool)
RGBColor.AsRGBHexString(in Color, bool)
RGBColor.DivideA(in Color, float)
RGBColor.DivideRGB(in Color, float, float, float)
RGBColor.GetA(in Color)
RGBColor.GetB(in Color)
RGBColor.GetG(in Color)
RGBColor.GetR(in Color)
RGBColor.GetRGB(in Color)
RGBColor.GetRGBBytes(in Color)
RGBColor.MultiplyA(in Color, float)
RGBColor.MultiplyRGB(in Color, float, float, float)
RGBColor.SetA(in Color, int)
RGBColor.SetA(in Color, float)
RGBColor.SetRGB(in Color, byte?, byte?, byte?)
RGBColor.SetRGB(in Color, int?, int?, int?)
RGBColor.SetRGB(in Color, float?, float?, float?)
RGBColor.SubtractA(in Color, int)
RGBColor.SubtractA(in Color, float)
RGBColor.SubtractRGB(in Color, int, int, int)
RGBColor.SubtractRGB(in Color, float, float, float)
XYZColor.AddXYZ(in Color, float, float, float)
XYZColor.DivideXYZ(in Color, float, float, float)
XYZColor.GetX(in Color)
XYZColor.GetXYZ(in Color)
XYZColor.GetY(in Color)
XYZColor.GetZ(in Color)
XYZColor.MultiplyXYZ(in Color, float, float, float)
XYZColor.SetXYZ(in Color, float?, float?, float?)
XYZColor.SubtractXYZ(in Color, float, float, float)
  • Edit this page
  • View Source
In this article
Back to top Generated by DocFX