SVGFEDropShadowElement: dx プロパティ
Baseline
Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2020年1月.
dx は SVGFEDropShadowElement インターフェイスの読み取り専用プロパティで、この <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">
<!-- dx プロパティを 10 に設定したドロップシャドウ -->
<feDropShadow
in="SourceGraphic"
dx="10"
dy="10"
stdDeviation="5"
flood-color="red" />
</filter>
</defs>
<!-- 赤い影をつけた矩形 -->
<rect
x="20"
y="20"
width="100"
height="100"
fill="red"
filter="url(#drop-shadow-filter)" />
<!-- 赤い影をつけた円 -->
<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); // 出力結果: 10
仕様書
| Specification |
|---|
| Filter Effects Module Level 1> # dom-svgfedropshadowelement-dx> |