當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


SVG FEDropShadow.stdDeviationX屬性用法及代碼示例

SVG FEDropShadow.stdDeviationX屬性返回與FEDisplacementMap.stdDeviationX元素的stdDeviationX組件相對應的SVGAnimatedNumber對象。

用法:

var a = FEDropShadow.stdDeviationX

返回值:此屬性返回與FEDisplacementMap.stdDeviationX元素的stdDeviationX組件相對應的SVGAnimatedNumber對象。

範例1:

HTML

<!DOCTYPE html> 
<html> 
  
<body> 
    <svg width="200" height="200"> 
        <defs> 
            <filter id="drop_shadow" 
                filterUnits="objectBoundingBox" 
                x="-50%" y="-60%" width="250%" 
                height="250%"> 
  
                <feDropShadow in="SourceGraphic"
                    dx="1" dy="1" stdDeviation="30"
                    flood-color="darkgreen" id="gfg" /> 
            </filter> 
        </defs> 
  
        <rect x="40" y="40" width="100" 
            height="100" style="stroke:#000000;  
                fill:lightgreen;  
                filter:url(#drop_shadow);" /> 
  
        <g fill="#FFFFFF" stroke="black" 
            font-size="10" font-family="Verdana"> 
            <text x="50" y="90">GeeksForGeeks</text> 
        </g> 
  
        <script type="text/javascript"> 
            var g = document.getElementById("gfg"); 
            console.log(g.stdDeviationX) 
            console.log("stdDeviationX value is:" 
                , g.stdDeviationX.baseVal) 
        </script> 
    </svg> 
</body> 
  
</html>

輸出:



範例2:

HTML

<!DOCTYPE html> 
<html> 
  
<body> 
    <svg width="200" height="200"> 
        <defs> 
            <filter id="blur" 
                filterUnits="objectBoundingBox" 
                x="-10%" y="-10%" width="300%" 
                height="300%"> 
  
                <feDropShadow in="StrokePaint" 
                    dx="1" dy="1" stdDeviation="30" 
                    flood-color="darkgreen" id="gfg" /> 
            </filter> 
        </defs> 
  
        <circle cx="110" cy="60" r="55" 
            stroke="darkgreen" stroke-width="3" 
            fill="Lightgreen"
            style="stroke:filter:url(#blur);" /> 
  
        <g fill="#FFFFFF" stroke="Green" 
            font-size="10" c font-family="Verdana" /> 
        <text x="60" y="62">GeeksForGeeks</text> 
  
        <script type="text/javascript"> 
            var g = document.getElementById("gfg"); 
            console.log(g.stdDeviationX) 
            console.log("stdDeviationX value is:",  
                g.stdDeviationX.baseVal) 
        </script> 
    </svg> 
</body> 
  
</html>

輸出:

支持的瀏覽器:

  • 穀歌瀏覽器
  • Edge
  • Firefox
  • Safari
  • Opera

參考:https://developer.mozilla.org/en-US/docs/Web/API/SVGFEDropShadowElement




相關用法


注:本文由純淨天空篩選整理自taran910大神的英文原創作品 SVG FEDropShadow.stdDeviationX Property。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。