Show / Hide Table of Contents

Class RGBColor

Contains helper-methods and extension for the Color-type to work in the RGB color space.

Inheritance
object
RGBColor
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: RGB.NET.Core
Assembly: RGB.NET.Core.dll
Syntax
public static class RGBColor

Methods

| Edit this page View Source

AddA(in Color, int)

Adds the specified alpha value to this color.

Declaration
public static Color AddA(this in Color color, int a)
Parameters
Type Name Description
Color color

The color to modify.

int a

The alpha value to add.

Returns
Type Description
Color

The new color after the modification.

| Edit this page View Source

AddA(in Color, float)

Adds the specified alpha-percent value to this color.

Declaration
public static Color AddA(this in Color color, float a)
Parameters
Type Name Description
Color color

The color to modify.

float a

The alpha value to add.

Returns
Type Description
Color

The new color after the modification.

| Edit this page View Source

AddRGB(in Color, int, int, int)

Adds the specified RGB values to this color.

Declaration
public static Color AddRGB(this in Color color, int r = 0, int g = 0, int b = 0)
Parameters
Type Name Description
Color color

The color to modify.

int r

The red value to add.

int g

The green value to add.

int b

The blue value to add.

Returns
Type Description
Color

The new color after the modification.

| Edit this page View Source

AddRGB(in Color, float, float, float)

Adds the specified RGB-percent values to this color.

Declaration
public static Color AddRGB(this in Color color, float r = 0, float g = 0, float b = 0)
Parameters
Type Name Description
Color color

The color to modify.

float r

The red value to add.

float g

The green value to add.

float b

The blue value to add.

Returns
Type Description
Color

The new color after the modification.

| Edit this page View Source

AsARGBHexString(in Color, bool)

Gets the current color as a ARGB-HEX-string.

Declaration
public static string AsARGBHexString(this in Color color, bool leadingHash = true)
Parameters
Type Name Description
Color color
bool leadingHash
Returns
Type Description
string

The ARGB-HEX-string.

| Edit this page View Source

AsRGBHexString(in Color, bool)

Gets the current color as a RGB-HEX-string.

Declaration
public static string AsRGBHexString(this in Color color, bool leadingHash = true)
Parameters
Type Name Description
Color color
bool leadingHash
Returns
Type Description
string

The RGB-HEX-string.

| Edit this page View Source

DivideA(in Color, float)

Divides the specified alpha value to this color.

Declaration
public static Color DivideA(this in Color color, float a)
Parameters
Type Name Description
Color color

The color to modify.

float a

The alpha value to divide.

Returns
Type Description
Color

The new color after the modification.

| Edit this page View Source

DivideRGB(in Color, float, float, float)

Divides the specified RGB values to this color.

Declaration
public static Color DivideRGB(this in Color color, float r = 1, float g = 1, float b = 1)
Parameters
Type Name Description
Color color

The color to modify.

float r

The red value to divide.

float g

The green value to divide.

float b

The blue value to divide.

Returns
Type Description
Color

The new color after the modification.

| Edit this page View Source

FromHexString(string)

Creates a new instance of the Color struct using a HEX-string.

Declaration
public static Color FromHexString(string hexString)
Parameters
Type Name Description
string hexString

The HEX-representation of the color.

Returns
Type Description
Color

The color created from the HEX-string.

| Edit this page View Source

GetA(in Color)

Gets the A component value of this Color as byte in the range [0..255].

Declaration
public static byte GetA(this in Color color)
Parameters
Type Name Description
Color color

The color to get the value from.

Returns
Type Description
byte

The A component value of the color.

| Edit this page View Source

GetB(in Color)

Gets the B component value of this Color as byte in the range [0..255].

Declaration
public static byte GetB(this in Color color)
Parameters
Type Name Description
Color color

The color to get the value from.

Returns
Type Description
byte

The B component value of the color.

| Edit this page View Source

GetG(in Color)

Gets the G component value of this Color as byte in the range [0..255].

Declaration
public static byte GetG(this in Color color)
Parameters
Type Name Description
Color color

The color to get the value from.

Returns
Type Description
byte

The G component value of the color.

| Edit this page View Source

GetR(in Color)

Gets the R component value of this Color as byte in the range [0..255].

Declaration
public static byte GetR(this in Color color)
Parameters
Type Name Description
Color color

The color to get the value from.

Returns
Type Description
byte

The R component value of the color.

| Edit this page View Source

GetRGB(in Color)

Gets the A, R, G and B component value of this Color as percentage in the range [0..1].

Declaration
public static (float a, float r, float g, float b) GetRGB(this in Color color)
Parameters
Type Name Description
Color color

The color to get the value from.

