SVGFEDisplacementMapElement: in2 property
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
The in2
read-only property of the SVGFEDisplacementMapElement
interface reflects the in2
attribute of the given <feDisplacementMap>
element.
Value
An SVGAnimatedString
object.
Examples
In this example, two <feDisplacementMap>
elements are defined in a filter, each with a different in2
attribute.
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"
style="fill:red;"
filter="url(#filter1)" />
<circle cx="100" cy="100" r="50" style="fill:blue;" filter="url(#filter1)" />
</svg>
We can access the in2
attribute:
js
const displacementMaps = document.querySelectorAll("feDisplacementMap");
console.log(displacementMaps[0].getAttribute("in2")); // Output: "BackgroundImage"
console.log(displacementMaps[1].getAttribute("in2")); // Output: "BackgroundImage"
Specifications
Specification |
---|
Filter Effects Module Level 1 # dom-svgfedisplacementmapelement-in2 |
Browser compatibility
BCD tables only load in the browser