SVGFEDropShadowElement: dx 屬性
SVGFEDropShadowElement 介面的只讀屬性 dx 反映了給定 <feDropShadow> 元素的 dx 屬性。
值
一個 SVGAnimatedNumber 物件。
示例
訪問 dx 值
在此示例中,我們透過使用 SVGFEDropShadowElement 介面的只讀屬性 dx 來檢索 <feDropShadow> 的水平偏移量。
html
<svg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg">
<defs>
<filter id="drop-shadow-filter">
<!-- Drop Shadow with dx property set to 10 -->
<feDropShadow
in="SourceGraphic"
dx="10"
dy="10"
stdDeviation="5"
flood-color="red" />
</filter>
</defs>
<!-- Rectangle with a red shadow -->
<rect
x="20"
y="20"
width="100"
height="100"
fill="red"
filter="url(#drop-shadow-filter)" />
<!-- Circle with a red shadow -->
<circle
cx="100"
cy="100"
r="50"
fill="blue"
filter="url(#drop-shadow-filter)" />
</svg>
js
const dropShadow = document.querySelector("feDropShadow");
console.log(dropShadow.dx.baseVal); // Output: 10
規範
| 規範 |
|---|
| 濾鏡效果模組第 1 級 # dom-svgfedropshadowelement-dx |
瀏覽器相容性
載入中…