发布于 2020-07-26 12:56:44
基本的想法是掩盖干扰。对于干代码,首先将呈现的路径定义为可重用的模板。
path {
fill: none;
stroke: black;
}
mask rect {
fill: white;
}
.shadow {
stroke-width: 20;
}
.knot {
stroke-width: 10;
}<svg style="width:100px;" viewBox="0 0 100 100">
<defs>
<!-- path templates for multiple use -->
<path id="lower" d="M10 10 90 90" />
<path id="higher" d="M10 90 90 10" />
<mask id="mask">
<!-- white background: everything is visible -->
<rect width="100%" height="100%" />
<!-- black line: masked out space for higher path -->
<use href="#higher" class="shadow" />
</mask>
</defs>
<!-- lower path with masked-out gap -->
<use href="#lower" mask="url(#mask)" class="knot" />
<!-- higher path uninterrupted -->
<use href="#higher" class="knot" />
</svg>
https://stackoverflow.com/questions/63095913
复制相似问题