Compare commits
5 commits
master
...
svg-render
Author | SHA1 | Date | |
---|---|---|---|
|
46f8a1e0df | ||
|
c85fb5a319 | ||
|
6666d5f540 | ||
|
7819ca7bd3 | ||
|
ffb6db7b4d |
2 changed files with 75 additions and 18 deletions
|
@ -52,6 +52,7 @@ namespace x3 = boost::spirit::x3;
|
||||||
namespace css_color_grammar {
|
namespace css_color_grammar {
|
||||||
|
|
||||||
using x3::lit;
|
using x3::lit;
|
||||||
|
using x3::float_;
|
||||||
using x3::uint_parser;
|
using x3::uint_parser;
|
||||||
using x3::hex;
|
using x3::hex;
|
||||||
using x3::symbols;
|
using x3::symbols;
|
||||||
|
@ -223,6 +224,7 @@ x3::uint_parser<std::uint8_t, 16, 2, 2> hex2;
|
||||||
x3::uint_parser<std::uint8_t, 16, 1, 1> hex1;
|
x3::uint_parser<std::uint8_t, 16, 1, 1> hex1;
|
||||||
x3::uint_parser<std::uint16_t, 10, 1, 3> dec3;
|
x3::uint_parser<std::uint16_t, 10, 1, 3> dec3;
|
||||||
|
|
||||||
|
|
||||||
// rules
|
// rules
|
||||||
x3::rule<class hex2_color, color> const hex2_color("hex2_color");
|
x3::rule<class hex2_color, color> const hex2_color("hex2_color");
|
||||||
x3::rule<class hex1_color, color> const hex1_color("hex1_color");
|
x3::rule<class hex1_color, color> const hex1_color("hex1_color");
|
||||||
|
@ -367,32 +369,32 @@ auto const hex1_color_def = no_skip[lit('#')
|
||||||
>> hex1[hex1_blue]
|
>> hex1[hex1_blue]
|
||||||
>> (hex1[hex1_opacity] | attr(15)[hex1_opacity])];
|
>> (hex1[hex1_opacity] | attr(15)[hex1_opacity])];
|
||||||
|
|
||||||
auto const rgb_color_def = lit("rgb")
|
auto const rgb_color_def = no_case["rgb"]
|
||||||
>> lit('(') >> dec3[dec_red]
|
>> lit('(') >> dec3[dec_red]
|
||||||
>> lit(',') >> dec3[dec_green]
|
>> lit(',') >> dec3[dec_green]
|
||||||
>> lit(',') >> dec3[dec_blue]
|
>> lit(',') >> dec3[dec_blue]
|
||||||
>> attr(255) >> lit(')');
|
>> attr(255) >> lit(')');
|
||||||
|
|
||||||
auto const rgb_color_percent_def = lit("rgb")
|
auto const rgb_color_percent_def = no_case["rgb"]
|
||||||
>> lit('(') >> dec3[percent_red] >> lit('%')
|
>> lit('(') >> float_[percent_red] >> lit('%')
|
||||||
>> lit(',') >> dec3[percent_green] >> lit('%')
|
>> lit(',') >> float_[percent_green] >> lit('%')
|
||||||
>> lit(',') >> dec3[percent_blue] >> lit('%')
|
>> lit(',') >> float_[percent_blue] >> lit('%')
|
||||||
>> attr(255) >> lit(')');
|
>> attr(255) >> lit(')');
|
||||||
|
|
||||||
auto const rgba_color_def = lit("rgba")
|
auto const rgba_color_def = no_case["rgba"]
|
||||||
>> lit('(') >> dec3[dec_red]
|
>> lit('(') >> dec3[dec_red]
|
||||||
>> lit(',') >> dec3[dec_green]
|
>> lit(',') >> dec3[dec_green]
|
||||||
>> lit(',') >> dec3[dec_blue]
|
>> lit(',') >> dec3[dec_blue]
|
||||||
>> lit(',') >> double_[opacity] >> lit(')');
|
>> lit(',') >> double_[opacity] >> lit(')');
|
||||||
|
|
||||||
auto const rgba_color_percent_def = lit("rgba")
|
auto const rgba_color_percent_def = no_case["rgba"]
|
||||||
>> lit('(') >> dec3[percent_red] >> lit('%')
|
>> lit('(') >> float_[percent_red] >> lit('%')
|
||||||
>> lit(',') >> dec3[percent_green] >> lit('%')
|
>> lit(',') >> float_[percent_green] >> lit('%')
|
||||||
>> lit(',') >> dec3[percent_blue] >> lit('%')
|
>> lit(',') >> float_[percent_blue] >> lit('%')
|
||||||
>> lit(',') >> double_[opacity] >> lit(')');
|
>> lit(',') >> double_[opacity] >> lit(')');
|
||||||
|
|
||||||
auto const hsl_values = x3::rule<class hsl_values, std::tuple<std::uint16_t,std::uint8_t,std::uint8_t, double >> {} =
|
auto const hsl_values = x3::rule<class hsl_values, std::tuple<std::uint16_t,std::uint8_t,std::uint8_t, double >> {} =
|
||||||
lit("hsl")
|
no_case["hsl"]
|
||||||
>> lit('(') >> dec3
|
>> lit('(') >> dec3
|
||||||
>> lit(',') >> dec3 >> lit('%')
|
>> lit(',') >> dec3 >> lit('%')
|
||||||
>> lit(',') >> dec3 >> lit('%')
|
>> lit(',') >> dec3 >> lit('%')
|
||||||
|
@ -400,7 +402,7 @@ auto const hsl_values = x3::rule<class hsl_values, std::tuple<std::uint16_t,std:
|
||||||
;
|
;
|
||||||
|
|
||||||
auto const hsla_values = x3::rule<class hsla_values, std::tuple<std::uint16_t,std::uint8_t,std::uint8_t, double >> {} =
|
auto const hsla_values = x3::rule<class hsla_values, std::tuple<std::uint16_t,std::uint8_t,std::uint8_t, double >> {} =
|
||||||
lit("hsla")
|
no_case["hsla"]
|
||||||
>> lit('(') >> dec3
|
>> lit('(') >> dec3
|
||||||
>> lit(',') >> dec3 >> lit('%')
|
>> lit(',') >> dec3 >> lit('%')
|
||||||
>> lit(',') >> dec3 >> lit('%')
|
>> lit(',') >> dec3 >> lit('%')
|
||||||
|
|
|
@ -163,6 +163,7 @@ public:
|
||||||
unsigned g = stop_color.green();
|
unsigned g = stop_color.green();
|
||||||
unsigned b = stop_color.blue();
|
unsigned b = stop_color.blue();
|
||||||
unsigned a = stop_color.alpha();
|
unsigned a = stop_color.alpha();
|
||||||
|
std::cerr << "stop offset:" << st.first << std::endl;
|
||||||
m_gradient_lut.add_color(st.first, agg::rgba8_pre(r, g, b, int(a * opacity)));
|
m_gradient_lut.add_color(st.first, agg::rgba8_pre(r, g, b, int(a * opacity)));
|
||||||
}
|
}
|
||||||
if (m_gradient_lut.build_lut())
|
if (m_gradient_lut.build_lut())
|
||||||
|
@ -227,6 +228,8 @@ public:
|
||||||
interpolator_type,
|
interpolator_type,
|
||||||
gradient_adaptor_type,
|
gradient_adaptor_type,
|
||||||
color_func_type>;
|
color_func_type>;
|
||||||
|
|
||||||
|
std::cerr << x1 <<"," << y1 << "," << x2 << "," << y2 << std::endl;
|
||||||
// scale everything up since agg turns things into integers a bit too soon
|
// scale everything up since agg turns things into integers a bit too soon
|
||||||
int scaleup=255;
|
int scaleup=255;
|
||||||
x1 *= scaleup;
|
x1 *= scaleup;
|
||||||
|
@ -300,8 +303,25 @@ public:
|
||||||
|
|
||||||
if(attr.fill_gradient.get_gradient_type() != NO_GRADIENT)
|
if(attr.fill_gradient.get_gradient_type() != NO_GRADIENT)
|
||||||
{
|
{
|
||||||
render_gradient(ras, sl, ren, attr.fill_gradient, transform,
|
std::size_t size = attr.fill_gradient.get_stop_array().size();
|
||||||
attr.fill_opacity * attr.opacity * opacity, symbol_bbox, curved_trans, attr.index);
|
if (size == 1)
|
||||||
|
{
|
||||||
|
auto const& stop = attr.fill_gradient.get_stop_array()[0];
|
||||||
|
mapnik::color const& stop_color = stop.second;
|
||||||
|
unsigned r = stop_color.red();
|
||||||
|
unsigned g = stop_color.green();
|
||||||
|
unsigned b = stop_color.blue();
|
||||||
|
unsigned a = stop_color.alpha();
|
||||||
|
color = agg::rgba8_pre(r, g, b, a);
|
||||||
|
ScanlineRenderer ren_s(ren);
|
||||||
|
ren_s.color(color);
|
||||||
|
render_scanlines(ras, sl, ren_s);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
render_gradient(ras, sl, ren, attr.fill_gradient, transform,
|
||||||
|
attr.fill_opacity * attr.opacity * opacity, symbol_bbox, curved_trans, attr.index);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -343,8 +363,26 @@ public:
|
||||||
ras.add_path(curved_dashed_stroked_trans, attr.index);
|
ras.add_path(curved_dashed_stroked_trans, attr.index);
|
||||||
if (attr.stroke_gradient.get_gradient_type() != NO_GRADIENT)
|
if (attr.stroke_gradient.get_gradient_type() != NO_GRADIENT)
|
||||||
{
|
{
|
||||||
render_gradient(ras, sl, ren, attr.stroke_gradient, transform,
|
std::size_t size = attr.stroke_gradient.get_stop_array().size();
|
||||||
attr.stroke_opacity * attr.opacity * opacity, symbol_bbox, curved_trans, attr.index);
|
if (size == 1)
|
||||||
|
{
|
||||||
|
auto const& stop = attr.stroke_gradient.get_stop_array()[0];
|
||||||
|
mapnik::color const& stop_color = stop.second;
|
||||||
|
unsigned r = stop_color.red();
|
||||||
|
unsigned g = stop_color.green();
|
||||||
|
unsigned b = stop_color.blue();
|
||||||
|
unsigned a = stop_color.alpha();
|
||||||
|
color = agg::rgba8_pre(r, g, b, a);
|
||||||
|
ScanlineRenderer ren_s(ren);
|
||||||
|
ren_s.color(color);
|
||||||
|
render_scanlines(ras, sl, ren_s);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
render_gradient(ras, sl, ren, attr.stroke_gradient, transform,
|
||||||
|
attr.stroke_opacity * attr.opacity * opacity, symbol_bbox, curved_trans, attr.index);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -377,8 +415,25 @@ public:
|
||||||
ras.add_path(curved_stroked_trans, attr.index);
|
ras.add_path(curved_stroked_trans, attr.index);
|
||||||
if (attr.stroke_gradient.get_gradient_type() != NO_GRADIENT)
|
if (attr.stroke_gradient.get_gradient_type() != NO_GRADIENT)
|
||||||
{
|
{
|
||||||
render_gradient(ras, sl, ren, attr.stroke_gradient, transform,
|
std::size_t size = attr.stroke_gradient.get_stop_array().size();
|
||||||
attr.stroke_opacity * attr.opacity * opacity, symbol_bbox, curved_trans, attr.index);
|
if (size == 1)
|
||||||
|
{
|
||||||
|
auto const& stop = attr.stroke_gradient.get_stop_array()[0];
|
||||||
|
mapnik::color const& stop_color = stop.second;
|
||||||
|
unsigned r = stop_color.red();
|
||||||
|
unsigned g = stop_color.green();
|
||||||
|
unsigned b = stop_color.blue();
|
||||||
|
unsigned a = stop_color.alpha();
|
||||||
|
color = agg::rgba8_pre(r, g, b, a);
|
||||||
|
ScanlineRenderer ren_s(ren);
|
||||||
|
ren_s.color(color);
|
||||||
|
render_scanlines(ras, sl, ren_s);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
render_gradient(ras, sl, ren, attr.stroke_gradient, transform,
|
||||||
|
attr.stroke_opacity * attr.opacity * opacity, symbol_bbox, curved_trans, attr.index);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue