t
Loading...
Searching...
No Matches
t::Color Class Reference

The color class. More...

#include <Color.hpp>

Inheritance diagram for t::Color:
t::Vector3

Public Member Functions

 Color (double r, double g, double b)
 Creates a new color with the specified normalized red, green, and blue components.
 
 Color (int r, int g, int b, int colorDepth=8)
 Creates a new color with the specified red, green, and blue components and the specified color depth.
 
 Color (Vector3 vector3)
 Creates a new color with the specified Vector3 components as normalized RGB values.
 
Color & clamp ()
 Clamps the components of this color to the range \([0, 1]\).
 
double luminance () const
 Returns the luminance of this color.
 
 Vector3 (double _x, double _y, double _z)
 Creates a new 3D vector with the specified components.
 
- Public Member Functions inherited from t::Vector3
 Vector3 (double _x, double _y, double _z)
 Creates a new 3D vector with the specified components.
 
Vector3 clone () const
 Returns a copy of this 3D vector.
 
Vector3 & copy (const Vector3 &source)
 Copies the components of the specified 3D vector to this 3D vector.
 
Vector3 & set (double _x, double _y, double _z)
 Sets the components of this vector.
 
double length () const
 Returns the length of this 3D vector.
 
Vector3 unit () const
 Returns the unit vector of this 3D vector.
 
Vector3 & normalize ()
 Normalizes this 3D vector.
 
Vector3 absolute () const
 Returns a new 3D vector with the absolute values of the components of this 3D vector.
 
Vector3 & abs ()
 Sets the components of this 3D vector to their absolute values.
 
Vector3 & clamp (const Vector3 &min, const Vector3 &max)
 Clamps the components of this 3D vector to the specified minimum and maximum 3D vectors component-wise.
 
Vector3 & clamp (double min, double max)
 Clamps the components of this 3D vector to the specified minimum and maximum values.
 
double operator[] (std::size_t index) const
 Returns the component at the specified index of this 3D vector.
 
Vector3 & operator+= (const Vector3 &v)
 Adds the specified 3D vector to this vector.
 
Vector3 & operator+= (double s)
 Adds the specified constant to all components in this 3D vector.
 
Vector3 & operator-= (const Vector3 &v)
 Subtracts the specified 3D vector from this vector.
 
Vector3 & operator-= (double s)
 Subtracts the specified constant from all components in this 3D vector.
 
Vector3 & operator*= (const Vector3 &v)
 Multiplies the components of this vector with the corresponding components of the specified 3D vector.
 
Vector3 & operator*= (double s)
 Multiplies all components of this 3D vector with the specified constant.
 
Vector3 & operator/= (const Vector3 &v)
 Divides the components of this vector by the corresponding components of another 3D vector.
 
Vector3 & operator/= (double s)
 Divides the components of this 3D vector by the specified constant.
 

Additional Inherited Members

- Static Public Member Functions inherited from t::Vector3
static Vector3 fromBufferAttribute (const BufferAttribute< double > &bufferAttribute, int index)
 Returns 3 consecutive values at the specified index in a BufferAttribute at the specified in a Vector3.
 
static Vector3 cross (const Vector3 &a, const Vector3 &b)
 Returns the cross product of two vectors.
 
static double dot (const Vector3 &a, const Vector3 &b)
 Returns the dot product of two vectors.
 
static Vector3 reflect (const Vector3 &incident, const Vector3 &surfaceOrientation)
 Returns the reflection of an incident vector off a surface that has the specified orientation.
 
- Public Attributes inherited from t::Vector3
double x
 The x component of this 3D vector.
 
double y
 The y component of this 3D vector.
 
double z
 The z component of this 3D vector.
 

Detailed Description

The color class.

The class inherits from Vector3 and the x, y, and z components map to the normalized red, green, and blue components of the color, respectively.

Constructor & Destructor Documentation

◆ Color() [1/3]

t::Color::Color ( double r,
double g,
double b )
inline

Creates a new color with the specified normalized red, green, and blue components.

The components should be in the range \([0, 1]\).

auto red = Color(1, 0, 0);
auto green = Color(0, 1, 0);
auto blue = Color(0, 0, 1);
auto white = Color(1, 1, 1);
Color(double r, double g, double b)
Creates a new color with the specified normalized red, green, and blue components.
Definition Color.hpp:39
Parameters
rThe normalized red component of the color.
gThe normalized green component of the color.
bThe normalized blue component of the color.

◆ Color() [2/3]

t::Color::Color ( int r,
int g,
int b,
int colorDepth = 8 )
inline

Creates a new color with the specified red, green, and blue components and the specified color depth.

The components should be in the range \([0, 2^{d} - 1]\) where \(d\) is the color depth.

auto red = Color(255, 0, 0); // 8-bit red color
auto green16 = Color(0, 65535, 0, 16); // 16-bit green color
auto white = Color(255, 255, 255); // 8-bit white color
Parameters
rThe red component of the color.
gThe green component of the color.
bThe blue component of the color.
colorDepthThe color depth of the color.

◆ Color() [3/3]

t::Color::Color ( Vector3 vector3)
inlineexplicit

Creates a new color with the specified Vector3 components as normalized RGB values.

Parameters
vector3The Vector3 with the normalized red, green, and blue components.

Member Function Documentation

◆ clamp()

Color & t::Color::clamp ( )
inline

Clamps the components of this color to the range \([0, 1]\).

Returns
This color.

◆ luminance()

double t::Color::luminance ( ) const
inline

Returns the luminance of this color.

The luminance is calculated as \(0.2126r + 0.7152g + 0.0722z\) (reference).

Returns
The luminance of this color.

◆ Vector3()

t::Vector3::Vector3 ( double _x,
double _y,
double _z )
inline

Creates a new 3D vector with the specified components.

Parameters
_xThe x component of the new 3D vector.
_yThe y component of the new 3D vector.
_zThe z component of the new 3D vector.

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