VectSharp 2.5.0
A light library for C# vector graphics
Loading...
Searching...
No Matches
VectSharp.Colour Struct Reference

Represents an RGB colour. More...

Inheritance diagram for VectSharp.Colour:

Public Member Functions

override bool Equals (object obj)
 
bool Equals (Colour col)
 
override int GetHashCode ()
 
string ToCSSString (bool includeAlpha)
 Convert the Colour object into a hex string that is constituted by a "#" followed by two-digit hexadecimal representations of the red, green and blue components of the colour (in the range 0x00 - 0xFF). Optionally also includes opacity (alpha channel) data. More...
 
Colour WithAlpha (double alpha)
 Create a new Colour with the same RGB components as the current Colour, but with the specified alpha . More...
 
Colour WithAlpha (byte alpha)
 Create a new Colour with the same RGB components as the current Colour, but with the specified alpha . More...
 
double double double Z ToXYZ ()
 
double double double b ToLab ()
 
double double double L ToHSL ()
 

Static Public Member Functions

static Colour FromRgb (double r, double g, double b)
 Create a new colour from RGB (red, green and blue) values. More...
 
static Colour FromRgb (byte r, byte g, byte b)
 Create a new colour from RGB (red, green and blue) values. More...
 
static Colour FromRgb (int r, int g, int b)
 Create a new colour from RGB (red, green and blue) values. More...
 
static Colour FromRgba (double r, double g, double b, double a)
 Create a new colour from RGBA (red, green, blue and alpha) values. More...
 
static Colour FromRgba (byte r, byte g, byte b, byte a)
 Create a new colour from RGBA (red, green, blue and alpha) values. More...
 
static Colour FromRgba (byte r, byte g, byte b, double a)
 Create a new colour from RGBA (red, green, blue and alpha) values. More...
 
static Colour FromRgba (int r, int g, int b, int a)
 Create a new colour from RGBA (red, green, blue and alpha) values. More...
 
static Colour FromRgba (int r, int g, int b, double a)
 Create a new colour from RGBA (red, green, blue and alpha) values. More...
 
static Colour FromRgba ((int r, int g, int b, double a) colour)
 Create a new colour from RGBA (red, green, blue and alpha) values. More...
 
static bool operator== (Colour col1, Colour col2)
 
static bool operator!= (Colour col1, Colour col2)
 
static ? Colour FromCSSString (string cssString)
 Convert a CSS colour string into a Colour object. More...
 
static Colour WithAlpha (Colour original, double alpha)
 Create a new Colour with the same RGB components as the original Colour, but with the specified alpha . More...
 
static Colour WithAlpha (Colour original, byte alpha)
 Create a new Colour with the same RGB components as the original Colour, but with the specified alpha . More...
 
static Colour FromXYZ (double x, double y, double z)
 Creates a Colour from CIE XYZ coordinates. More...
 
static Colour FromLab (double L, double a, double b)
 Creates a Colour from CIE Lab coordinates (under Illuminant D65). More...
 
static Colour FromHSL (double h, double s, double l)
 Creates a Colour from HSL coordinates. More...
 

Public Attributes

double R
 Red component of the colour. Range: [0, 1]. More...
 
double G
 Green component of the colour. Range: [0, 1]. More...
 
double B
 Blue component of the colour. Range: [0, 1]. More...
 
double A
 Alpha component of the colour. Range: [0, 1]. More...
 
double X
 Converts a Colour to the CIE XYZ colour space. More...
 
double double Y
 
double L
 Converts a Colour to the CIE Lab colour space (under Illuminant D65). More...
 
double double a
 
double H
 Converts a Colour to the HSL colour space. More...
 
double double S
 

Detailed Description

Represents an RGB colour.

Definition at line 25 of file Colour.cs.

Member Function Documentation

◆ Equals() [1/2]

bool VectSharp.Colour.Equals ( Colour  col)

Definition at line 179 of file Colour.cs.

◆ Equals() [2/2]

override bool VectSharp.Colour.Equals ( object  obj)

Definition at line 166 of file Colour.cs.

◆ FromCSSString()

static ? Colour VectSharp.Colour.FromCSSString ( string  cssString)
static

Convert a CSS colour string into a Colour object.

Parameters
cssStringThe CSS colour string. In addition to 148 standard colour names (case-insensitive), #RGB, #RGBA, #RRGGBB and #RRGGBBAA hex strings and rgb(r, g, b) and rgba(r, g, b, a) functional colour notations are supported.
Returns

Definition at line 225 of file Colour.cs.

◆ FromHSL()

static Colour VectSharp.Colour.FromHSL ( double  h,
double  s,
double  l 
)
static

Creates a Colour from HSL coordinates.

Parameters
hThe H component. Should be in range [0, 1].
sThe S component. Should be in range [0, 1].
lThe L component. Should be in range [0, 1].
Returns
A Colour created from the specified components.

Definition at line 582 of file Colour.cs.

