ProtoTracer  1.0
Real-time 3D rendering and animation engine
Loading...
Searching...
No Matches
RGBColor.h
Go to the documentation of this file.
1/**
2 * @file RGBColor.h
3 * @brief Defines the RGBColor class for managing and manipulating RGB color values.
4 *
5 * The RGBColor class provides functionality to represent and manipulate RGB color values,
6 * including scaling brightness, adding values, hue shifting, and interpolating between colors.
7 *
8 * @date 22/12/2024
9 * @version 1.0
10 * @author Coela Can't
11 */
12
13#pragma once
14
15#include "Math/Mathematics.h"
16#include "Math/Quaternion.h"
17#include "Math/Vector3D.h"
18
19/**
20 * @class RGBColor
21 * @brief Represents an RGB color and provides methods for manipulation.
22 */
23class RGBColor {
24public:
25 uint8_t R = 0; ///< Red component of the color (0-255).
26 uint8_t G = 0; ///< Green component of the color (0-255).
27 uint8_t B = 0; ///< Blue component of the color (0-255).
28
29 /**
30 * @brief Default constructor initializes the color to black (0, 0, 0).
31 */
32 RGBColor();
33
34 /**
35 * @brief Constructor to initialize RGBColor with specified R, G, and B values.
36 * @param R Red component (0-255).
37 * @param G Green component (0-255).
38 * @param B Blue component (0-255).
39 */
40 RGBColor(const uint8_t& R, const uint8_t& G, const uint8_t& B);
41
42 /**
43 * @brief Copy constructor.
44 * @param rgbColor Reference to an existing RGBColor object.
45 */
47
48 /**
49 * @brief Constructor to initialize RGBColor from a Vector3D.
50 * @param color Vector3D representing RGB values.
51 */
52 RGBColor(const Vector3D& color);
53
54 /**
55 * @brief Sets the RGB values of the color.
56 * @param R Red component (0-255).
57 * @param G Green component (0-255).
58 * @param B Blue component (0-255).
59 */
60 void SetColor(const uint8_t& R, const uint8_t& G, const uint8_t& B);
61
62 /**
63 * @brief Scales the brightness of the color to a maximum value.
64 * @param maxBrightness The maximum brightness value (0-255).
65 * @return A new RGBColor with scaled brightness.
66 */
67 RGBColor Scale(const uint8_t& maxBrightness);
68
69 /**
70 * @brief Adds a value to each RGB component of the color.
71 * @param value The value to add (0-255).
72 * @return A new RGBColor with modified values.
73 */
74 RGBColor Add(const uint8_t& value);
75
76 /**
77 * @brief Shifts the hue of the color by a specified angle in degrees.
78 * @param hueDeg The angle in degrees to shift the hue.
79 * @return A new RGBColor with the hue shifted.
80 */
81 RGBColor HueShift(const float& hueDeg);
82
83 /**
84 * @brief Interpolates between two colors based on a ratio.
85 * @param a The starting color.
86 * @param b The ending color.
87 * @param ratio A value between 0 and 1 representing the interpolation factor.
88 * @return The interpolated RGBColor.
89 */
90 static RGBColor InterpolateColors(const RGBColor& a, const RGBColor& b, const float& ratio);
91
92 /**
93 * @brief Converts the RGBColor to a string representation.
94 * @return A string in the format "(R, G, B)".
95 */
97};
Provides a collection of mathematical utility functions and constants.
Defines the Quaternion class for 3D rotations and transformations.
Defines a 3D vector and various related operations.
Implements a generic Kalman Filter for 1D data.
Represents an RGB color and provides methods for manipulation.
Definition RGBColor.h:23
String ToString()
Converts the RGBColor to a string representation.
Definition RGBColor.cpp:89
uint16_t color
Encoded 16-bit RGB565 color value.
Definition RGBColor565.h:25
RGBColor()
Default constructor initializes the color to black (0, 0, 0).
Definition RGBColor.cpp:3
RGBColor HueShift(const float &hueDeg)
Shifts the hue of the color by a specified angle in degrees.
Definition RGBColor.cpp:65
void SetColor(const uint8_t &R, const uint8_t &G, const uint8_t &B)
Sets the RGB values of the color.
Definition RGBColor.cpp:23
RGBColor Scale(const uint8_t &maxBrightness)
Scales the brightness of the color to a maximum value.
Definition RGBColor.cpp:29
static RGBColor InterpolateColors(const RGBColor &a, const RGBColor &b, const float &ratio)
Interpolates between two colors based on a ratio.
Definition RGBColor.cpp:79
uint8_t B
Blue component of the color (0-255).
Definition RGBColor.h:27
uint8_t G
Green component of the color (0-255).
Definition RGBColor.h:26
RGBColor Add(const uint8_t &value)
Adds a value to each RGB component of the color.
Definition RGBColor.cpp:47
uint8_t R
Red component of the color (0-255).
Definition RGBColor.h:25
Represents a 3D vector (X, Y, Z) and provides methods for vector arithmetic.
Definition Vector3D.h:26