<feMorphology>
<feMorphology>
SVG 滤镜基元用于侵蚀或膨胀输入图像。其特别之处在于能够实现加粗或细化效果。
与其它滤镜图元一样,它默认在 linearRGB
颜色空间中处理颜色分量。您可以使用 color-interpolation-filters
属性改为使用 sRGB
。
使用语境
属性
DOM 接口
此元素实现了 SVGFEMorphologyElement
接口。
示例
过滤 SVG 内容
SVG
html
<svg xmlns="http://www.w3.org/2000/svg" width="300" height="180">
<filter id="erode">
<feMorphology operator="erode" radius="1" />
</filter>
<filter id="dilate">
<feMorphology operator="dilate" radius="2" />
</filter>
<text y="1em">Normal text</text>
<text id="thin" y="2em">Thinned text</text>
<text id="thick" y="3em">Fattened text</text>
</svg>
CSS
css
text {
font-family: "Helvetica", "Arial", sans-serif;
font-size: 3em;
}
#thin {
filter: url("#erode");
}
#thick {
filter: url("#dilate");
}
过滤 HTML 内容
SVG
html
<svg xmlns="http://www.w3.org/2000/svg" width="0" height="0">
<filter id="erode">
<feMorphology operator="erode" radius="1" />
</filter>
<filter id="dilate">
<feMorphology operator="dilate" radius="2" />
</filter>
</svg>
<p>Normal text</p>
<p id="thin">Thinned text</p>
<p id="thick">Fattened text</p>
CSS
css
p {
margin: 0;
font-family: "Helvetica", "Arial", sans-serif;
font-size: 3em;
}
#thin {
filter: url("#erode");
}
#thick {
filter: url("#dilate");
}
规范
规范 |
---|
滤镜效果模块第 1 级 # feMorphologyElement |
浏览器兼容性
加载中…