SVGFEDropShadowElement: stdDeviationY 屬性

Baseline 已廣泛支援

此特性已相當成熟,可在許多裝置和瀏覽器版本上使用。自 ⁨2020 年 1 月⁩ 起,所有主流瀏覽器均已支援。

SVGFEDropShadowElement 介面的只讀屬性 stdDeviationY 反映了給定 <feDropShadow> 元素的 stdDeviation 屬性的(可能是自動計算的)Y 分量。

一個 SVGAnimatedNumber 物件。

示例

訪問 stdDeviationY

在此示例中,我們透過使用 SVGFEDropShadowElement 介面的只讀屬性 stdDeviationY 來檢索 <feDropShadow> 模糊操作的垂直標準差。

html
<svg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg">
  <defs>
    <filter id="drop-shadow-filter">
      <!-- Drop Shadow with stdDeviationY property set to 10 for vertical blur -->
      <feDropShadow
        in="SourceGraphic"
        dx="10"
        dy="10"
        stdDeviation="5 10"
        flood-color="gray" />
    </filter>
  </defs>

  <!-- Rectangle with a gray shadow -->
  <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.stdDeviationY.baseVal); // Output: 10

規範

規範
濾鏡效果模組第 1 級
# dom-svgfedropshadowelement-stddeviationy

瀏覽器相容性

另見