核矩阵

Baseline 已广泛支持

此特性已相当成熟,可在许多设备和浏览器版本上使用。自 ⁨2015 年 7 月⁩以来,各浏览器均已提供此特性。

kernelMatrix 属性定义了组成 <feConvolveMatrix> 元素卷积矩阵的数字列表。

值之间用空格和/或逗号分隔。列表中的条目数必须等于 <orderX> 乘以 <orderY>,具体由 order 属性定义。

你可以将此属性与以下 SVG 元素一起使用

示例

html
<svg viewBox="0 0 420 200" xmlns="http://www.w3.org/2000/svg">
  <filter id="convolveMatrix1" x="0" y="0" width="100%" height="100%">
    <feConvolveMatrix kernelMatrix="1 1 0 0 0 0 0 0 -1" />
  </filter>
  <filter id="convolveMatrix2" x="0" y="0" width="100%" height="100%">
    <feConvolveMatrix kernelMatrix="-1 0 0 0 0 0 0 0 1" />
  </filter>

  <image
    href="mdn_logo_only_color.png"
    width="200"
    height="200"
    filter="url(#convolveMatrix1)" />
  <image
    x="220"
    href="mdn_logo_only_color.png"
    width="200"
    height="200"
    filter="url(#convolveMatrix2)" />
</svg>

用法说明

<数字列表>
默认值 None
可动画的
<数字列表>

组成卷积卷积矩阵的 <number> 列表。值之间用空格和/或逗号分隔。列表中的条目数必须等于 <orderX> 乘以 <orderY>

如果 orderX * orderY 的结果不等于值列表中的条目数,则滤镜图元将作为直通滤镜。

规范

规范
滤镜效果模块第 1 级
# element-attrdef-feconvolvematrix-kernelmatrix

浏览器兼容性