ProtoTracer  1.0
Real-time 3D rendering and animation engine
Loading...
Searching...
No Matches
RGBColor Class Reference

Represents an RGB color and provides methods for manipulation. More...

#include <RGBColor.h>

Public Member Functions

 RGBColor ()
 Default constructor initializes the color to black (0, 0, 0).
 
 RGBColor (const uint8_t &R, const uint8_t &G, const uint8_t &B)
 Constructor to initialize RGBColor with specified R, G, and B values.
 
 RGBColor (const RGBColor &rgbColor)
 Copy constructor.
 
 RGBColor (const Vector3D &color)
 Constructor to initialize RGBColor from a Vector3D.
 
void SetColor (const uint8_t &R, const uint8_t &G, const uint8_t &B)
 Sets the RGB values of the color.
 
RGBColor Scale (const uint8_t &maxBrightness)
 Scales the brightness of the color to a maximum value.
 
RGBColor Add (const uint8_t &value)
 Adds a value to each RGB component of the color.
 
RGBColor HueShift (const float &hueDeg)
 Shifts the hue of the color by a specified angle in degrees.
 
String ToString ()
 Converts the RGBColor to a string representation.
 
 RGBColor ()
 Default constructor initializes the color to black (0, 0, 0).
 
 RGBColor (uint8_t R, uint8_t G, uint8_t B)
 Constructor to initialize RGBColor with specified R, G, and B values.
 
 RGBColor (const RGBColor &rgbColor)
 Copy constructor.
 
 RGBColor (Vector3D color)
 Constructor to initialize RGBColor from a Vector3D.
 
void SetColor (uint8_t R, uint8_t G, uint8_t B)
 Sets the RGB values of the color.
 
RGBColor Scale (uint8_t maxBrightness)
 Scales the brightness of the color to a maximum value.
 
RGBColor Add (uint8_t value)
 Adds a value to each RGB component of the color.
 
RGBColor HueShift (float hueDeg)
 Shifts the hue of the color by a specified angle in degrees.
 
String ToString ()
 Converts the RGBColor to a string representation.
 

Static Public Member Functions

static RGBColor InterpolateColors (const RGBColor &a, const RGBColor &b, const float &ratio)
 Interpolates between two colors based on a ratio.
 
static RGBColor InterpolateColors (RGBColor a, RGBColor b, float ratio)
 Interpolates between two colors based on a ratio.
 

Public Attributes

uint8_t R = 0
 Red component of the color (0-255).
 
uint8_t G = 0
 Green component of the color (0-255).
 
uint8_t B = 0
 Blue component of the color (0-255).
 
uint16_t color = 0
 Encoded 16-bit RGB565 color value.
 

Detailed Description

Represents an RGB color and provides methods for manipulation.

Represents a 16-bit RGB color (RGB565) and provides methods for manipulation.

Definition at line 23 of file RGBColor.h.

Constructor & Destructor Documentation

◆ RGBColor() [1/8]

RGBColor ( )

Default constructor initializes the color to black (0, 0, 0).

Definition at line 3 of file RGBColor.cpp.

Referenced by Add(), Add(), HueShift(), HueShift(), InterpolateColors(), Scale(), and Scale().

◆ RGBColor() [2/8]

RGBColor ( const uint8_t R,
const uint8_t G,
const uint8_t B 
)

Constructor to initialize RGBColor with specified R, G, and B values.

Parameters
RRed component (0-255).
GGreen component (0-255).
BBlue component (0-255).

Definition at line 5 of file RGBColor.cpp.

References B, G, and R.

◆ RGBColor() [3/8]

RGBColor ( const RGBColor rgbColor)

Copy constructor.

Parameters
rgbColorReference to an existing RGBColor object.

Definition at line 11 of file RGBColor.cpp.

References B, G, and R.

◆ RGBColor() [4/8]

RGBColor ( const Vector3D color)

Constructor to initialize RGBColor from a Vector3D.

Parameters
colorVector3D representing RGB values.

Definition at line 17 of file RGBColor.cpp.

References B, G, R, Vector3D::X, Vector3D::Y, and Vector3D::Z.

◆ RGBColor() [5/8]

RGBColor ( )
inline

Default constructor initializes the color to black (0, 0, 0).

Definition at line 30 of file RGBColor565.h.

◆ RGBColor() [6/8]

RGBColor ( uint8_t  R,
uint8_t  G,
uint8_t  B 
)
inline

Constructor to initialize RGBColor with specified R, G, and B values.

Parameters
RRed component (0-255).
GGreen component (0-255).
BBlue component (0-255).

Definition at line 38 of file RGBColor565.h.

References B, color, G, and R.

◆ RGBColor() [7/8]

RGBColor ( const RGBColor rgbColor)
inline

Copy constructor.

Parameters
rgbColorReference to an existing RGBColor object.

Definition at line 50 of file RGBColor565.h.

References B, G, and R.

◆ RGBColor() [8/8]

RGBColor ( Vector3D  color)
inline

Constructor to initialize RGBColor from a Vector3D.

Parameters
colorVector3D representing RGB values.

Definition at line 60 of file RGBColor565.h.

