Color.pkg 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. $#include "Color.h"
  2. /// RGBA color.
  3. class Color
  4. {
  5. public:
  6. /// Construct with default values (opaque white.)
  7. Color();
  8. /// Copy-construct from another color.
  9. Color(const Color& color);
  10. /// Construct from another color and modify the alpha.
  11. Color(const Color& color, float a);
  12. /// Construct from RGB values and set alpha fully opaque.
  13. Color(float r, float g, float b);
  14. /// Construct from RGBA values.
  15. Color(float r, float g, float b, float a);
  16. /// Test for equality with another color.
  17. bool operator == (const Color& rhs) const;
  18. /// Multiply with a scalar.
  19. Color operator * (float rhs) const;
  20. /// Add a color.
  21. Color operator + (const Color& rhs) const;
  22. /// Return RGB values as a Vector3.
  23. Vector3 RGBValues() const;
  24. /// Return approximate intensity.
  25. float Intensity() const;
  26. /// Linear interpolation with another color.
  27. Color Lerp(const Color& rhs, float t) const;
  28. /// Return color packed to a 32-bit integer. Components are clamped to [0, 1] range.
  29. unsigned ToUInt() const;
  30. /// Return as a four-dimensional vector.
  31. Vector4 ToVector4() const;
  32. /// Red value.
  33. float r_ @ r;
  34. /// Green value.
  35. float g_ @ g;
  36. /// Blue value.
  37. float b_ @ b;
  38. /// Alpha value.
  39. float a_ @ a;
  40. /// Opaque white color.
  41. static const Color WHITE;
  42. /// Opaque yellow color.
  43. static const Color YELLOW;
  44. /// Opaque red color.
  45. static const Color RED;
  46. /// Opaque green color.
  47. static const Color GREEN;
  48. /// Opaque green color.
  49. static const Color BLUE;
  50. /// Opaque black color.
  51. static const Color BLACK;
  52. /// Transparent color (black with no alpha).
  53. static const Color TRANSPARENT;
  54. };