fix color.cpp formatting

This commit is contained in:
Mathis Logemann 2022-01-28 10:37:38 +01:00
parent 779787f980
commit 9bf8fcc823

View file

@ -47,14 +47,22 @@ std::string color::to_string() const
boost::spirit::karma::uint_generator<uint8_t, 10> color_; boost::spirit::karma::uint_generator<uint8_t, 10> color_;
std::string str; std::string str;
std::back_insert_iterator<std::string> sink(str); std::back_insert_iterator<std::string> sink(str);
karma::generate(sink, // clang-format off
eps(alpha() < 255) karma::generate(sink, eps(alpha() < 255)
// begin grammar // begin grammar
<< "rgba(" << color_(red()) << ',' << color_(green()) << ',' << color_(blue()) << ',' << "rgba("
<< double_(alpha() / 255.0) << ')' | << color_(red()) << ','
"rgb(" << color_(red()) << ',' << color_(green()) << ',' << color_(blue()) << ')' << color_(green()) << ','
<< color_(blue()) << ','
<< double_(alpha() / 255.0) << ')'
|
"rgb("
<< color_(red()) << ','
<< color_(green()) << ','
<< color_(blue()) << ')'
// end grammar // end grammar
); );
// clang-format on
return str; return str;
} }
@ -66,12 +74,17 @@ std::string color::to_hex_string() const
boost::spirit::karma::right_align_type right_align; boost::spirit::karma::right_align_type right_align;
std::string str; std::string str;
std::back_insert_iterator<std::string> sink(str); std::back_insert_iterator<std::string> sink(str);
// clang-format off
karma::generate(sink, karma::generate(sink,
// begin grammar // begin grammar
'#' << 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())] << 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 // end grammar
); );
// clang-format on
return str; return str;
} }