Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

transparency does not work for background color in svg #288

Closed
jonalm opened this issue Nov 24, 2023 · 2 comments
Closed

transparency does not work for background color in svg #288

jonalm opened this issue Nov 24, 2023 · 2 comments

Comments

@jonalm
Copy link

jonalm commented Nov 24, 2023

@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

@jonalm
Copy link
Author

jonalm commented Nov 24, 2023

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?

@cormullion
Copy link
Member

Hi! Yes, @svg sets the background to white... source

Perhaps this is helpful?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants