我有一个 SVG 绘图,示例代码如下。
需要通过过滤器在整个图片周围制作一个宽度为N像素的白色光晕轮廓。
有必要找到一个解决方案,而不是针对这个特定的绘图,而是一个我可以应用于任何绘图的过滤器。例如,文本或一组形状。
问题的上下文是为 Telegram 创建贴纸,其中光环轮廓是推荐的组件。
div {
background-color: blue;
}
<div>
<svg id="placeholder" width="600" height="600" version="1.1" viewBox="-120 -120 240 240" preserveAspectRatio="none">
<path d="M25.9-96.6C38.3-92.4 41.3-99.8 54-93.5 65.7-85.7 60.9-79.3 70.7-70.7 79.3-60.9 85.7-65.7 93.5-54 99.8-41.3 92.4-38.3 96.6-25.9 99.1-13.1 107.1-14.1 108 0 107.1 14.1 99.1 13.1 96.6 25.9 92.4 38.3 99.8 41.3 93.5 54 85.7 65.7 79.3 60.9 70.7 70.7 60.9 79.3 65.7 85.7 54 93.5 41.3 99.8 38.3 92.4 25.9 96.6 13.1 99.1 14.1 107.1 0 108 -14.1 107.1-13.1 99.1-25.9 96.6 -38.3 92.4-41.3 99.8-54 93.5 -65.7 85.7-60.9 79.3-70.7 70.7 -79.3 60.9-85.7 65.7-93.5 54 -99.8 41.3-92.4 38.3-96.6 25.9 -99.1 13.1-107.1 14.1-108 0 -107.1-14.1-99.1-13.1-96.6-25.9 -92.4-38.3-99.8-41.3-93.5-54 -85.7-65.7-79.3-60.9-70.7-70.7 -60.9-79.3-65.7-85.7-54-93.5 -41.3-99.8-38.3-92.4-25.9-96.6 -13.1-99.1-14.1-107.1 0-108 14.1-107.1 13.1-99.1 25.9-96.6 38.3-92.4 41.3-99.8 54-93.5 65.7-85.7 60.9-79.3 70.7-70.7 79.3-60.9 85.7-65.7 93.5-54 99.8-41.3 92.4-38.3 96.6-25.9 99.1-13.1 107.1-14.1 108 0 107.1 14.1 99.1 13.1 96.6 25.9 92.4 38.3 99.8 41.3 93.5 54 85.7 65.7 79.3 60.9 70.7 70.7 60.9 79.3 65.7 85.7 54 93.5 41.3 99.8 38.3 92.4 25.9 96.6 13.1 99.1 14.1 107.1 0 108 -14.1 107.1-13.1 99.1-25.9 96.6 -38.3 92.4-41.3 99.8-54 93.5 -65.7 85.7-60.9 79.3-70.7 70.7 -79.3 60.9-85.7 65.7-93.5 54 -99.8 41.3-92.4 38.3-96.6 25.9 -99.1 13.1-107.1 14.1-108 0 -107.1-14.1-99.1-13.1-96.6-25.9 -92.4-38.3-99.8-41.3-93.5-54 -85.7-65.7-79.3-60.9-70.7-70.7 -60.9-79.3-65.7-85.7-54-93.5 -41.3-99.8-38.3-92.4-25.9-96.6 -13.1-99.1-14.1-107.1 0-108 14.1-107.1 13.1-99.1 25.9-96.6 38.3-92.4 41.3-99.8 54-93.5 65.7-85.7 60.9-79.3 70.7-70.7" style="fill:yellow;stroke:black; stroke-width:4"/>
</svg>
</div>