raven/src/RGB.hpp

34 lines
656 B
C++
Raw Normal View History

2022-03-18 02:49:16 +02:00
#pragma once
2022-06-12 22:16:26 +03:00
#include <iostream>
2022-03-18 02:49:16 +02:00
namespace Raven {
class RGB {
private:
double m_r {0.0};
double m_g {0.0};
double m_b {0.0};
public:
RGB() {}
RGB(double r, double g, double b)
: m_r(r)
, m_g(g)
, m_b(b) {}
2022-06-12 22:16:26 +03:00
RGB(unsigned int hex) {
m_r = (((hex) >> (2 * 8)) & 0xFF) / 255.0;
m_g = (((hex) >> (1 * 8)) & 0xFF) / 255.0;
m_b = (((hex) >> (0 * 8)) & 0xFF) / 255.0;
}
2022-03-18 02:49:16 +02:00
void set_r(double r) { m_r = r; }
void set_g(double g) { m_g = g; }
void set_b(double b) { m_b = b; }
2022-04-30 09:40:09 +03:00
double r() { return m_r; }
double g() { return m_g; }
double b() { return m_b; }
2022-03-18 02:49:16 +02:00
};
}