k2

Baseline 已廣泛支援

此特性已相當成熟,可在許多裝置和瀏覽器版本上使用。自 ⁨2020 年 1 月⁩ 起,所有主流瀏覽器均已支援。

k2 屬性定義了在 <feComposite> 濾鏡圖元中的 arithmetic 操作所使用的值之一。

畫素組合使用以下公式計算:

js
result = k1 * i1 * i2 + k2 * i1 + k3 * i2 + k4;

你可以將此屬性與以下 SVG 元素一起使用

示例

html
<svg viewBox="0 0 420 200" xmlns="http://www.w3.org/2000/svg">
  <filter id="composite1" x="0" y="0" width="100%" height="100%">
    <feComposite
      in2="SourceGraphic"
      operator="arithmetic"
      k1="1"
      k2="1"
      k3="0"
      k4="0" />
  </filter>
  <filter id="composite2" x="0" y="0" width="100%" height="100%">
    <feComposite
      in2="SourceGraphic"
      operator="arithmetic"
      k1="1"
      k2="10"
      k3="0"
      k4="0" />
  </filter>

  <image
    href="mdn.svg"
    x="0"
    y="0"
    width="200"
    height="200"
    filter="url(#composite1)" />
  <image
    href="mdn.svg"
    x="220"
    y="0"
    width="200"
    height="200"
    filter="url(#composite2)" />
</svg>

用法說明

<number>
預設值 0
可動畫的

規範

規範
濾鏡效果模組第 1 級
# element-attrdef-fecomposite-k2

瀏覽器相容性