Color.h 915 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. * Color.h, part of VCMI engine
  3. *
  4. * Authors: listed in file AUTHORS in main folder
  5. *
  6. * License: GNU General Public License v2.0 or later
  7. * Full text of license available in license.txt file, in main folder
  8. *
  9. */
  10. #pragma once
  11. VCMI_LIB_NAMESPACE_BEGIN
  12. /// An object that represents RGBA color
  13. class ColorRGBA
  14. {
  15. public:
  16. enum : uint8_t
  17. {
  18. ALPHA_OPAQUE = 255,
  19. ALPHA_TRANSPARENT = 0,
  20. };
  21. uint8_t r;
  22. uint8_t g;
  23. uint8_t b;
  24. uint8_t a;
  25. //constructors
  26. ColorRGBA()
  27. :r(0)
  28. ,g(0)
  29. ,b(0)
  30. ,a(0)
  31. {
  32. }
  33. ColorRGBA(uint8_t r, uint8_t g, uint8_t b, uint8_t a)
  34. : r(r)
  35. , g(g)
  36. , b(b)
  37. , a(a)
  38. {}
  39. ColorRGBA(uint8_t r, uint8_t g, uint8_t b)
  40. : r(r)
  41. , g(g)
  42. , b(b)
  43. , a(ALPHA_OPAQUE)
  44. {}
  45. template <typename Handler>
  46. void serialize(Handler &h, const int version)
  47. {
  48. h & r;
  49. h & g;
  50. h & b;
  51. h & a;
  52. }
  53. };
  54. VCMI_LIB_NAMESPACE_END