-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathColor.h
More file actions
30 lines (22 loc) · 671 Bytes
/
Copy pathColor.h
File metadata and controls
30 lines (22 loc) · 671 Bytes
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
#ifndef SOFTWARE_RENDERER_COLOR_H
#define SOFTWARE_RENDERER_COLOR_H
#include <stdint.h>
#include <string>
#include "TGAImage.h"
#define RANDOM_COLOR Color(((float)rand()/RAND_MAX), ((float)rand()/RAND_MAX), ((float)rand()/RAND_MAX), 1)
class Color
{
public:
float R, G, B, A;
Color(float r = 1.0f, float g = 1.0f, float b = 1.0f, float a = 1.0f);
Color(TGAColor tcol);
uint32_t ToUInt32() const;
Color operator + (const Color &c) const;
Color operator - (const Color &c) const;
Color operator * (float f) const;
float operator[](uint32_t i) const;
std::string str();
private:
static const float constexpr tcol_denom = 1.0f / 255.0f;
};
#endif