このページはコミュニティーの尽力で英語から翻訳されました。MDN Web Docs コミュニティーについてもっと知り、仲間になるにはこちらから。

View in English Always switch to English

SVGFEDisplacementMapElement: in2 プロパティ

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2015年7月.

in2SVGFEDisplacementMapElement インターフェイスの読み取り専用プロパティで、この <feDisplacementMap> 要素の in2 属性を反映します。

SVGAnimatedString オブジェクトです。

この例では、フィルター内に 2 つの <feDisplacementMap> 要素が定義されており、それぞれ異なる in2 属性が設定されています。

html
<svg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg">
  <defs>
    <filter id="filter1">
      <!-- First Displacement Map -->
      <feDisplacementMap in="SourceGraphic" in2="BackgroundImage" scale="20">
        <feFuncR type="table" tableValues="0 1" />
      </feDisplacementMap>

      <!-- Second Displacement Map -->
      <feDisplacementMap in="SourceGraphic" in2="BackgroundImage" scale="30">
        <feFuncR type="table" tableValues="0.5 1" />
      </feDisplacementMap>
    </filter>
  </defs>
  <rect
    x="20"
    y="20"
    width="100"
    height="100"
    fill="red"
    filter="url(#filter1)" />
  <circle cx="100" cy="100" r="50" fill="blue" filter="url(#filter1)" />
</svg>

次のようにして、in2 属性にアクセスできます。

js
const displacementMaps = document.querySelectorAll("feDisplacementMap");

console.log(displacementMaps[0].getAttribute("in2")); // 出力結果: "BackgroundImage"
console.log(displacementMaps[1].getAttribute("in2")); // 出力結果: "BackgroundImage"

仕様書

Specification
Filter Effects Module Level 1
# dom-svgfedisplacementmapelement-in2

ブラウザーの互換性

関連情報