lots more color work, closer and closer to being ready for ... being taken apart again

This commit is contained in:
Paul Davis 2014-12-08 15:52:18 -05:00
parent e1c6f3bf6c
commit 624a86c39d
8 changed files with 136 additions and 116 deletions

View file

@ -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); }

View file

@ -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
{