|
Ray Tracer Common Project
Image rendering program based on the ray tracing technique.
|
RGBA color representation. More...
#include <color.hpp>
Public Member Functions | |
| color () | |
| color (const color &c) | |
| color (double r, double g, double b, double a=1.0) | |
| virtual void | set_red (double r) |
| virtual void | set_green (double g) |
| virtual void | set_blue (double b) |
| virtual void | set_alpha (double a) |
| double | red () const |
| double | green () const |
| double | blue () const |
| double | alpha () const |
| virtual bool | operator== (const color &c) const |
| color | operator+ (const color &c) const |
| Color addition. More... | |
| void | operator+= (const color &c) |
| Color addition See color::operator+ for details. | |
| color | operator* (const color &c) const |
| Color multiplication. More... | |
| void | operator*= (const color &c) |
| Color multiplication. More... | |
| void | operator*= (double f) |
| Double multiplication. More... | |
| color | operator* (double f) const |
| Double multiplication. More... | |
| virtual | operator uint32 () const |
| Cast operator to unsigned 32bits int. More... | |
| uint32 | map (SDL_PixelFormat *) const |
| SDL convertion operator. More... | |
Static Public Attributes | |
| static color | WHITE = color(1.0, 1.0, 1.0) |
| default white color. | |
| static color | GRAY = color(0.5, 0.5, 0.5) |
| default gray color. | |
| static color | BLACK = color(0.0, 0.0, 0.0) |
| default black color. | |
| static color | BLUE = color(0.0, 0.0, 1.0) |
| default blue color. | |
| static color | GREEN = color(0.0, 1.0, 0.0) |
| default green color. | |
| static color | RED = color(1.0, 0.0, 0.0) |
| default red color. | |
RGBA color representation.
The color class represents a color through its four components: red, green, blue and alpha (RGBA). All components are normalized into [0, 1].
| rt::color::color | ( | ) |
Default constructor. Builds a white color.
| rt::color::color | ( | const color & | c | ) |
Copy constructor.
| rt::color::color | ( | double | r, |
| double | g, | ||
| double | b, | ||
| double | a = 1.0 |
||
| ) |
Builds a color from its red, green and blue components. Alpha is set to 255.
|
inline |
Returns the alpha component.
|
inline |
Returns the blue component.
|
inline |
Returns the green component.
| uint32 rt::color::map | ( | SDL_PixelFormat * | format | ) | const |
SDL convertion operator.
Cast the color into the SDL pixel format representation.
|
virtual |
Cast operator to unsigned 32bits int.
Represents the color as a unsigned 32b int, with red being the most significant byte.
Color multiplication.
Perform a multiplication, or absorbtion, between two colors. The multiplication is defined as follow:
For two colors \(src_{RGBA}\) and \(dst_{RGBA}\) (this color) the destination color will be:
\begin{eqnarray*} out_{RGB} &=& dst_{RGB}src_{RGB}src_A + dst_{RGB}(1-src_A)\\ out_A &=& dst_Asrc_A + dst_A(1-src_A) \end{eqnarray*}
| color rt::color::operator* | ( | double | f | ) | const |
Double multiplication.
Return a new color from this one with all components multiplied by a double value.
| void rt::color::operator*= | ( | const color & | c | ) |
Color multiplication.
See color::operator* for details.
| void rt::color::operator*= | ( | double | f | ) |
Double multiplication.
Multiply all components but alpha by a double value.
Color addition.
Perfom an additive blending between two colors. The blending is performed as follow:
For two colors \(src_{RGBA}\) and \(dst_{RGBA}\) (this color) the destination color will be:
\[ out_{RGBA} = src_{RGBA} + dst_{RGBA} \]
|
virtual |
Comparison operator.
|
inline |
Returns the red component.
|
inlinevirtual |
Sets the alpha component.
|
inlinevirtual |
Sets the blue component.
|
inlinevirtual |
Sets the green component.
|
inlinevirtual |
Sets the red component.
1.8.15