svg - Creating an outset mask around svg shape
问题描述
In an art-project I'm drawing svg-shapes all over the canvas, so that they can overlap at times:
In these cases I want the result to look something like this:
I think I would have to create some kind of shape surounding the foreground shape, but I have no clue how I would be able to do that dynamically. Is there even a way to do this? From some other questions I got the hint, there might be a possibility using filters. I would be happy to do it this way if there is no other, but I also heared these filters are quite resource intensive, what would be a problem, since I'm animating quite a bit here.
Hope you can help me. Thanks for your time :)
解决方案
如果这些是带有笔触但没有填充的笔触,您可以执行以下操作:您使用不同笔触宽度的每条路径两次
svg{background:#ccc; width:300px;}
<svg viewBox = "0 0 100 100">
<defs>
<path id="test" d="M10,75Q33,75 50,50 T90,25" fill="none" />
</defs>
<use xlink:href="#test" style="stroke:#fff;stroke-width:10; stroke-linecap: round" />
<use xlink:href="#test" style="stroke:#000;stroke-width:3; stroke-linecap: round" />
推荐阅读
- python - 从“statsmodels”保存拟合模型
- c++ - sf::Clock 发送随机字表示时间
- r - 识别按 ID 和日期分组的数据框中的第一行
- c# - System.AggregateException: '某些服务不能被构造' ASP.net core
- sass - scss 液体混合中的变量
- google-apps-script - 将数据复制到另一个工作表时出现问题
- javascript - NuxtJs - 在另一个插件中调用插件 - vue-gtag
- html - 如何在引导程序中将面板标题(左)和面板与两侧等距对齐
- spring-boot - 如何在Java自动配置中表示自定义spring cloud stream kafka binder配置
- python - 如果我从 Keras 创建一个 LSTM 模型,然后从头开始创建一个神经网络,是否有可能?