diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2014-12-08 15:52:18 -0500 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2014-12-08 22:02:38 -0500 |
commit | 624a86c39d0a22439c797d88c6defe28e55ab806 (patch) | |
tree | 4e33ac2ac9e63f5fdf5a0000cc17b352924d8232 /libs/canvas | |
parent | e1c6f3bf6ca32503dadd4a8fe431a1a7a47f64a1 (diff) |
lots more color work, closer and closer to being ready for ... being taken apart again
Diffstat (limited to 'libs/canvas')
-rw-r--r-- | libs/canvas/canvas/colors.h | 4 | ||||
-rw-r--r-- | libs/canvas/colors.cc | 21 |
2 files changed, 24 insertions, 1 deletions
diff --git a/libs/canvas/canvas/colors.h b/libs/canvas/canvas/colors.h index 5e13c5ca96..28fc2c079b 100644 --- a/libs/canvas/canvas/colors.h +++ b/libs/canvas/canvas/colors.h @@ -44,12 +44,14 @@ struct LIBCANVAS_API HSV HSV (); HSV (double h, double s, double v, double a = 1.0); HSV (Color); - + HSV (const std::string&); + double h; double s; double v; double a; + std::string to_string() const; bool is_gray() const; Color color() const { return hsva_to_color (h,s, v, a); } diff --git a/libs/canvas/colors.cc b/libs/canvas/colors.cc index fc1bf47457..76b51d584f 100644 --- a/libs/canvas/colors.cc +++ b/libs/canvas/colors.cc @@ -17,6 +17,7 @@ */ #include <algorithm> +#include <sstream> #include <cmath> #include <stdint.h> #include <cfloat> @@ -236,6 +237,26 @@ HSV::HSV (Color c) color_to_hsva (c, h, s, v, a); } +HSV::HSV (const std::string& str) +{ + stringstream ss (str); + ss >> h; + ss >> s; + ss >> v; + ss >> a; +} + +string +HSV::to_string () const +{ + stringstream ss; + ss << h << ' '; + ss << s << ' '; + ss << v << ' '; + ss << a; + return ss.str(); +} + bool HSV::is_gray () const { |