diff --git a/src/color.cpp b/src/color.cpp index 2dcbe76c9..c905bd869 100644 --- a/src/color.cpp +++ b/src/color.cpp @@ -24,18 +24,12 @@ #include #include #include - // agg #include "agg_color_rgba.h" #pragma GCC diagnostic push #include #include -#include -#include -#include -#include -#include #pragma GCC diagnostic pop // stl @@ -52,22 +46,23 @@ color::color(std::string const& str, bool premultiplied) std::string color::to_string() const { namespace karma = boost::spirit::karma; - boost::spirit::karma::_1_type _1; boost::spirit::karma::eps_type eps; boost::spirit::karma::double_type double_; - boost::spirit::karma::string_type kstring; - boost::spirit::karma::uint_generator color_generator; + boost::spirit::karma::uint_generator color_; std::string str; std::back_insert_iterator sink(str); - karma::generate(sink, + karma::generate(sink, eps(alpha() < 255) // begin grammar - kstring[ boost::phoenix::if_(alpha()==255) [_1="rgb("].else_[_1="rgba("]] - << color_generator[_1 = red()] << ',' - << color_generator[_1 = green()] << ',' - << color_generator[_1 = blue()] - << kstring[ boost::phoenix::if_(alpha()==255) [_1 = ')'].else_[_1 =',']] - << eps(alpha()<255) << double_ [_1 = alpha()/255.0] - << ')' + << "rgba(" + << color_(red()) << ',' + << color_(green()) << ',' + << color_(blue()) << ',' + << double_(alpha()/255.0) << ')' + | + "rgb(" + << color_(red()) << ',' + << color_(green()) << ',' + << color_(blue()) << ')' // end grammar ); return str; @@ -76,7 +71,6 @@ std::string color::to_string() const std::string color::to_hex_string() const { namespace karma = boost::spirit::karma; - boost::spirit::karma::_1_type _1; boost::spirit::karma::hex_type hex; boost::spirit::karma::eps_type eps; boost::spirit::karma::right_align_type right_align; @@ -85,10 +79,10 @@ std::string color::to_hex_string() const karma::generate(sink, // begin grammar '#' - << right_align(2,'0')[hex[_1 = red()]] - << right_align(2,'0')[hex[_1 = green()]] - << right_align(2,'0')[hex[_1 = blue()]] - << eps(alpha() < 255) << right_align(2,'0')[hex [_1 = alpha()]] + << right_align(2,'0')[hex(red())] + << right_align(2,'0')[hex(green())] + << right_align(2,'0')[hex(blue())] + << eps(alpha() < 255) << right_align(2,'0')[hex(alpha())] // end grammar ); return str;