◆ FromLab()

static Colour VectSharp.Colour.FromLab ( double  L,
double  a,
double  b 
)
static

Creates a Colour from CIE Lab coordinates (under Illuminant D65).

Parameters
LThe L* component.
aThe a* component.
bThe b* component.
Returns
An sRGB Colour created from the specified components.

Definition at line 504 of file Colour.cs.

◆ FromRgb() [1/3]

static Colour VectSharp.Colour.FromRgb ( byte  r,
byte  g,
byte  b 
)
static

Create a new colour from RGB (red, green and blue) values.

Parameters
rThe red component of the colour. Range: [0, 255].
gThe green component of the colour. Range: [0, 255].
bThe blue component of the colour. Range: [0, 255].
Returns
A Colour struct with the specified components and an alpha component of 1.

Definition at line 74 of file Colour.cs.

◆ FromRgb() [2/3]

static Colour VectSharp.Colour.FromRgb ( double  r,
double  g,
double  b 
)
static

Create a new colour from RGB (red, green and blue) values.

Parameters
rThe red component of the colour. Range: [0, 1].
gThe green component of the colour. Range: [0, 1].
bThe blue component of the colour. Range: [0, 1].
Returns
A Colour struct with the specified components and an alpha component of 1.

Definition at line 62 of file Colour.cs.

◆ FromRgb() [3/3]

static Colour VectSharp.Colour.FromRgb ( int  r,
int  g,
int  b 
)
static

Create a new colour from RGB (red, green and blue) values.

Parameters
rThe red component of the colour. Range: [0, 255].
gThe green component of the colour. Range: [0, 255].
bThe blue component of the colour. Range: [0, 255].
Returns
A Colour struct with the specified components and an alpha component of 1.

Definition at line 86 of file Colour.cs.

◆ FromRgba() [1/6]

static Colour VectSharp.Colour.FromRgba ( (int r, int g, int b, double a)  colour)
static

Create a new colour from RGBA (red, green, blue and alpha) values.

Parameters
colourA ValueTuple<Int32, Int32, Int32, Double> containing component information for the colour. For r, g, and b, range: [0, 255]; for a, range: [0, 1].
Returns
A Colour struct with the specified components.

Definition at line 160 of file Colour.cs.

◆ FromRgba() [2/6]

static Colour VectSharp.Colour.FromRgba ( byte  r,
byte  g,
byte  b,
byte  a 
)
static

Create a new colour from RGBA (red, green, blue and alpha) values.

Parameters
rThe red component of the colour. Range: [0, 255].
gThe green component of the colour. Range: [0, 255].
bThe blue component of the colour. Range: [0, 255].
aThe alpha component of the colour. Range: [0, 255].
Returns
A ColourColour struct with the specified components.

Definition at line 112 of file Colour.cs.

◆ FromRgba() [3/6]

static Colour VectSharp.Colour.FromRgba ( byte  r,
byte  g,
byte  b,
double  a 
)
static

Create a new colour from RGBA (red, green, blue and alpha) values.

Parameters
rThe red component of the colour. Range: [0, 255].
gThe green component of the colour. Range: [0, 255].
bThe blue component of the colour. Range: [0, 255].
aThe alpha component of the colour. Range: [0, 1].
Returns
A Colour struct with the specified components.

Definition at line 125 of file Colour.cs.

◆ FromRgba() [4/6]

static Colour VectSharp.Colour.FromRgba ( double  r,
double  g,
double  b,
double  a 
)
static

Create a new colour from RGBA (red, green, blue and alpha) values.

Parameters
rThe red component of the colour. Range: [0, 1].
gThe green component of the colour. Range: [0, 1].
bThe blue component of the colour. Range: [0, 1].
aThe alpha component of the colour. Range: [0, 1].
Returns
A Colour struct with the specified components.

Definition at line 99 of file Colour.cs.

◆ FromRgba() [5/6]

static Colour VectSharp.Colour.FromRgba ( int  r,
int  g,
int  b,
double  a 
)
static

Create a new colour from RGBA (red, green, blue and alpha) values.

Parameters
rThe red component of the colour. Range: [0, 255].
gThe green component of the colour. Range: [0, 255].
bThe blue component of the colour. Range: [0, 255].
aThe alpha component of the colour. Range: [0, 1].
Returns
A Colour struct with the specified components.

Definition at line 150 of file Colour.cs.

◆ FromRgba() [6/6]

static Colour VectSharp.Colour.FromRgba ( int  r,
int  g,
int  b,
int  a 
)
static

Create a new colour from RGBA (red, green, blue and alpha) values.

Parameters
rThe red component of the colour. Range: [0, 255].
gThe green component of the colour. Range: [0, 255].
bThe blue component of the colour. Range: [0, 255].
aThe alpha component of the colour. Range: [0, 255].
Returns
A Colour struct with the specified components.

Definition at line 137 of file Colour.cs.

◆ FromXYZ()

