SVG - Fill the overlapping part of two <circle>'s.

I've created a SVG with two <circle>'s that are placed next to each other, with some part overlapping. I want to fill the overlapping part with a color. I'm trying to explore <filter> but short on time, would appreciate if someone could help me with it.
<svg height="100%" width="100%" xmlns="http://www.w3.org/2000/svg">

<g filter="url(#overlap)">
<circle class="circle" r="30%" cx="32%" cy="50%" fill="white" fill-opacity="0.05" stroke="#8C0000" />
<circle class="circle" r="30%" cx="68%" cy="50%" fill="white" fill-opacity="0.05" stroke="#8C0000" />
</g>
</svg>
<svg height="100%" width="100%" xmlns="http://www.w3.org/2000/svg">

<g filter="url(#overlap)">
<circle class="circle" r="30%" cx="32%" cy="50%" fill="white" fill-opacity="0.05" stroke="#8C0000" />
<circle class="circle" r="30%" cx="68%" cy="50%" fill="white" fill-opacity="0.05" stroke="#8C0000" />
</g>
</svg>
No description
8 Replies
ἔρως
ἔρως3mo ago
you can fake it, but you need to convert this to a 300x150 image (by using a viewbox) and this path: <path d="M150.0019 28.707A71.1513 71.1513 0 00150 121.293 71.1513 71.1513 0 00150.0019 28.707Z" /> by the way, your svg is very sub-optimal
<g filter="url(#overlap)">
<circle class="circle" r="30%" cx="32%" cy="50%" fill="white" fill-opacity="0.05" stroke="#8C0000" />
<circle class="circle" r="30%" cx="68%" cy="50%" fill="white" fill-opacity="0.05" stroke="#8C0000" />
</g>
<g filter="url(#overlap)">
<circle class="circle" r="30%" cx="32%" cy="50%" fill="white" fill-opacity="0.05" stroke="#8C0000" />
<circle class="circle" r="30%" cx="68%" cy="50%" fill="white" fill-opacity="0.05" stroke="#8C0000" />
</g>
^ this is a group, and you have repeated properties you should have something like this:
<g filter="url(#overlap)" fill="white" fill-opacity="0.05" stroke="#8C0000">
<circle class="circle" r="30%" cx="32%" cy="50%"/>
<circle class="circle" r="30%" cx="68%" cy="50%" />
</g>
<g filter="url(#overlap)" fill="white" fill-opacity="0.05" stroke="#8C0000">
<circle class="circle" r="30%" cx="32%" cy="50%"/>
<circle class="circle" r="30%" cx="68%" cy="50%" />
</g>
feanor
feanor3mo ago
the problem is, the SVG is supposed to be responsive, it should resize between 1024px and 1920px. I guess I need to explore <path>. I was wondering if there is some kinda filter/mask to achieve it.
ἔρως
ἔρως3mo ago
so?
feanor
feanor3mo ago
thank you for improving the code, I didn't know attributes could inherit like that, first day with SVGs.
ἔρως
ἔρως3mo ago
if you don't have an absolute system, you're going to be in trouble to do some things im not saying this is a perfect solution, by the way you're welcome. that's what a group does
Lamer of Sweden
Lamer of Sweden3mo ago
Found something on stackoverflow using ComponentTransfer. The last entry marked green. https://stackoverflow.com/questions/38751756/what-is-the-best-approach-for-overlapping-svg-elements-area-fill
ἔρως
ἔρως3mo ago
that's a much better method
feanor
feanor3mo ago
thank you so much, looking into it.
Want results from more Discord servers?
Add your server