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

View in English Always switch to English

SVGFEDropShadowElement: stdDeviationX プロパティ

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月.

stdDeviationXSVGFEDropShadowElement インターフェイスの読み取り専用プロパティで、この <feDropShadow> 要素の stdDeviation 属性の(おそらく自動で計算された)X 成分を反映します。

SVGAnimatedNumber オブジェクトです。

stdDeviationX 値へアクセス

この例では、<feDropShadow> のぼかし処理における水平方向の標準偏差を、SVGFEDropShadowElement インターフェイスの読み取り専用のプロパティ stdDeviationX を使用して取得します。

html
<svg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg">
  <defs>
    <filter id="drop-shadow-filter">
      <!-- 水平方向のぼかし効果をつけるために、stdDeviationX プロパティを 5 に設定したドロップシャドウ -->
      <feDropShadow
        in="SourceGraphic"
        dx="10"
        dy="10"
        stdDeviation="5 10"
        flood-color="gray" />
    </filter>
  </defs>

  <!-- 灰色の影を持つ矩形 -->
  <rect
    x="50"
    y="50"
    width="100"
    height="100"
    fill="red"
    filter="url(#drop-shadow-filter)" />
</svg>
js
const dropShadow = document.querySelector("feDropShadow");

console.log(dropShadow.stdDeviationX.baseVal); // 出力結果: 5

仕様書

Specification
Filter Effects Module Level 1
# dom-svgfedropshadowelement-stddeviationx

ブラウザーの互換性

関連情報