Compose.jl
Compose.jl copied to clipboard
Transparent stroke/fill breaks SVG context
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?
https://github.com/GiovineItalia/Compose.jl/blob/e08b5cac84627389c729502fa1cbae615212d1f9/src/svg.jl#L608-L615
https://github.com/GiovineItalia/Compose.jl/blob/e08b5cac84627389c729502fa1cbae615212d1f9/src/svg.jl#L617-L624
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. https://github.com/GiovineItalia/Compose.jl/blob/2b561b0f53a81cbf9a4001d721d29880d6e50ebc/src/property.jl#L54 https://github.com/GiovineItalia/Compose.jl/blob/2b561b0f53a81cbf9a4001d721d29880d6e50ebc/src/property.jl#L71
While work has been done to fix fillopacity (#314, #318, #319, #322, #332), strokeopacity needs work. Note fillopacity is documented, but not strokeopacity.
The following is the case with "explicit" fillopacity(a)
.
https://github.com/GiovineItalia/Compose.jl/blob/e08b5cac84627389c729502fa1cbae615212d1f9/src/property.jl#L212-L214
For users who understand the inheritance in SVG, like us, this explanation may be sufficient. What I want to emphasize in this issue is that transparent colors implicitly change stroke-opacity
/fill-opacity
and opaque colors not.
I think at least additional docs are needed. In particular, the latter nothing
is reminiscent of none
for users familiar with SVG.
The way I think fill(RGBA(r,g,b,a))
and fillopacity(a)
should currently work is explained in https://github.com/GiovineItalia/Gadfly.jl/issues/1290#issuecomment-544323436. Yes the design/inheritance rules could be better documented. Because Compose uses multiple backends, Compose inheritance may not work in precisely the same way as a particular backend. Color inheritance (different from opacity inheritance) would also work better if svg2's rgba
spec was implemented (#319), but users don't like that rgba is not supported by Inkscape.
Perhaps you could implement the rgba spec in Inkscape?
Perhaps you could implement the rgba spec in Inkscape?
Inkscape places importance on conforming to the standard, so I think it is difficult to implement it within SVG1.
BTW, SVG 1.2 Full was canceled, so version="1.2"
is just for SVG Tiny (i.e. with baseProfile="tiny"
).
https://github.com/GiovineItalia/Compose.jl/blob/e08b5cac84627389c729502fa1cbae615212d1f9/src/svg.jl#L342
I believe this problem can be mitigated by being able to determine whether fill-opacity
was set by FillOpacityPrimitive
or FillPrimitive
.