-
Notifications
You must be signed in to change notification settings - Fork 80
Description
At least since 2014, when I learned about Gadfly.jl, using transparent (i.e. alpha != 1.0) strokes and fills breaks the SVG context (i.e. stroke-opacity and fill-opacity). Is this a known issue or desired behavior?
Lines 608 to 615 in e08b5ca
| function print_property(img::SVG, property::StrokePrimitive) | |
| if property.color.alpha != 1.0 | |
| @printf(img.out, " stroke=\"%s\" stroke-opacity=\"%0.3f\"", | |
| svg_fmt_color(color(property.color)), property.color.alpha) | |
| else | |
| @printf(img.out, " stroke=\"%s\"", svg_fmt_color(color(property.color))) | |
| end | |
| end |
Lines 617 to 624 in e08b5ca
| function print_property(img::SVG, property::FillPrimitive) | |
| if property.color.alpha != 1.0 | |
| @printf(img.out, " fill=\"%s\" fill-opacity=\"%0.3f\"", | |
| svg_fmt_color(color(property.color)), property.color.alpha) | |
| else | |
| @printf(img.out, " fill=\"%s\"", svg_fmt_color(color(property.color))) | |
| end | |
| end |
Of course, adding stroke-opacity="1"/fill-opacity="1" for opaque colors also causes context breaking.
This problem can be avoided by specifying stroke-opacity and fill-opacity manually.
If it is an official solution, we need to fix the code of Gadfly. The stroke(nothing) sets stroke-opacity to zero.
While it is not a complete solution, at least, it is better to distinguish between the strokes/fills which actually exist but fully-transparent, and no-stroke/no-fill.
Line 54 in 2b561b0
| stroke(c::Nothing) = Stroke([StrokePrimitive(RGBA{Float64}(0, 0, 0, 0))]) |
Line 71 in 2b561b0
| fill(c::Nothing) = Fill([FillPrimitive(RGBA{Float64}(0.0, 0.0, 0.0, 0.0))]) |