SVGFEBlendElement:in2 屬性

Baseline 已廣泛支援

此特性已相當成熟,可在許多裝置和瀏覽器版本上使用。自 ⁨2015 年 7 月⁩以來,各瀏覽器均已提供此特性。

SVGFEBlendElement 介面的只讀屬性 in2 反映了給定元素的 in2 屬性。

一個 SVGAnimatedString 物件。

示例

在此示例中,filter 中定義了兩個 <feBlend> 元素,每個元素都有不同的 in2 屬性。

html
<svg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg">
  <filter id="blend-filter">
    <feBlend in="SourceGraphic" in2="SourceAlpha" operator="over" />
    <feBlend in="SourceGraphic" in2="BackgroundImage" operator="in" />
  </filter>
  <rect
    x="20"
    y="20"
    width="100"
    height="100"
    fill="red"
    filter="url(#blend-filter)" />
  <circle cx="100" cy="100" r="50" fill="blue" filter="url(#blend-filter)" />
</svg>

我們可以訪問 in2 屬性

js
const feBlends = document.querySelectorAll("feBlend");

console.log(feBlends[0].in2.baseVal); // Output: "SourceAlpha"
console.log(feBlends[1].in2.baseVal); // Output: "BackgroundImage"

規範

規範
濾鏡效果模組第 1 級
# dom-svgfeblendelement-in2

瀏覽器相容性

另見