ProtoTracer  1.0
Real-time 3D rendering and animation engine
Loading...
Searching...
No Matches
Color.h
Go to the documentation of this file.
1/**
2 * @file Color.h
3 * @brief Abstract class template for defining and manipulating colors.
4 *
5 * @date 22/12/2024
6 * @version 1.0
7 * @author Coela Can't
8 */
9
10#pragma once
11
12#include <Arduino.h>
13
14/**
15 * @class Color
16 * @brief Abstract base class for representing a color with operations for modification and interpolation.
17 * @tparam T Data type for the color channels (e.g., uint8_t, float).
18 */
19template <typename T>
20class Color {
21public:
22 /**
23 * @brief Constructor to initialize a color with red, green, and blue components.
24 * @param R The red component of the color.
25 * @param G The green component of the color.
26 * @param B The blue component of the color.
27 */
28 virtual Color(T R, T G, T B) = 0;
29
30 /**
31 * @brief Virtual destructor.
32 */
33 virtual ~Color() {}
34
35 /**
36 * @brief Sets the color using red, green, and blue components.
37 * @param R The red component of the color.
38 * @param G The green component of the color.
39 * @param B The blue component of the color.
40 */
41 virtual void SetColor(T R, T G, T B) = 0;
42
43 /**
44 * @brief Scales the color brightness to a maximum brightness level.
45 * @param maxBrightness The maximum brightness value.
46 * @return A new color scaled to the specified brightness.
47 */
48 virtual Color Scale(T maxBrightness) = 0;
49
50 /**
51 * @brief Adds a constant value to all color channels.
52 * @param value The value to add to each channel.
53 * @return A new color with the added value.
54 */
55 virtual Color Add(T value) = 0;
56
57 /**
58 * @brief Shifts the hue of the color by a specified angle.
59 * @param hueDeg The hue shift in degrees.
60 * @return A new color with the hue shifted.
61 */
62 virtual Color HueShift(float hueDeg) = 0;
63
64 /**
65 * @brief Interpolates between two colors based on a ratio.
66 * @param color1 The first color.
67 * @param color2 The second color.
68 * @param ratio The interpolation ratio (0.0 - 1.0).
69 * @return A new color that is the interpolated result.
70 */
71 virtual Color InterpolateColors(Color color1, Color color2, float ratio) = 0;
72
73 /**
74 * @brief Converts the color to a string representation.
75 * @return A string representing the color in "R, G, B" format.
76 */
77 virtual String ToString() = 0;
78};
Abstract base class for representing a color with operations for modification and interpolation.
Definition Color.h:20
virtual Color InterpolateColors(Color color1, Color color2, float ratio)=0
Interpolates between two colors based on a ratio.
virtual String ToString()=0
Converts the color to a string representation.
virtual Color Scale(T maxBrightness)=0
Scales the color brightness to a maximum brightness level.
virtual ~Color()
Virtual destructor.
Definition Color.h:33
virtual Color(T R, T G, T B)=0
Constructor to initialize a color with red, green, and blue components.
virtual void SetColor(T R, T G, T B)=0
Sets the color using red, green, and blue components.
virtual Color HueShift(float hueDeg)=0
Shifts the hue of the color by a specified angle.
virtual Color Add(T value)=0
Adds a constant value to all color channels.