static Colour VectSharp.Colour.FromXYZ ( double  x,
double  y,
double  z 
)
static

Creates a Colour from CIE XYZ coordinates.

Parameters
xThe X coordinate.
yThe Y coordinate.
zThe Z coordinate.
Returns
An sRGB Colour created from the specified components.

Definition at line 422 of file Colour.cs.

◆ GetHashCode()

override int VectSharp.Colour.GetHashCode ( )

Definition at line 197 of file Colour.cs.

◆ operator!=()

static bool VectSharp.Colour.operator!= ( Colour  col1,
Colour  col2 
)
static

Definition at line 191 of file Colour.cs.

◆ operator==()

static bool VectSharp.Colour.operator== ( Colour  col1,
Colour  col2 
)
static

Definition at line 185 of file Colour.cs.

◆ ToCSSString()

string VectSharp.Colour.ToCSSString ( bool  includeAlpha)

Convert the Colour object into a hex string that is constituted by a "#" followed by two-digit hexadecimal representations of the red, green and blue components of the colour (in the range 0x00 - 0xFF). Optionally also includes opacity (alpha channel) data.

Parameters
includeAlphaWhether two additional hex digits representing the colour's opacity (alpha channel) should be included in the string.
Returns
A hex colour string.

Definition at line 208 of file Colour.cs.

◆ ToHSL()

double double double L VectSharp.Colour.ToHSL ( )

Definition at line 535 of file Colour.cs.

◆ ToLab()

double double double b VectSharp.Colour.ToLab ( )

Definition at line 466 of file Colour.cs.

◆ ToXYZ()

double double double Z VectSharp.Colour.ToXYZ ( )

Definition at line 377 of file Colour.cs.

◆ WithAlpha() [1/4]

Colour VectSharp.Colour.WithAlpha ( byte  alpha)

Create a new Colour with the same RGB components as the current Colour, but with the specified alpha .

Parameters
alphaThe alpha component of the new Colour.
Returns
A Colour struct with the same RGB components as the current Colour and the specified alpha .

Definition at line 368 of file Colour.cs.

◆ WithAlpha() [2/4]

static Colour VectSharp.Colour.WithAlpha ( Colour  original,
byte  alpha 
)
static

Create a new Colour with the same RGB components as the original Colour, but with the specified alpha .

Parameters
originalThe original Colour from which the RGB components will be taken.
alphaThe alpha component of the new Colour.
Returns
A Colour struct with the same RGB components as the original Colour and the specified alpha .

Definition at line 348 of file Colour.cs.

◆ WithAlpha() [3/4]

static Colour VectSharp.Colour.WithAlpha ( Colour  original,
double  alpha 
)
static

Create a new Colour with the same RGB components as the original Colour, but with the specified alpha .

Parameters
originalThe original Colour from which the RGB components will be taken.
alphaThe alpha component of the new Colour.
Returns
A Colour struct with the same RGB components as the original Colour and the specified alpha .

Definition at line 337 of file Colour.cs.

◆ WithAlpha() [4/4]

Colour VectSharp.Colour.WithAlpha ( double  alpha)

Create a new Colour with the same RGB components as the current Colour, but with the specified alpha .

Parameters
alphaThe alpha component of the new Colour.
Returns
A Colour struct with the same RGB components as the current Colour and the specified alpha .

Definition at line 358 of file Colour.cs.

Member Data Documentation

◆ A

double VectSharp.Colour.A

Alpha component of the colour. Range: [0, 1].

Definition at line 45 of file Colour.cs.

◆ a

double double VectSharp.Colour.a

Definition at line 466 of file Colour.cs.

◆ B

double VectSharp.Colour.B

Blue component of the colour. Range: [0, 1].

Definition at line 40 of file Colour.cs.

◆ G

double VectSharp.Colour.G

Green component of the colour. Range: [0, 1].

Definition at line 35 of file Colour.cs.

◆ H

double VectSharp.Colour.H

Converts a Colour to the HSL colour space.

Returns
A ValueType containing the H, S and L components of the Colour. Each component has range [0, 1].

Definition at line 535 of file Colour.cs.

◆ L

double VectSharp.Colour.L

Converts a Colour to the CIE Lab colour space (under Illuminant D65).

Returns
A ValueType containing the L*, a* and b* components of the Colour.

Definition at line 466 of file Colour.cs.

◆ R

double VectSharp.Colour.R

Red component of the colour. Range: [0, 1].

Definition at line 30 of file Colour.cs.

◆ S

double double VectSharp.Colour.S

Definition at line 535 of file Colour.cs.

◆ X

double VectSharp.Colour.X

Converts a Colour to the CIE XYZ colour space.

Returns
A ValueTuple containing the X, Y and Z components of the Colour.

Definition at line 377 of file Colour.cs.

◆ Y

double double VectSharp.Colour.Y

Definition at line 377 of file Colour.cs.


The documentation for this struct was generated from the following files: