fix handling of opacity when rendering svg with cairo - closes #1943
This commit is contained in:
parent
4bc28d547b
commit
63a06a9aab
9 changed files with 106 additions and 7 deletions
|
@ -568,14 +568,14 @@ void render_vector_marker(cairo_context & context, pixel_position const& pos, ma
|
|||
}
|
||||
if(attr.fill_gradient.get_gradient_type() != NO_GRADIENT)
|
||||
{
|
||||
cairo_gradient g(attr.fill_gradient,attr.fill_opacity*opacity);
|
||||
cairo_gradient g(attr.fill_gradient,attr.fill_opacity * attr.opacity * opacity);
|
||||
|
||||
context.set_gradient(g,bbox);
|
||||
context.fill();
|
||||
}
|
||||
else if(attr.fill_flag)
|
||||
{
|
||||
double fill_opacity = attr.fill_opacity * opacity * attr.fill_color.opacity();
|
||||
double fill_opacity = attr.fill_opacity * attr.opacity * opacity * attr.fill_color.opacity();
|
||||
context.set_color(attr.fill_color.r/255.0,attr.fill_color.g/255.0,
|
||||
attr.fill_color.b/255.0, fill_opacity);
|
||||
context.fill();
|
||||
|
@ -591,13 +591,13 @@ void render_vector_marker(cairo_context & context, pixel_position const& pos, ma
|
|||
context.set_line_cap(line_cap_enum(attr.line_cap));
|
||||
context.set_line_join(line_join_enum(attr.line_join));
|
||||
context.set_miter_limit(attr.miter_limit);
|
||||
cairo_gradient g(attr.stroke_gradient,attr.fill_opacity*opacity);
|
||||
cairo_gradient g(attr.stroke_gradient,attr.fill_opacity * attr.opacity * opacity);
|
||||
context.set_gradient(g,bbox);
|
||||
context.stroke();
|
||||
}
|
||||
else if (attr.stroke_flag)
|
||||
{
|
||||
double stroke_opacity = attr.stroke_opacity * opacity * attr.stroke_color.opacity();
|
||||
double stroke_opacity = attr.stroke_opacity * attr.opacity * opacity * attr.stroke_color.opacity();
|
||||
context.set_color(attr.stroke_color.r/255.0,attr.stroke_color.g/255.0,
|
||||
attr.stroke_color.b/255.0, stroke_opacity);
|
||||
context.set_line_width(attr.stroke_width);
|
||||
|
|
25
tests/data/svg/box.svg
Normal file
25
tests/data/svg/box.svg
Normal file
|
@ -0,0 +1,25 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
version="1.1"
|
||||
width="10"
|
||||
height="9.9999971"
|
||||
id="svg6102">
|
||||
<g
|
||||
transform="translate(-240,-532.36218)"
|
||||
id="layer1">
|
||||
<rect
|
||||
width="10"
|
||||
height="9.9999971"
|
||||
x="240"
|
||||
y="532.36218"
|
||||
id="rect6613"
|
||||
style="opacity:0.5;color:#000000;fill:#00ccff;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1px;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 823 B |
|
@ -0,0 +1,34 @@
|
|||
{
|
||||
"keys": [
|
||||
"",
|
||||
"1"
|
||||
],
|
||||
"data": {},
|
||||
"grid": [
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" !! ",
|
||||
" !! ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" "
|
||||
]
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 145 B |
Binary file not shown.
After Width: | Height: | Size: 145 B |
Binary file not shown.
After Width: | Height: | Size: 151 B |
Binary file not shown.
After Width: | Height: | Size: 151 B |
42
tests/visual_tests/styles/marker-svg-opacity2.xml
Normal file
42
tests/visual_tests/styles/marker-svg-opacity2.xml
Normal file
|
@ -0,0 +1,42 @@
|
|||
<Map srs="+init=epsg:4326" background-color="black">
|
||||
|
||||
<Style name="svg">
|
||||
<Rule>
|
||||
<MarkersSymbolizer file="../../data/svg/box.svg"/>
|
||||
</Rule>
|
||||
</Style>
|
||||
|
||||
<Layer name="svg" srs="+init=epsg:4326">
|
||||
<StyleName>svg</StyleName>
|
||||
<Datasource>
|
||||
<Parameter name="type">csv</Parameter>
|
||||
<Parameter name="inline">
|
||||
x,y
|
||||
2.5,2.5
|
||||
</Parameter>
|
||||
</Datasource>
|
||||
</Layer>
|
||||
|
||||
<!-- points to frame data view -->
|
||||
|
||||
<Style name="frame">
|
||||
<Rule>
|
||||
<PointSymbolizer />
|
||||
</Rule>
|
||||
</Style>
|
||||
|
||||
<Layer name="frame" srs="+init=epsg:4326">
|
||||
<StyleName>frame</StyleName>
|
||||
<Datasource>
|
||||
<Parameter name="type">csv</Parameter>
|
||||
<Parameter name="inline">
|
||||
x,y
|
||||
0,0
|
||||
5,0
|
||||
0,5
|
||||
5,5
|
||||
</Parameter>
|
||||
</Datasource>
|
||||
</Layer>
|
||||
|
||||
</Map>
|
|
@ -85,15 +85,13 @@ files = {
|
|||
'lines-1': {'sizes': sizes_few_square,'bbox':default_text_box},
|
||||
'lines-2': {'sizes': sizes_few_square,'bbox':default_text_box},
|
||||
'lines-3': {'sizes': sizes_few_square,'bbox':default_text_box},
|
||||
# https://github.com/mapnik/mapnik/issues/1696
|
||||
# https://github.com/mapnik/mapnik/issues/1521
|
||||
# fails with clang++ on os x
|
||||
'lines-shield': {'sizes': sizes_few_square,'bbox':default_text_box},
|
||||
'collision': {'sizes':[(600,400)]},
|
||||
'shield-on-polygon': {'sizes':[(600,400)]},
|
||||
'shield-on-line-spacing-eq-width': {'sizes':[(600,400)]},
|
||||
'geometry-transform-translate': {'sizes':[(200,200)]},
|
||||
'marker-svg-opacity':{},
|
||||
'marker-svg-opacity2':{},
|
||||
'marker-multi-policy': {'sizes':[(600,400)]},
|
||||
'marker-on-line': {'sizes':[(600,400)],
|
||||
'bbox': mapnik.Box2d(-10, 0, 15, 20)},
|
||||
|
|
Loading…
Add table
Reference in a new issue