touchups to hsla work
This commit is contained in:
commit
04199e2a94
5 changed files with 31 additions and 14 deletions
|
@ -449,11 +449,11 @@ void apply_filter(Src & src, hsla const& op)
|
|||
double s2 = tint.s0 + (s * (tint.s1 - tint.s0));
|
||||
double l2 = tint.l0 + (l * (tint.l1 - tint.l0));
|
||||
if (h2 > 1) h2 = 1;
|
||||
if (h2 < 0) h2 = 0;
|
||||
else if (h2 < 0) h2 = 0;
|
||||
if (s2 > 1) s2 = 1;
|
||||
if (s2 < 0) s2 = 0;
|
||||
else if (s2 < 0) s2 = 0;
|
||||
if (l2 > 1) l2 = 1;
|
||||
if (l2 < 0) l2 = 0;
|
||||
else if (l2 < 0) l2 = 0;
|
||||
hsl2rgb(h2,s2,l2,r,g,b);
|
||||
// premultiply
|
||||
// we only work with premultiplied source,
|
||||
|
|
|
@ -39,7 +39,10 @@ struct image_filter_grammar :
|
|||
{
|
||||
image_filter_grammar();
|
||||
qi::rule<Iterator, ContType(), qi::ascii::space_type> start;
|
||||
qi::rule<Iterator, ContType(), qi::locals<int,int>, qi::ascii::space_type> filter;
|
||||
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::uint_parser< unsigned, 10, 1, 3 > radius_;
|
||||
};
|
||||
|
||||
|
|
|
@ -30,7 +30,6 @@
|
|||
#include <boost/variant/variant_fwd.hpp>
|
||||
|
||||
// stl
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <ostream>
|
||||
#include <iterator> // for std::back_insert_iterator
|
||||
|
@ -71,7 +70,8 @@ typedef boost::variant<filter::blur,
|
|||
filter::sobel,
|
||||
filter::x_gradient,
|
||||
filter::y_gradient,
|
||||
filter::invert> filter_type;
|
||||
filter::invert,
|
||||
filter::hsla> filter_type;
|
||||
|
||||
inline std::ostream& operator<< (std::ostream& os, blur)
|
||||
{
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2012 Artem Pavlenko
|
||||
* Copyright (C) 2013 Artem Pavlenko
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
|
@ -44,8 +44,11 @@ image_filter_grammar<Iterator,ContType>::image_filter_grammar()
|
|||
using qi::_1;
|
||||
using qi::_a;
|
||||
using qi::_b;
|
||||
using qi::_r1;
|
||||
using qi::eps;
|
||||
using qi::char_;
|
||||
using qi::lexeme;
|
||||
using boost::spirit::ascii::string;
|
||||
using phoenix::push_back;
|
||||
using phoenix::construct;
|
||||
|
||||
|
@ -75,15 +78,26 @@ image_filter_grammar<Iterator,ContType>::image_filter_grammar()
|
|||
|
|
||||
lit("y-gradient")[push_back(_val,construct<mapnik::filter::y_gradient>())]
|
||||
|
|
||||
(lit("agg-stack-blur")[_a = 1, _b = 1]
|
||||
lit("invert")[push_back(_val,construct<mapnik::filter::invert>())]
|
||||
|
|
||||
agg_blur_filter(_val)
|
||||
|
|
||||
hsla_filter(_val)
|
||||
;
|
||||
|
||||
agg_blur_filter = (lit("agg-stack-blur")[_a = 1, _b = 1]
|
||||
>> -( lit('(') >> radius_[_a = _1]
|
||||
>> lit(',')
|
||||
>> radius_[_b = _1]
|
||||
>> lit(')'))
|
||||
[push_back(_val,construct<mapnik::filter::agg_stack_blur>(_a,_b))])
|
||||
|
|
||||
lit("invert")[push_back(_val,construct<mapnik::filter::invert>())]
|
||||
>> lit(')')))
|
||||
[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))]
|
||||
;
|
||||
|
||||
string_arg = +~char_(')');
|
||||
}
|
||||
|
||||
template struct mapnik::image_filter_grammar<std::string::const_iterator,std::vector<mapnik::filter::filter_type> >;
|
||||
|
|
Loading…
Reference in a new issue