Chunks
Moddable voxel sandbox for room-scale VR.
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | List of all members
Chunks.Graphics.Color Struct Reference

Represents an RGBA color as four floats between 0.0 and 1.0. More...

Inheritance diagram for Chunks.Graphics.Color:

Public Member Functions

 Color (float r, float g, float b, float a=1f)
 Constructs a color from the given red, green, blue and (optionally) alpha components as floats between 0.0 and 1.0. More...
 
 Color (int r, int g, int b, int a=255)
 Constructs a color from the given red, green, blue and (optionally) alpha components as integers between 0 and 255. More...
 
Color ScaleRgb (float scale)
 
int ToRgb ()
 Converts the color to an integer, with the R, G, and B components stored as the first, second, and third bytes respectively in order of significance. More...
 
int ToRgba ()
 Converts the color to an integer, with the R, G, B, and A components stored as the first, second, third, and fourth bytes respectively in order of significance. More...
 
override int GetHashCode ()
 Returns the hash code for this color. More...
 
bool Equals (Color other)
 Tests for equality with another color. More...
 
override bool Equals (object obj)
 Indicates whether this instance and a specified object are equal. More...
 
override string ToString ()
 Returns a string representation of this color. More...
 

Static Public Member Functions

static Color Parse (string str)
 Parses a color from a string with the format #RRGGBB[AA] More...
 
static bool TryParse (string str, out Color color)
 Attempts to parse a color from a string with the format #RRGGBB[AA], returning true if the parse was successful. More...
 
static Color FromRgb (int rgb)
 Converts an integer representation of an RGB color to a Color, with the least significant byte storing the red component. More...
 
static Color FromRgba (int rgba)
 Converts an integer representation of an RGBA color to a Color, with the least significant byte storing the red component. More...
 
static Color Lerp (Color a, Color b, float t)
 Linearly interpolates between two colors. More...
 
static Color operator+ (Color a, Color b)
 Adds two colors together. More...
 
static Color operator- (Color a, Color b)
 Subtracts a color from another. More...
 
static Color operator* (Color a, Color b)
 Multiplies two colors together. More...
 
static Color operator* (Color clr, float mul)
 Multiplies a color by a scalar. More...
 
static Color operator* (float mul, Color clr)
 Multiplies a color by a scalar. More...
 
static Color operator/ (Color clr, float div)
 Divides a color by a scalar. More...
 
static bool operator== (Color a, Color b)
 Tests for equality with another color. More...
 
static bool operator!= (Color a, Color b)
 Tests for inequality with another color. More...
 

Public Attributes

float R
 Red component. More...
 
float G
 Green component. More...
 
float B
 Blue component. More...
 
float A
 Alpha component. More...
 

Static Public Attributes

static readonly Color Black = new Color(0, 0, 0)
 Solid black (#000000). More...
 
static readonly Color White = new Color(255, 255, 255)
 Solid white (#ffffff). More...
 

Detailed Description

Represents an RGBA color as four floats between 0.0 and 1.0.

Constructor & Destructor Documentation

Chunks.Graphics.Color.Color ( float  r,
float  g,
float  b,
float  a = 1f 
)

Constructs a color from the given red, green, blue and (optionally) alpha components as floats between 0.0 and 1.0.

Parameters
rRed component
gGreem component
bBlue component
aAlpha component
Chunks.Graphics.Color.Color ( int  r,
int  g,
int  b,
int  a = 255 
)

Constructs a color from the given red, green, blue and (optionally) alpha components as integers between 0 and 255.

Parameters
rRed component
gGreem component
bBlue component
aAlpha component

Member Function Documentation

bool Chunks.Graphics.Color.Equals ( Color  other)

Tests for equality with another color.

Parameters
otherColor to test for equality with
override bool Chunks.Graphics.Color.Equals ( object  obj)

Indicates whether this instance and a specified object are equal.

Parameters
objAnother object to compare to.
static Color Chunks.Graphics.Color.FromRgb ( int  rgb)
static

Converts an integer representation of an RGB color to a Color, with the least significant byte storing the red component.

Parameters
rgbInteger representation of an RGB color
static Color Chunks.Graphics.Color.FromRgba ( int  rgba)
static

Converts an integer representation of an RGBA color to a Color, with the least significant byte storing the red component.

Parameters
rgbaInteger representation of an RGBA color
override int Chunks.Graphics.Color.GetHashCode ( )

Returns the hash code for this color.

static Color Chunks.Graphics.Color.Lerp ( Color  a,
Color  b,
float  t 
)
static

Linearly interpolates between two colors.

Parameters
aStarting color
bEnding color
tInterpolation parameter between 0.0 and 1.0
static bool Chunks.Graphics.Color.operator!= ( Color  a,
Color  b 
)
static

Tests for inequality with another color.

Parameters
aFirst color to test for inequality with
bSecond color to test for inequality with
static Color Chunks.Graphics.Color.operator* ( Color  a,
Color  b 
)
static

Multiplies two colors together.

Parameters
aFirst color to multiply
bSecond color to multiply
static Color Chunks.Graphics.Color.operator* ( Color  clr,
float  mul 
)
static

Multiplies a color by a scalar.

Parameters
clrColor to multiply
mulScalar value to multiply by
static Color Chunks.Graphics.Color.operator* ( float  mul,
Color  clr 
)
static

Multiplies a color by a scalar.

Parameters
clrColor to multiply
mulScalar value to multiply by
static Color Chunks.Graphics.Color.operator+ ( Color  a,
Color  b 
)
static

Adds two colors together.

Parameters
aFirst color to add
bSecond color to add
static Color Chunks.Graphics.Color.operator- ( Color  a,
Color  b 
)
static

Subtracts a color from another.

Parameters
aColor to be subtracted from
bColor to subtract
static Color Chunks.Graphics.Color.operator/ ( Color  clr,
float  div 
)
static

Divides a color by a scalar.

Parameters
clrColor to divide
divScalar value to divide by
static bool Chunks.Graphics.Color.operator== ( Color  a,
Color  b 
)
static

Tests for equality with another color.

Parameters
aFirst color to test for equality with
bSecond color to test for equality with
static Color Chunks.Graphics.Color.Parse ( string  str)
static

Parses a color from a string with the format #RRGGBB[AA]

Parameters
strString to parse
Color Chunks.Graphics.Color.ScaleRgb ( float  scale)
int Chunks.Graphics.Color.ToRgb ( )

Converts the color to an integer, with the R, G, and B components stored as the first, second, and third bytes respectively in order of significance.

int Chunks.Graphics.Color.ToRgba ( )

Converts the color to an integer, with the R, G, B, and A components stored as the first, second, third, and fourth bytes respectively in order of significance.

override string Chunks.Graphics.Color.ToString ( )

Returns a string representation of this color.

static bool Chunks.Graphics.Color.TryParse ( string  str,
out Color  color 
)
static

Attempts to parse a color from a string with the format #RRGGBB[AA], returning true if the parse was successful.

Parameters
strString to parse
colorIf true is returned, contains the parsed color

Member Data Documentation

float Chunks.Graphics.Color.A

Alpha component.

float Chunks.Graphics.Color.B

Blue component.

readonly Color Chunks.Graphics.Color.Black = new Color(0, 0, 0)
static

Solid black (#000000).

float Chunks.Graphics.Color.G

Green component.

float Chunks.Graphics.Color.R

Red component.

readonly Color Chunks.Graphics.Color.White = new Color(255, 255, 255)
static

Solid white (#ffffff).


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