References B, G, R, Vector3D::X, Vector3D::Y, and Vector3D::Z.

Member Function Documentation

◆ Add() [1/2]

RGBColor Add ( const uint8_t value)

Adds a value to each RGB component of the color.

Parameters
valueThe value to add (0-255).
Returns
A new RGBColor with modified values.

Definition at line 47 of file RGBColor.cpp.

References B, G, R, and RGBColor().

◆ Add() [2/2]

RGBColor Add ( uint8_t  value)
inline

Adds a value to each RGB component of the color.

Parameters
valueThe value to add (0-255).
Returns
A new RGBColor with modified values.

Definition at line 100 of file RGBColor565.h.

References B, Mathematics::Constrain(), G, R, and RGBColor().

◆ HueShift() [1/2]

RGBColor HueShift ( const float hueDeg)

Shifts the hue of the color by a specified angle in degrees.

Parameters
hueDegThe angle in degrees to shift the hue.
Returns
A new RGBColor with the hue shifted.

Definition at line 65 of file RGBColor.cpp.

References B, G, Mathematics::MPI, R, and RGBColor().

Referenced by Oscilloscope::GetRGB(), SpectrumAnalyzer::GetRGB(), Image::GetRGB(), UVMap::GetRGB(), SimpleMaterial::HueShift(), SpiralMaterial::HueShift(), HUB75AnimationSplit::Update(), WS35AnimationSplit::Update(), and ProtogenProject::UpdateFace().

◆ HueShift() [2/2]

RGBColor HueShift ( float  hueDeg)
inline

Shifts the hue of the color by a specified angle in degrees.

Parameters
hueDegThe angle in degrees to shift the hue.
Returns
A new RGBColor with the hue shifted.

Definition at line 113 of file RGBColor565.h.

References B, G, Mathematics::MPI, R, and RGBColor().

◆ InterpolateColors() [1/2]

RGBColor InterpolateColors ( const RGBColor a,
const RGBColor b,
const float ratio 
)
static

Interpolates between two colors based on a ratio.

Parameters
aThe starting color.
bThe ending color.
ratioA value between 0 and 1 representing the interpolation factor.
Returns
The interpolated RGBColor.

Definition at line 79 of file RGBColor.cpp.

References B, G, and R.

Referenced by MaterialMask::GetRGB().

◆ InterpolateColors() [2/2]

static RGBColor InterpolateColors ( RGBColor  a,
RGBColor  b,
float  ratio 
)
inlinestatic

Interpolates between two colors based on a ratio.

Parameters
aThe starting color.
bThe ending color.
ratioA value between 0 and 1 representing the interpolation factor.
Returns
The interpolated RGBColor.

Definition at line 131 of file RGBColor565.h.

References B, G, R, and RGBColor().

◆ Scale() [1/2]

RGBColor Scale ( const uint8_t maxBrightness)

Scales the brightness of the color to a maximum value.

Parameters
maxBrightnessThe maximum brightness value (0-255).
Returns
A new RGBColor with scaled brightness.

Definition at line 29 of file RGBColor.cpp.

References B, G, R, and RGBColor().

Referenced by BetaProtoController::Display(), GammaControllerBack::Display(), GammaControllerFront::Display(), KaiborgV1Controller::Display(), KaiborgV1D1Controller::Display(), ProtoDRController::Display(), WS35BetaController::Display(), and WS35Controller::Display().

◆ Scale() [2/2]

RGBColor Scale ( uint8_t  maxBrightness)
inline

Scales the brightness of the color to a maximum value.

Parameters
maxBrightnessThe maximum brightness value (0-255).
Returns
A new RGBColor with scaled brightness.

Definition at line 83 of file RGBColor565.h.

References B, Mathematics::Constrain(), G, R, and RGBColor().

◆ SetColor() [1/2]

void SetColor ( const uint8_t R,
const uint8_t G,
const uint8_t B 
)

Sets the RGB values of the color.

Parameters
RRed component (0-255).
GGreen component (0-255).
BBlue component (0-255).

Definition at line 23 of file RGBColor.cpp.

References B, G, and R.

Referenced by SammyAnimation::Update(), and TechSaneAnimation::Update().

◆ SetColor() [2/2]

void SetColor ( uint8_t  R,
uint8_t  G,
uint8_t  B 
)
inline

Sets the RGB values of the color.

Parameters
RRed component (0-255).
GGreen component (0-255).
BBlue component (0-255).

Definition at line 72 of file RGBColor565.h.

References B, G, and R.

◆ ToString() [1/2]

String ToString ( )

Converts the RGBColor to a string representation.

Returns
A string in the format "(R, G, B)".

Definition at line 89 of file RGBColor.cpp.

References B, G, and R.

◆ ToString() [2/2]

String ToString ( )
inline

Converts the RGBColor to a string representation.

Returns
A string in the format "[R, G, B]".

Definition at line 143 of file RGBColor565.h.

References B, G, and R.

Member Data Documentation

◆ B

◆ color

uint16_t color = 0

Encoded 16-bit RGB565 color value.

Definition at line 25 of file RGBColor565.h.

Referenced by RGBColor().

◆ G

◆ R


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