23 #include <tulip/Vector.h>
26 #include <QtCore/QVariant>
31 class TLP_SCOPE Color :
public tlp::Vector<unsigned char,4> {
34 inline Color(
const tlp::Vector<unsigned char,4>&);
36 inline Color(
const unsigned char red=0 ,
const unsigned char green=0 ,
const unsigned char blue=0,
const unsigned char alpha=255);
38 inline void set(
const unsigned char red=0,
const unsigned char green=0 ,
const unsigned char blue=0,
const unsigned char alpha=255);
40 inline float getRGL()
const;
42 inline float getGGL()
const;
44 inline float getBGL()
const;
46 inline float getAGL()
const;
48 inline float* getGL()
const;
50 inline unsigned char getR()
const;
52 inline unsigned char getG()
const;
54 inline unsigned char getB()
const;
56 inline unsigned char getA()
const;
58 inline void setR(
const unsigned char red);
60 inline void setG(
const unsigned char green);
62 inline void setB(
const unsigned char blue);
64 inline void setA(
const unsigned char alpha);
81 TLP_SCOPE std::ostream& operator<<(std::ostream &os,
const tlp::Color &);
82 TLP_SCOPE std::istream& operator>>(std::istream &is, tlp::Color &);
86 Q_DECLARE_METATYPE(tlp::Color)
88 tlp::Color::Color(const tlp::Vector<
unsigned char,4> &v) : tlp::Vector<
unsigned char,4>(v) {}
90 tlp::Color::Color(
const unsigned char red ,
const unsigned char green ,
const unsigned char blue,
const unsigned char alpha) {
96 void tlp::Color::set(
unsigned char red,
unsigned char green,
unsigned char blue,
unsigned char alpha) {
103 unsigned char tlp::Color::getR()
const {
106 unsigned char tlp::Color::getG()
const {
109 unsigned char tlp::Color::getB()
const {
112 unsigned char tlp::Color::getA()
const {
116 float tlp::Color::getRGL()
const {
117 return (
float)array[0]/255.0;
119 float tlp::Color::getGGL()
const {
120 return (
float)array[1]/255.0;
122 float tlp::Color::getBGL()
const {
123 return (
float)array[2]/255.0;
125 float tlp::Color::getAGL()
const {
126 return (
float)array[3]/255.0;
128 float* tlp::Color::getGL()
const {
129 float *result=
new float[4];
137 void tlp::Color::setR(
unsigned char red) {
140 void tlp::Color::setG(
unsigned char green) {
143 void tlp::Color::setB(
unsigned char blue) {
146 void tlp::Color::setA(
unsigned char alpha) {
150 TLP_BEGIN_HASH_NAMESPACE {
152 struct hash<tlp::Color> {
153 inline std::size_t operator()(
const tlp::Color &c)
const {
154 return hash_vector(c);
157 } TLP_END_HASH_NAMESPACE