Color.hpp
Go to the documentation of this file.
1 
7 #include <etk/types.hpp>
8 
9 #pragma once
10 
11 #include <iomanip>
12 
13 namespace etk {
32  template<typename MY_TYPE=uint8_t, int MY_TYPE_SIZE=4> class Color {
33  public:
35  static const MY_TYPE defaultAlpha;
36  private:
37  MY_TYPE m_element[MY_TYPE_SIZE];
38  public:
42  Color() { };
50  Color(MY_TYPE _r, MY_TYPE _g, MY_TYPE _b, MY_TYPE _a) {
51  set(_r, _g, _b, _a);
52  };
59  Color(MY_TYPE _r, MY_TYPE _g, MY_TYPE _b) {
60  set(_r, _g, _b);
61  };
67  Color(MY_TYPE _r, MY_TYPE _g) {
68  set(_r, _g);
69  };
74  Color(MY_TYPE _r) {
75  set(_r);
76  };
81  template<typename MY_TYPE_2, int MY_TYPE_SIZE_2>
87  Color(const std::string& _input);
94  for (size_t iii=0; iii<MY_TYPE_SIZE; ++iii) {
95  m_element[iii] = _input.m_element[iii];
96  }
97  return *this;
98  };
106  for (size_t iii=0; iii<MY_TYPE_SIZE;++iii) {
107  if(m_element[iii] != _obj.m_element[iii]) {
108  return true;
109  }
110  }
111  return false;
112  }
120  for (size_t iii=0; iii<MY_TYPE_SIZE;++iii) {
121  if(m_element[iii] != _obj.m_element[iii]) {
122  return false;
123  }
124  }
125  return true;
126  }
131  uint32_t get() const;
139  void set(MY_TYPE _r, MY_TYPE _g, MY_TYPE _b, MY_TYPE _a) {
140  if (MY_TYPE_SIZE >= 1) {
141  m_element[0] = _r;
142  }
143  if (MY_TYPE_SIZE >= 2) {
144  m_element[1] = _g;
145  }
146  if (MY_TYPE_SIZE >= 3) {
147  m_element[2] = _b;
148  }
149  if (MY_TYPE_SIZE >= 4) {
150  m_element[3] = _a;
151  }
152  };
159  void set(MY_TYPE _r, MY_TYPE _g, MY_TYPE _b) {
160  if (MY_TYPE_SIZE >= 1) {
161  m_element[0] = _r;
162  }
163  if (MY_TYPE_SIZE >= 2) {
164  m_element[1] = _g;
165  }
166  if (MY_TYPE_SIZE >= 3) {
167  m_element[2] = _b;
168  }
169  if (MY_TYPE_SIZE >= 4) {
170  m_element[3] = defaultAlpha;
171  }
172  };
178  void set(MY_TYPE _r, MY_TYPE _g) {
179  if (MY_TYPE_SIZE >= 1) {
180  m_element[0] = _r;
181  }
182  if (MY_TYPE_SIZE >= 2) {
183  m_element[1] = _g;
184  }
185  if (MY_TYPE_SIZE >= 3) {
186  m_element[2] = 0;
187  }
188  if (MY_TYPE_SIZE >= 4) {
189  m_element[3] = defaultAlpha;
190  }
191  };
196  void set(MY_TYPE _r) {
197  if (MY_TYPE_SIZE >= 1) {
198  m_element[0] = _r;
199  }
200  if (MY_TYPE_SIZE >= 2) {
201  m_element[1] = 0;
202  }
203  if (MY_TYPE_SIZE >= 3) {
204  m_element[2] = 0;
205  }
206  if (MY_TYPE_SIZE >= 4) {
207  m_element[3] = defaultAlpha;
208  }
209  };
214  std::string getHexString() const {
215  std::ostringstream oss;
216  oss << "0x" << std::setw(8) << std::setfill('0') << std::hex << get();
217  return oss.str();
218  };
223  std::string getString() const {
224  std::ostringstream oss;
225  oss << "#" << std::setw(8) << std::setfill('0') << std::hex << get();
226  return oss.str();
227  };
232  MY_TYPE r() const {
233  if (MY_TYPE_SIZE >= 1) {
234  return m_element[0];
235  } else {
236  return 0;
237  }
238  };
243  MY_TYPE g() const {
244  if (MY_TYPE_SIZE >= 2) {
245  return m_element[1];
246  } else {
247  return 0;
248  }
249  };
254  MY_TYPE b() const {
255  if (MY_TYPE_SIZE >= 3) {
256  return m_element[2];
257  } else {
258  return 0;
259  }
260  };
265  MY_TYPE a() const {
266  if (MY_TYPE_SIZE >= 4) {
267  return m_element[3];
268  } else {
269  return defaultAlpha;
270  }
271  };
276  void setR(MY_TYPE _r) {
277  if (MY_TYPE_SIZE >= 1) {
278  m_element[0] = MY_TYPE(_r);
279  }
280  };
285  void setG(MY_TYPE _g) {
286  if (MY_TYPE_SIZE >= 2) {
287  m_element[1] = MY_TYPE(_g);
288  }
289  };
294  void setB(MY_TYPE _b) {
295  if (MY_TYPE_SIZE >= 3) {
296  m_element[2] = MY_TYPE(_b);
297  }
298  };
303  void setA(MY_TYPE _a) {
304  if (MY_TYPE_SIZE >= 4) {
305  m_element[3] = MY_TYPE(_a);
306  }
307  };
314  if (MY_TYPE_SIZE >= 1) {
315  m_element[0] += _obj.m_element[0];
316  }
317  if (MY_TYPE_SIZE >= 2) {
318  m_element[1] += _obj.m_element[1];
319  }
320  if (MY_TYPE_SIZE >= 3) {
321  m_element[2] += _obj.m_element[2];
322  }
323  if (MY_TYPE_SIZE >= 4) {
324  m_element[3] += _obj.m_element[3];
325  }
326  return *this;
327  }
335  tmpp += _obj;
336  return tmpp;
337  }
344  if (MY_TYPE_SIZE >= 1) {
345  m_element[0] *= _obj.m_element[0];
346  }
347  if (MY_TYPE_SIZE >= 2) {
348  m_element[1] *= _obj.m_element[1];
349  }
350  if (MY_TYPE_SIZE >= 3) {
351  m_element[2] *= _obj.m_element[2];
352  }
353  if (MY_TYPE_SIZE >= 4) {
354  m_element[3] *= _obj.m_element[3];
355  }
356  return *this;
357  }
364  if (MY_TYPE_SIZE >= 1) {
365  m_element[0] *= _val;
366  }
367  if (MY_TYPE_SIZE >= 2) {
368  m_element[1] *= _val;
369  }
370  if (MY_TYPE_SIZE >= 3) {
371  m_element[2] *= _val;
372  }
373  if (MY_TYPE_SIZE >= 4) {
374  m_element[3] *= _val;
375  }
376  return *this;
377  }
385  tmpp *= _obj;
386  return tmpp;
387  }
393  etk::Color<MY_TYPE,MY_TYPE_SIZE> operator* (const MY_TYPE _val) const {
395  tmpp *= _val;
396  return tmpp;
397  }
398  };
399 
405  etk::Color<uint8_t, 4> parseStringStartWithSharp(const std::string& _input);
411  etk::Color<uint8_t, 4> parseStringStartWithRGBGen(const std::string& _input);
417  etk::Color<double, 4> parseStringStartWithRGB(const std::string& _input);
435  etk::Color<uint8_t, 4> parseStringStartWithRGBUnsigned8(const std::string& _input);
441  etk::Color<uint8_t, 4> parseStringColorNamed(const std::string& _input);
442 
448  template<> uint32_t Color<uint8_t, 4>::get() const;
449 
450  template<typename MY_TYPE, int MY_TYPE_SIZE> uint32_t Color<MY_TYPE, MY_TYPE_SIZE>::get() const {
451  Color<uint8_t, 4> tmp(*this);
452  return tmp.get();
453  }
454 
455  template<typename MY_TYPE, int MY_TYPE_SIZE> Color<MY_TYPE, MY_TYPE_SIZE>::Color(const std::string& _input) {
456  //TK_VERBOSE("convert color string : '" << _input << "'");
457  const char* inputData = _input.c_str();
458  size_t len = _input.size();
459  if( len >=1
460  && inputData[0] == '#') {
461  Color<uint8_t, 4> value = etk::parseStringStartWithSharp(std::string(_input, 1));
462  *this = value;
463  } else if(etk::start_with(_input, "rgb(", false) == true) {
464  Color<uint8_t, 4> value = etk::parseStringStartWithRGBGen(std::string(_input, 4, _input.size()-5));
465  *this = value;
466  } else if(etk::start_with(_input, "rgba(", false) == true) {
467  Color<uint8_t, 4> value = etk::parseStringStartWithRGBGen(std::string(_input, 5, _input.size()-6));
468  *this = value;
469  } else if(etk::start_with(_input, "rgb[FLOAT](", false) == true) {
470  Color<double, 4> value = etk::parseStringStartWithRGB(std::string(_input, 11, _input.size()-12));
471  *this = value;
472  } else if(etk::start_with(_input, "rgba[FLOAT](", false) == true) {
473  Color<double, 4> value = etk::parseStringStartWithRGB(std::string(_input, 12, _input.size()-13));
474  *this = value;
475  } else if(etk::start_with(_input, "rgb[DOUBLE](", false) == true) {
476  Color<double, 4> value = etk::parseStringStartWithRGB(std::string(_input, 12, _input.size()-13));
477  *this = value;
478  } else if(etk::start_with(_input, "rgba[DOUBLE](", false) == true) {
479  Color<double, 4> value = etk::parseStringStartWithRGB(std::string(_input, 13, _input.size()-14));
480  *this = value;
481  } else if(etk::start_with(_input, "rgb[U32](", false) == true) {
482  Color<uint32_t, 4> value = etk::parseStringStartWithRGBUnsigned32(std::string(_input, 9, _input.size()-10));
483  *this = value;
484  } else if(etk::start_with(_input, "rgba[U32](", false) == true) {
485  Color<uint32_t, 4> value = etk::parseStringStartWithRGBUnsigned32(std::string(_input, 10, _input.size()-11));
486  *this = value;
487  } else if(etk::start_with(_input, "rgb[U16](", false) == true) {
488  Color<uint16_t, 4> value = etk::parseStringStartWithRGBUnsigned16(std::string(_input, 9, _input.size()-10));
489  *this = value;
490  } else if(etk::start_with(_input, "rgba[U16](", false) == true) {
491  Color<uint16_t, 4> value = etk::parseStringStartWithRGBUnsigned16(std::string(_input, 10, _input.size()-11));
492  *this = value;
493  } else if(etk::start_with(_input, "rgb[U8](", false) == true) {
494  Color<uint8_t, 4> value = etk::parseStringStartWithRGBUnsigned8(std::string(_input, 8, _input.size()-9));
495  *this = value;
496  } else if(etk::start_with(_input, "rgba[U8](", false) == true) {
497  Color<uint8_t, 4> value = etk::parseStringStartWithRGBUnsigned8(std::string(_input, 9, _input.size()-10));
498  *this = value;
499  } else {
501  *this = value;
502  }
503  //TK_VERBOSE(" ==> converted color string : '" << _input << "' ==> " << *this);
504  };
505 
506 
508  template<int MY_TYPE_SIZE> std::ostream& operator <<(std::ostream& _os, const Color<uint8_t, MY_TYPE_SIZE>& _obj) { // RGB & RGBA 8 bits
509  std::ostringstream oss;
510  if (MY_TYPE_SIZE >= 3) {
511  _os << "#";
512  oss << std::setw(2) << std::setfill('0') << std::hex << uint32_t(_obj.r());
513  if (MY_TYPE_SIZE >= 2) {
514  oss << std::setw(2) << std::setfill('0') << std::hex << uint32_t(_obj.g());
515  }
516  if (MY_TYPE_SIZE >= 3) {
517  oss << std::setw(2) << std::setfill('0') << std::hex << uint32_t(_obj.b());
518  }
519  if (MY_TYPE_SIZE >= 4) {
520  oss << std::setw(2) << std::setfill('0') << std::hex << uint32_t(_obj.a());
521  }
522  _os << oss.str();
523  } else {
524  if (MY_TYPE_SIZE >= 2) {
525  _os << "be";
526  } else {
527  _os << "Mono";
528  }
529  _os << "[U8](";
530  oss << "0x" << std::setw(2) << std::setfill('0') << std::hex << uint32_t(_obj.r());
531  if (MY_TYPE_SIZE >= 2) {
532  _os << ",";
533  oss << "0x" << std::setw(2) << std::setfill('0') << std::hex << uint32_t(_obj.g());
534  }
535  _os << oss.str();
536  _os << ")";
537  }
538  return _os;
539  }
541  template<int MY_TYPE_SIZE> std::ostream& operator <<(std::ostream& _os, const Color<uint16_t, MY_TYPE_SIZE>& _obj) { // RGB & RGBA 8 bits
542  std::ostringstream oss;
543  if (MY_TYPE_SIZE >= 4) {
544  _os << "rgba";
545  } else if (MY_TYPE_SIZE >= 3) {
546  _os << "rgb";
547  } else if (MY_TYPE_SIZE >= 2) {
548  _os << "be";
549  } else {
550  _os << "Mono";
551  }
552  _os << "[U16](";
553  oss << "0x" << std::setw(4) << std::setfill('0') << std::hex << _obj.r();
554  if (MY_TYPE_SIZE >= 2) {
555  oss << ",0x" << std::setw(4) << std::setfill('0') << std::hex << _obj.g();
556  }
557  if (MY_TYPE_SIZE >= 3) {
558  oss << ",0x" << std::setw(4) << std::setfill('0') << std::hex << _obj.b();
559  }
560  if (MY_TYPE_SIZE >= 4) {
561  oss << ",0x" << std::setw(4) << std::setfill('0') << std::hex << _obj.a();
562  }
563  _os << oss.str() << ")";
564  return _os;
565  }
567  template<int MY_TYPE_SIZE> std::ostream& operator <<(std::ostream& _os, const Color<uint32_t, MY_TYPE_SIZE>& _obj) { // RGB & RGBA 8 bits
568  std::ostringstream oss;
569  if (MY_TYPE_SIZE >= 4) {
570  _os << "rgba";
571  } else if (MY_TYPE_SIZE >= 3) {
572  _os << "rgb";
573  } else if (MY_TYPE_SIZE >= 2) {
574  _os << "be";
575  } else {
576  _os << "Mono";
577  }
578  _os << "[U32](";
579  oss << "0x" << std::setw(8) << std::setfill('0') << std::hex << _obj.r();
580  if (MY_TYPE_SIZE >= 2) {
581  oss << ",0x" << std::setw(8) << std::setfill('0') << std::hex << _obj.g();
582  }
583  if (MY_TYPE_SIZE >= 3) {
584  oss << ",0x" << std::setw(8) << std::setfill('0') << std::hex << _obj.b();
585  }
586  if (MY_TYPE_SIZE >= 4) {
587  oss << ",0x" << std::setw(8) << std::setfill('0') << std::hex << _obj.a();
588  }
589  _os << oss.str() << ")";
590  return _os;
591  }
593  template<int MY_TYPE_SIZE> std::ostream& operator <<(std::ostream& _os, const Color<float, MY_TYPE_SIZE>& _obj) { // RGB float & RGBA float
594  if (MY_TYPE_SIZE >= 4) {
595  _os << "rgba";
596  } else if (MY_TYPE_SIZE >= 3) {
597  _os << "rgb";
598  } else if (MY_TYPE_SIZE >= 2) {
599  _os << "be";
600  } else {
601  _os << "Mono";
602  }
603  _os << "[FLOAT](";
604  _os << _obj.r();
605  if (MY_TYPE_SIZE >= 2) {
606  _os << ",";
607  _os << _obj.g();
608  }
609  if (MY_TYPE_SIZE >= 3) {
610  _os << ",";
611  _os << _obj.b();
612  }
613  if (MY_TYPE_SIZE >= 4) {
614  _os << ",";
615  _os << _obj.a();
616  }
617  _os << ")";
618  return _os;
619  }
621  template<int MY_TYPE_SIZE> std::ostream& operator <<(std::ostream& _os, const Color<double, MY_TYPE_SIZE>& _obj) { // RGB & RGBA 8 bits
622  if (MY_TYPE_SIZE >= 4) {
623  _os << "rgba";
624  } else if (MY_TYPE_SIZE >= 3) {
625  _os << "rgb";
626  } else if (MY_TYPE_SIZE >= 2) {
627  _os << "be";
628  } else {
629  _os << "Mono";
630  }
631  _os << "[double](";
632  _os << _obj.r();
633  if (MY_TYPE_SIZE >= 2) {
634  _os << ",";
635  _os << _obj.g();
636  }
637  if (MY_TYPE_SIZE >= 3) {
638  _os << ",";
639  _os << _obj.b();
640  }
641  if (MY_TYPE_SIZE >= 4) {
642  _os << ",";
643  _os << _obj.a();
644  }
645  _os << ")";
646  return _os;
647  }
649  template<typename MY_TYPE, int MY_TYPE_SIZE> std::ostream& operator <<(std::ostream& _os, const std::vector<Color<MY_TYPE, MY_TYPE_SIZE> >& _obj) {
650  for (size_t iii = 0; iii < _obj.size(); ++iii) {
651  if (iii != 0) {
652  _os << " ";
653  }
654  _os << _obj[iii];
655  }
656  return _os;
657  };
658 
662  namespace color {
663  extern const Color<> none;
664  extern const Color<> aliceBlue;
665  extern const Color<> antiqueWhite;
666  extern const Color<> aqua;
667  extern const Color<> aquamarine;
668  extern const Color<> azure;
669  extern const Color<> beige;
670  extern const Color<> bisque;
671  extern const Color<> black;
672  extern const Color<> blanchedAlmond;
673  extern const Color<> blue;
674  extern const Color<> blueViolet;
675  extern const Color<> brown;
676  extern const Color<> burlyWood;
677  extern const Color<> cadetBlue;
678  extern const Color<> chartreuse;
679  extern const Color<> chocolate;
680  extern const Color<> coral;
681  extern const Color<> cornflowerBlue;
682  extern const Color<> cornsilk;
683  extern const Color<> crimson;
684  extern const Color<> cyan;
685  extern const Color<> darkBlue;
686  extern const Color<> darkCyan;
687  extern const Color<> darkGoldenRod;
688  extern const Color<> darkGray;
689  extern const Color<> darkGrey;
690  extern const Color<> darkGreen;
691  extern const Color<> darkKhaki;
692  extern const Color<> darkMagenta;
693  extern const Color<> darkOliveGreen;
694  extern const Color<> darkorange;
695  extern const Color<> darkOrchid;
696  extern const Color<> darkRed;
697  extern const Color<> darkSalmon;
698  extern const Color<> darkSeaGreen;
699  extern const Color<> darkSlateBlue;
700  extern const Color<> darkSlateGray;
701  extern const Color<> darkSlateGrey;
702  extern const Color<> darkTurquoise;
703  extern const Color<> darkViolet;
704  extern const Color<> deepPink;
705  extern const Color<> deepSkyBlue;
706  extern const Color<> dimGray;
707  extern const Color<> dimGrey;
708  extern const Color<> dodgerBlue;
709  extern const Color<> fireBrick;
710  extern const Color<> floralWhite;
711  extern const Color<> forestGreen;
712  extern const Color<> fuchsia;
713  extern const Color<> gainsboro;
714  extern const Color<> ghostWhite;
715  extern const Color<> gold;
716  extern const Color<> goldenRod;
717  extern const Color<> gray;
718  extern const Color<> grey;
719  extern const Color<> green;
720  extern const Color<> greenYellow;
721  extern const Color<> honeyDew;
722  extern const Color<> hotPink;
723  extern const Color<> indianRed;
724  extern const Color<> indigo;
725  extern const Color<> ivory;
726  extern const Color<> khaki;
727  extern const Color<> lavender;
728  extern const Color<> lavenderBlush;
729  extern const Color<> lawnGreen;
730  extern const Color<> lemonChiffon;
731  extern const Color<> lightBlue;
732  extern const Color<> lightCoral;
733  extern const Color<> lightCyan;
734  extern const Color<> lightGoldenRodYellow;
735  extern const Color<> lightGray;
736  extern const Color<> lightGrey;
737  extern const Color<> lightGreen;
738  extern const Color<> lightPink;
739  extern const Color<> lightSalmon;
740  extern const Color<> lightSeaGreen;
741  extern const Color<> lightSkyBlue;
742  extern const Color<> lightSlateGray;
743  extern const Color<> lightSlateGrey;
744  extern const Color<> lightSteelBlue;
745  extern const Color<> lightYellow;
746  extern const Color<> lime;
747  extern const Color<> limeGreen;
748  extern const Color<> linen;
749  extern const Color<> magenta;
750  extern const Color<> maroon;
751  extern const Color<> mediumAquaMarine;
752  extern const Color<> mediumBlue;
753  extern const Color<> mediumOrchid;
754  extern const Color<> mediumPurple;
755  extern const Color<> mediumSeaGreen;
756  extern const Color<> mediumSlateBlue;
757  extern const Color<> mediumSpringGreen;
758  extern const Color<> mediumTurquoise;
759  extern const Color<> mediumVioletRed;
760  extern const Color<> midnightBlue;
761  extern const Color<> mintCream;
762  extern const Color<> mistyRose;
763  extern const Color<> moccasin;
764  extern const Color<> navajoWhite;
765  extern const Color<> navy;
766  extern const Color<> oldLace;
767  extern const Color<> olive;
768  extern const Color<> oliveDrab;
769  extern const Color<> orange;
770  extern const Color<> orangeRed;
771  extern const Color<> orchid;
772  extern const Color<> paleGoldenRod;
773  extern const Color<> paleGreen;
774  extern const Color<> paleTurquoise;
775  extern const Color<> paleVioletRed;
776  extern const Color<> papayaWhip;
777  extern const Color<> peachPuff;
778  extern const Color<> peru;
779  extern const Color<> pink;
780  extern const Color<> plum;
781  extern const Color<> powderBlue;
782  extern const Color<> purple;
783  extern const Color<> red;
784  extern const Color<> rosyBrown;
785  extern const Color<> royalBlue;
786  extern const Color<> saddleBrown;
787  extern const Color<> salmon;
788  extern const Color<> sandyBrown;
789  extern const Color<> seaGreen;
790  extern const Color<> seaShell;
791  extern const Color<> sienna;
792  extern const Color<> silver;
793  extern const Color<> skyBlue;
794  extern const Color<> slateBlue;
795  extern const Color<> slateGray;
796  extern const Color<> slateGrey;
797  extern const Color<> snow;
798  extern const Color<> springGreen;
799  extern const Color<> steelBlue;
800  extern const Color<> tan;
801  extern const Color<> teal;
802  extern const Color<> thistle;
803  extern const Color<> tomato;
804  extern const Color<> turquoise;
805  extern const Color<> violet;
806  extern const Color<> wheat;
807  extern const Color<> white;
808  extern const Color<> whiteSmoke;
809  extern const Color<> yellow;
810  extern const Color<> yellowGreen;
811  };
812 };
813 
814 
const Color mediumSlateBlue
const Color darkGoldenRod
const Color powderBlue
const Color darkBlue
const Color darkSeaGreen
const Color pink
const Color rosyBrown
const Color khaki
const Color navajoWhite
const Color navy
uint32_t get() const
Get the Generic uint32_t value of the color.
Definition: Color.hpp:450
const Color plum
const Color paleGreen
const etk::Color< MY_TYPE, MY_TYPE_SIZE > & operator+=(const etk::Color< MY_TYPE, MY_TYPE_SIZE > &_obj)
Operator+= Addition an other etk::color with this one.
Definition: Color.hpp:313
const Color lightGray
const Color slateBlue
const Color indianRed
void setR(MY_TYPE _r)
Set red color.
Definition: Color.hpp:276
const Color moccasin
void setA(MY_TYPE _a)
Set alpha blending.
Definition: Color.hpp:303
const Color tomato
const Color lightCyan
const Color oliveDrab
const Color ghostWhite
const Color goldenRod
const Color darkGreen
etk::Color< MY_TYPE, MY_TYPE_SIZE > operator*(const etk::Color< MY_TYPE, MY_TYPE_SIZE > &_obj) const
Operator*= Multiply 2 color together.
Definition: Color.hpp:383
const Color darkKhaki
const Color sienna
basic namespace of the etk library. (it might contain all the etk fuctions/class/structures without m...
Definition: Archive.hpp:16
const Color darkGray
const Color cornflowerBlue
const Color lightSkyBlue
etk::Color< MY_TYPE, MY_TYPE_SIZE > operator+(const etk::Color< MY_TYPE, MY_TYPE_SIZE > &_obj) const
Operator+ Addition an other etk::color with this one.
Definition: Color.hpp:333
const Color gray
const Color gold
const Color lime
const Color mediumBlue
Color(MY_TYPE _r)
Contructor with request initialisation.
Definition: Color.hpp:74
const Color violet
const Color crimson
const Color cadetBlue
const Color teal
const Color yellowGreen
const Color mistyRose
const Color purple
const Color mediumOrchid
const Color lightGreen
const Color lightSlateGray
const Color midnightBlue
const Color tan
Color()
Constructor. It does not initialise element of class.
Definition: Color.hpp:42
const Color limeGreen
const Color linen
const Color whiteSmoke
etk::Color< uint32_t, 4 > parseStringStartWithRGBUnsigned32(const std::string &_input)
Get a color value started with a "rgb()" converted in uint32.
const Color aquamarine
const Color mediumPurple
const Color steelBlue
const Color blue
const Color indigo
const Color wheat
const Color silver
const Color dimGray
std::string getString() const
Convert the color in an generic string value ("#FEDCBA98")
Definition: Color.hpp:223
const Color royalBlue
const Color magenta
const Color lightSeaGreen
MY_TYPE a() const
Get alpha blending.
Definition: Color.hpp:265
const Color dodgerBlue
const Color chartreuse
const Color darkGrey
const Color lightGoldenRodYellow
etk::Color< uint16_t, 4 > parseStringStartWithRGBUnsigned16(const std::string &_input)
Get a color value started with a "rgb()" converted in uint16.
const Color lawnGreen
const Color forestGreen
void setB(MY_TYPE _b)
Set blue color.
Definition: Color.hpp:294
const Color orangeRed
const Color chocolate
const Color salmon
MY_TYPE g() const
Get green color.
Definition: Color.hpp:243
const Color none
No color (alpha = 0)
const Color lemonChiffon
const Color darkCyan
const Color fireBrick
const Color azure
const Color deepPink
const Color blueViolet
const Color lavender
const Color mediumSeaGreen
const Color lightYellow
const Color darkTurquoise
const Color papayaWhip
const Color darkViolet
const Color darkMagenta
const Color lightSalmon
const Color grey
const Color paleTurquoise
const Color aqua
const Color springGreen
const Color lightSlateGrey
const Color darkRed
const Color peachPuff
const Color greenYellow
bool operator!=(const etk::Color< MY_TYPE, MY_TYPE_SIZE > &_obj) const
Different comparaison operator.
Definition: Color.hpp:105
etk::Color< double, 4 > parseStringStartWithRGB(const std::string &_input)
Get a color value started with a "rgb()" keep in double.
const Color hotPink
const Color lightCoral
const Color darkSalmon
Color< MY_TYPE, MY_TYPE_SIZE > & operator=(const etk::Color< MY_TYPE, MY_TYPE_SIZE > &_input)
Asignemement operator.
Definition: Color.hpp:93
const Color black
const Color antiqueWhite
const Color aliceBlue
const Color darkorange
MY_TYPE b() const
Get blue color.
Definition: Color.hpp:254
const Color cyan
static const MY_TYPE defaultAlpha
Default alpha value.
Definition: Color.hpp:35
const Color olive
static const Color< MY_TYPE, MY_TYPE_SIZE > emptyColor
To auto fill with no data in all case.
Definition: Color.hpp:34
const Color maroon
etk::Color< uint8_t, 4 > parseStringStartWithRGBUnsigned8(const std::string &_input)
Get a color value started with a "rgb()" converted in uint6.
const Color green
const Color mediumTurquoise
const Color slateGrey
const Color coral
const Color peru
const Color mintCream
const Color lightPink
bool operator==(const etk::Color< MY_TYPE, MY_TYPE_SIZE > &_obj) const
Equality comparaison operator.
Definition: Color.hpp:119
const Color seaGreen
const Color darkSlateBlue
const Color deepSkyBlue
const Color turquoise
const Color red
const Color darkOrchid
const Color darkOliveGreen
const Color thistle
const Color paleVioletRed
const Color burlyWood
const Color yellow
const Color ivory
const Color lightBlue
const Color oldLace
const Color white
const Color beige
const Color honeyDew
const Color fuchsia
MY_TYPE r() const
Get red color.
Definition: Color.hpp:232
Color(MY_TYPE _r, MY_TYPE _g, MY_TYPE _b)
Contructor with request initialisation.
Definition: Color.hpp:59
The color class is a template to abstract the color implementation choice.
Definition: Color.hpp:32
const Color floralWhite
const Color darkSlateGray
etk::Color< uint8_t, 4 > parseStringStartWithRGBGen(const std::string &_input)
Get a color value started with a "rgb()" converted in uint8.
const Color slateGray
const Color cornsilk
const Color seaShell
Color(MY_TYPE _r, MY_TYPE _g)
Contructor with request initialisation.
Definition: Color.hpp:67
const Color bisque
const Color lightGrey
const Color brown
etk::Color< MY_TYPE, MY_TYPE_SIZE > & operator*=(const etk::Color< MY_TYPE, MY_TYPE_SIZE > &_obj)
Operator*= Multiply 2 color together.
Definition: Color.hpp:343
const Color lavenderBlush
etk::Color< uint8_t, 4 > parseStringStartWithSharp(const std::string &_input)
Get a color value started with a "#".
const Color sandyBrown
etk::Color< uint8_t, 4 > parseStringColorNamed(const std::string &_input)
Get a color value started with a "named" converted in uint8 like red, geen ...
const Color mediumAquaMarine
const Color mediumVioletRed
const Color snow
std::string getHexString() const
Convert the color in an hexedecimal string ("0xFEDCBA98")
Definition: Color.hpp:214
const Color darkSlateGrey
const Color orchid
Color(MY_TYPE _r, MY_TYPE _g, MY_TYPE _b, MY_TYPE _a)
Contructor with request initialisation.
Definition: Color.hpp:50
const Color lightSteelBlue
const Color paleGoldenRod
const Color orange
const Color mediumSpringGreen
const Color gainsboro
const Color blanchedAlmond
const Color skyBlue
void setG(MY_TYPE _g)
Set green color.
Definition: Color.hpp:285
const Color dimGrey
const Color saddleBrown