核矩陣

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

瀏覽器相容性