-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathColor.hpp
More file actions
67 lines (48 loc) · 1.75 KB
/
Color.hpp
File metadata and controls
67 lines (48 loc) · 1.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/******************************************************************************
* @file Color.hpp
* @author Andrés Gavín Murillo, 716358
* @author Abel Naya Forcano, 544125
* @date Enero 2020
* @coms Informática Gráfica - Trabajo 4: Path tracer
******************************************************************************/
#ifndef TRABAJO3_COLOR_HPP
#define TRABAJO3_COLOR_HPP
#include "HCoord.hpp"
#include "Random.hpp"
struct Color {
float r;
float g;
float b;
float max() const;
Color operator+(const Color &right) const;
Color operator*(const Color &right) const;
bool operator>(const Color &right) const;
Color operator/(float s) const;
Color operator*(float s) const;
};
struct VertexColor {
enum VERTEX_COLOR_TYPE {
NEAREST,
DISTANCE_WEIGHTING,
DISTANCE_WEIGHTING_SQUARE
};
VERTEX_COLOR_TYPE type;
const Color colors[3];
const HCoord vertices[3];
};
Color rgb(unsigned char r, unsigned char g, unsigned char b);
VertexColor vertexColorNearest(const Color colors[3], const HCoord vertices[3]);
VertexColor vertexColorDistanceWeighting(const Color colors[3], const HCoord vertices[3]);
VertexColor vertexColorDistanceWeightingSquare(const Color colors[3], const HCoord vertices[3]);
Color getColor(const VertexColor &vertexColor, const HCoord &position);
// color constants
static const Color C_BLACK = {0, 0, 0};
static const Color C_RED = {1, 0, 0};
static const Color C_GREEN = {0, 1, 0};
static const Color C_BLUE = {0, 0, 1};
static const Color C_CYAN = {0, 1, 1};
static const Color C_PURPLE = {1, 0, 1};
static const Color C_YELLOW = {1, 1, 0};
static const Color C_WHITE = {1, 1, 1};
static const Color C_GREY = {0.5f, 0.5f, 0.5f};
#endif //TRABAJO3_COLOR_HPP