Returns
Type Description
(float a, float r, float g, float b)

A tuple containing the A, R, G and B component value of the color.

| Edit this page View Source

GetRGBBytes(in Color)

Gets the A, R, G and B component value of this Color as byte in the range [0..255].

Declaration
public static (byte a, byte r, byte g, byte b) GetRGBBytes(this in Color color)
Parameters
Type Name Description
Color color

The color to get the value from.

Returns
Type Description
(byte a, byte r, byte g, byte b)

A tuple containing the A, R, G and B component value of the color.

| Edit this page View Source

MultiplyA(in Color, float)

Multiplies the specified alpha value to this color.

Declaration
public static Color MultiplyA(this in Color color, float a)
Parameters
Type Name Description
Color color

The color to modify.

float a

The alpha value to multiply.

Returns
Type Description
Color

The new color after the modification.

| Edit this page View Source

MultiplyRGB(in Color, float, float, float)

Multiplies the specified RGB values to this color.

Declaration
public static Color MultiplyRGB(this in Color color, float r = 1, float g = 1, float b = 1)
Parameters
Type Name Description
Color color

The color to modify.

float r

The red value to multiply.

float g

The green value to multiply.

float b

The blue value to multiply.

Returns
Type Description
Color

The new color after the modification.

| Edit this page View Source

SetA(in Color, int)

Sets the specified alpha value of this color.

Declaration
public static Color SetA(this in Color color, int a)
Parameters
Type Name Description
Color color

The color to modify.

int a

The alpha value to set.

Returns
Type Description
Color

The new color after the modification.

| Edit this page View Source

SetA(in Color, float)

Sets the specified alpha value of this color.

Declaration
public static Color SetA(this in Color color, float a)
Parameters
Type Name Description
Color color

The color to modify.

float a

The alpha value to set.

Returns
Type Description
Color

The new color after the modification.

| Edit this page View Source

SetRGB(in Color, byte?, byte?, byte?)

Sets the specified RGB value of this color.

Declaration
public static Color SetRGB(this in Color color, byte? r = null, byte? g = null, byte? b = null)
Parameters
Type Name Description
Color color

The color to modify.

byte? r

The red value to set.

byte? g

The green value to set.

byte? b

The blue value to set.

Returns
Type Description
Color

The new color after the modification.

| Edit this page View Source

SetRGB(in Color, int?, int?, int?)

Sets the specified RGB value of this color.

Declaration
public static Color SetRGB(this in Color color, int? r = null, int? g = null, int? b = null)
Parameters
Type Name Description
Color color

The color to modify.

int? r

The red value to set.

int? g

The green value to set.

int? b

The blue value to set.

Returns
Type Description
Color

The new color after the modification.

| Edit this page View Source

SetRGB(in Color, float?, float?, float?)

Sets the specified RGB value of this color.

Declaration
public static Color SetRGB(this in Color color, float? r = null, float? g = null, float? b = null)
Parameters
Type Name Description
Color color

The color to modify.

float? r

The red value to set.

float? g

The green value to set.

float? b

The blue value to set.

Returns
Type Description
Color

The new color after the modification.

| Edit this page View Source

SubtractA(in Color, int)

Subtracts the specified alpha value to this color.

Declaration
public static Color SubtractA(this in Color color, int a)
Parameters
Type Name Description
Color color

The color to modify.

int a

The alpha value to subtract.

Returns
Type Description
Color

The new color after the modification.

| Edit this page View Source

SubtractA(in Color, float)

Subtracts the specified alpha-percent value to this color.

Declaration
public static Color SubtractA(this in Color color, float aPercent)
Parameters
Type Name Description
Color color

The color to modify.

float aPercent

The alpha value to subtract.

Returns
Type Description
Color

The new color after the modification.

| Edit this page View Source

SubtractRGB(in Color, int, int, int)

Subtracts the specified RGB values to this color.

Declaration
public static Color SubtractRGB(this in Color color, int r = 0, int g = 0, int b = 0)
Parameters
Type Name Description
Color color

The color to modify.

int r

The red value to subtract.

int g

The green value to subtract.

int b

The blue value to subtract.

Returns
Type Description
Color

The new color after the modification.

| Edit this page View Source

SubtractRGB(in Color, float, float, float)

Subtracts the specified RGB values to this color.

Declaration
public static Color SubtractRGB(this in Color color, float r = 0, float g = 0, float b = 0)
Parameters
Type Name Description
Color color

The color to modify.

float r

The red value to subtract.

float g

The green value to subtract.

float b

The blue value to subtract.

Returns
Type Description
Color

The new color after the modification.

  • Edit this page
  • View Source
In this article
Back to top Generated by DocFX