Advertisement
Guest User

Untitled

a guest
May 21st, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. #include <sstream>
  2.  
  3. #include "properties/color.h"
  4.  
  5. namespace touch {
  6.  
  7. Color::Color() {
  8. red = 0;
  9. green = 0;
  10. blue = 0;
  11. alpha = 0;
  12. }
  13.  
  14. Color::Color(const unsigned int red, const unsigned int green,
  15. const unsigned int blue) : Color(red, green, blue, 0) {}
  16.  
  17. Color::Color(const unsigned int red, const unsigned int green,
  18. const unsigned int blue, const unsigned int alpha) {
  19. SetRed(red);
  20. SetGreen(green);
  21. SetBlue(blue);
  22. SetAlpha(alpha);
  23. }
  24.  
  25. Color::Color(const Color &color) {
  26. Copy(color);
  27. }
  28.  
  29. unsigned int Color::GetRed() const {
  30. return red;
  31. }
  32.  
  33. unsigned int Color::GetGreen() const {
  34. return green;
  35. }
  36.  
  37. unsigned int Color::GetBlue() const {
  38. return blue;
  39. }
  40.  
  41. unsigned int Color::GetAlpha() const {
  42. return alpha;
  43. }
  44.  
  45. void Color::SetRed(const unsigned int red) {
  46. this->red = red & 0xFF;
  47. }
  48.  
  49. void Color::SetGreen(const unsigned int green) {
  50. this->green = green & 0xFF;
  51. }
  52.  
  53. void Color::SetBlue(const unsigned int blue) {
  54. this->blue = blue & 0xFF;
  55. }
  56.  
  57. void Color::SetAlpha(const unsigned int alpha) {
  58. this->alpha = alpha & 0xFF;
  59. }
  60.  
  61. void Color::Copy(const Color &color) {
  62. this->red = color.red;
  63. this->green = color.green;
  64. this->blue = color.blue;
  65. this->alpha = color.alpha;
  66. }
  67.  
  68. bool Color::IsVisible() const {
  69. return this->alpha != 0xFF;
  70. }
  71.  
  72. std::string Color::ToString() const {
  73. std::ostringstream stream;
  74. stream << "red: " << red
  75. << ", green: " << green
  76. << ", blue: " << blue
  77. << ", alpha: " << alpha
  78. << ", is_visible: " << IsVisible() ? "true" : "false";
  79. return stream.str();
  80. }
  81.  
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement