Luxor.jl
Luxor.jl copied to clipboard
transparency does not work for background color in svg
@svg begin
background(1,0,0,0.5)
setcolor(1,0,0,0.5) # note same color with same alpha value
circle(Point(0, 0), 100, action = :fill)
end 200 200 "circle.svg"
produces svg
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="200pt" height="200pt" viewBox="0 0 200 200" version="1.1">
<g id="surface362">
<rect x="0" y="0" width="200" height="200" style="fill:rgb(100%,100%,100%);fill-opacity:1;stroke:none;"/>
<rect x="0" y="0" width="200" height="200" style="fill:rgb(100%,0%,0%);fill-opacity:0.5;stroke:none;"/>
<path style=" stroke:none;fill-rule:nonzero;fill:rgb(100%,0%,0%);fill-opacity:0.5;" d="M 200 100 C 200 155.226562 155.226562 200 100 200 C 44.773438 200 0 155.226562 0 100 C 0 44.773438 44.773438 0 100 0 C 155.226562 0 200 44.773438 200 100 Z M 200 100 "/>
</g>
</svg>
The line
<rect x="0" y="0" width="200" height="200" style="fill:rgb(100%,100%,100%);fill-opacity:1;stroke:none;"/>
makes the background non-transparent
Ah, so the background color is transparent on top of a white background. Sorry, I'm a bit slow. In any case, why is the white (non-transparent) background needed?