Merge branch 'master' of github.com:mapnik/mapnik

This commit is contained in:
Dane Springmeyer 2013-02-27 19:18:52 -05:00
commit 0404f17f27
3 changed files with 50 additions and 13 deletions

View file

@ -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;
@ -41,10 +43,12 @@ struct image_filter_grammar :
qi::rule<Iterator, ContType(), qi::ascii::space_type> start;
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<double,double,double,double,double,double,double,double>,
void(ContType&), qi::ascii::space_type> hsla_filter;
qi::rule<Iterator, qi::locals<mapnik::color,mapnik::color>, void(ContType&), qi::ascii::space_type> colorize_alpha_filter;
qi::rule<Iterator, qi::ascii::space_type> no_args;
qi::uint_parser< unsigned, 10, 1, 3 > radius_;
css_color_grammar<Iterator> css_color_;
};
}

View file

@ -25,10 +25,10 @@
// mapnik
#include <mapnik/config.hpp>
#include <mapnik/color.hpp>
// boost
#include <boost/variant.hpp>
#include <boost/variant/variant_fwd.hpp>
// stl
#include <vector>
#include <ostream>
@ -56,9 +56,21 @@ struct agg_stack_blur
struct hsla
{
hsla(std::string const& tint_string)
: tinter(tint_string) {}
std::string tinter;
hsla(double h0, double h1,
double s0, double s1,
double l0, double l1,
double a0, double a1)
{
// TODO: implement me!
}
};
struct colorize_alpha
{
colorize_alpha(mapnik::color const& c0, mapnik::color const& c1)
{
// TODO: implement me!
}
};
typedef boost::variant<filter::blur,
@ -71,7 +83,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)
{
@ -93,7 +106,7 @@ inline std::ostream& operator<< (std::ostream& os, agg_stack_blur const& filter)
inline std::ostream& operator<< (std::ostream& os, hsla const& filter)
{
os << "hsla(" << filter.tinter << ')';
os << "hsla(" << "TODO" << ')';
return os;
}

View file

@ -44,10 +44,17 @@ image_filter_grammar<Iterator,ContType>::image_filter_grammar()
using qi::_1;
using qi::_a;
using qi::_b;
using qi::_c;
using qi::_d;
using qi::_e;
using qi::_f;
using qi::_g;
using qi::_h;
using qi::_r1;
using qi::eps;
using qi::char_;
using qi::lexeme;
using qi::double_;
using boost::spirit::ascii::string;
using phoenix::push_back;
using phoenix::construct;
@ -83,6 +90,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 +101,22 @@ 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(')'))
[push_back(_r1,construct<mapnik::filter::hsla>(_a))]
hsla_filter = lit("hsla")
>> lit('(')
>> double_[_a = _1] >> lit('x') >> double_[_b = _1] >> lit(';')
>> double_[_c = _1] >> lit('x') >> double_[_d = _1] >> lit(';')
>> double_[_e = _1] >> lit('x') >> double_[_f = _1] >> lit(';')
>> double_[_g = _1] >> lit('x') >> double_[_h = _1] >> lit(')')
[push_back(_r1, construct<mapnik::filter::hsla>(_a,_b,_c,_d,_e,_f,_g,_h))]
;
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_(')');
no_args = -(lit('(') >> lit(')'));
}