+ image-filters: add colorize-alpha filter
This commit is contained in:
parent
b1233d533f
commit
cbc809ddf5
3 changed files with 30 additions and 6 deletions
|
@ -25,10 +25,12 @@
|
|||
|
||||
// boost
|
||||
#include <boost/spirit/include/qi.hpp>
|
||||
|
||||
// mapnik
|
||||
#include <mapnik/css_color_grammar.hpp>
|
||||
// stl
|
||||
#include <vector>
|
||||
|
||||
|
||||
namespace mapnik {
|
||||
|
||||
namespace qi = boost::spirit::qi;
|
||||
|
@ -42,9 +44,11 @@ struct image_filter_grammar :
|
|||
qi::rule<Iterator, ContType(), qi::ascii::space_type> filter;
|
||||
qi::rule<Iterator, qi::locals<int,int>, void(ContType&), qi::ascii::space_type> agg_blur_filter;
|
||||
qi::rule<Iterator, qi::locals<std::string>, void(ContType&), qi::ascii::space_type> hsla_filter;
|
||||
qi::rule<Iterator, std::string(), qi::ascii::space_type> string_arg;
|
||||
qi::rule<Iterator, qi::locals<mapnik::color,mapnik::color>, void(ContType&), qi::ascii::space_type> colorize_alpha_filter;
|
||||
qi::rule<Iterator, std::string(char), qi::ascii::space_type> string_arg;
|
||||
qi::rule<Iterator, qi::ascii::space_type> no_args;
|
||||
qi::uint_parser< unsigned, 10, 1, 3 > radius_;
|
||||
css_color_grammar<Iterator> css_color_;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
// mapnik
|
||||
#include <mapnik/config.hpp>
|
||||
|
||||
#include <mapnik/color.hpp>
|
||||
// boost
|
||||
#include <boost/variant/variant_fwd.hpp>
|
||||
|
||||
|
@ -61,6 +61,16 @@ struct hsla
|
|||
std::string tinter;
|
||||
};
|
||||
|
||||
|
||||
|
||||
struct colorize_alpha
|
||||
{
|
||||
colorize_alpha(mapnik::color const& c0, mapnik::color const& c1)
|
||||
{
|
||||
//do work
|
||||
}
|
||||
};
|
||||
|
||||
typedef boost::variant<filter::blur,
|
||||
filter::gray,
|
||||
filter::agg_stack_blur,
|
||||
|
@ -71,7 +81,8 @@ typedef boost::variant<filter::blur,
|
|||
filter::x_gradient,
|
||||
filter::y_gradient,
|
||||
filter::invert,
|
||||
filter::hsla> filter_type;
|
||||
filter::hsla,
|
||||
filter::colorize_alpha> filter_type;
|
||||
|
||||
inline std::ostream& operator<< (std::ostream& os, blur)
|
||||
{
|
||||
|
|
|
@ -83,6 +83,8 @@ image_filter_grammar<Iterator,ContType>::image_filter_grammar()
|
|||
agg_blur_filter(_val)
|
||||
|
|
||||
hsla_filter(_val)
|
||||
|
|
||||
colorize_alpha_filter(_val)
|
||||
;
|
||||
|
||||
agg_blur_filter = lit("agg-stack-blur")[_a = 1, _b = 1]
|
||||
|
@ -92,11 +94,18 @@ image_filter_grammar<Iterator,ContType>::image_filter_grammar()
|
|||
[push_back(_r1,construct<mapnik::filter::agg_stack_blur>(_a,_b))]
|
||||
;
|
||||
|
||||
hsla_filter = (lit("hsla") >> lit('(') >> string_arg[_a = _1] >> lit(')'))
|
||||
hsla_filter = lit("hsla") >> lit('(') >> string_arg(')')[_a = _1] >> lit(')')
|
||||
[push_back(_r1,construct<mapnik::filter::hsla>(_a))]
|
||||
;
|
||||
|
||||
string_arg = +~char_(')');
|
||||
colorize_alpha_filter = lit("colorize-alpha")
|
||||
>> lit('(')
|
||||
>> css_color_[_a = _1] >> lit(',')
|
||||
>> css_color_[_b = _1] >> lit(')')
|
||||
[push_back(_r1,construct<mapnik::filter::colorize_alpha>(_a,_b))]
|
||||
;
|
||||
|
||||
string_arg = + (char_ - lit(_r1));
|
||||
no_args = -(lit('(') >> lit(')'));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue