Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: m3Dpi MQTT-Thermostat-example Final_project_Tran Final_project_Tran ... more
Diff: Color.cpp
- Revision:
- 2:ed46f45e1d66
- Child:
- 4:a7a26506c62f
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Color.cpp Thu Oct 08 21:43:02 2015 +0000 @@ -0,0 +1,40 @@ + +#include "Color.h" + + +Color::Color(int red, int green, int blue){ + setColor(red, green, blue); +} + +Color::Color(float red, float green, float blue){ + setColor((int) red * 255.0f, (int) green * 255.0f, (int) blue * 255.0f); +} + +Color::Color(int color){ +// red = (color >> 16) & 0xFF; +// green = (color >> 8 ) & 0xFF; +// blue = (color >> 0 ) & 0xFF; + setColor((color >> 16) & 0xFF, (color >> 8) & 0xFF, color & 0xFF); +} + +int Color::getHex(){ + return ((red << 16) || (green << 8) || (blue << 0)); +} + +int Color::getRed(){ + return red; +} + +int Color::getGreen(){ + return green; +} + +int Color::getBlue(){ + return blue; +} + +void Color::setColor(int red, int green, int blue){ + this->red = red; + this->green = green; + this->blue = blue; +} \ No newline at end of file