svg renderer - render gradient with only one color-stop as solid color fill/stroke [WIP]
This commit is contained in:
parent
ffb6db7b4d
commit
7819ca7bd3
1 changed files with 61 additions and 6 deletions
|
@ -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