Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <sstream>
- #include "properties/color.h"
- namespace touch {
- Color::Color() {
- red = 0;
- green = 0;
- blue = 0;
- alpha = 0;
- }
- Color::Color(const unsigned int red, const unsigned int green,
- const unsigned int blue) : Color(red, green, blue, 0) {}
- Color::Color(const unsigned int red, const unsigned int green,
- const unsigned int blue, const unsigned int alpha) {
- SetRed(red);
- SetGreen(green);
- SetBlue(blue);
- SetAlpha(alpha);
- }
- Color::Color(const Color &color) {
- Copy(color);
- }
- unsigned int Color::GetRed() const {
- return red;
- }
- unsigned int Color::GetGreen() const {
- return green;
- }
- unsigned int Color::GetBlue() const {
- return blue;
- }
- unsigned int Color::GetAlpha() const {
- return alpha;
- }
- void Color::SetRed(const unsigned int red) {
- this->red = red & 0xFF;
- }
- void Color::SetGreen(const unsigned int green) {
- this->green = green & 0xFF;
- }
- void Color::SetBlue(const unsigned int blue) {
- this->blue = blue & 0xFF;
- }
- void Color::SetAlpha(const unsigned int alpha) {
- this->alpha = alpha & 0xFF;
- }
- void Color::Copy(const Color &color) {
- this->red = color.red;
- this->green = color.green;
- this->blue = color.blue;
- this->alpha = color.alpha;
- }
- bool Color::IsVisible() const {
- return this->alpha != 0xFF;
- }
- std::string Color::ToString() const {
- std::ostringstream stream;
- stream << "red: " << red
- << ", green: " << green
- << ", blue: " << blue
- << ", alpha: " << alpha
- << ", is_visible: " << IsVisible() ? "true" : "false";
- return stream.str();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement