当前位置: 首页>>代码示例>>用法及示例精选>>正文


SVG FEOffset.dx属性用法及代码示例

SVG FEOffset.dx属性返回与FEOffset.dx元素的dx组件相对应的SVGAnimatedNumber对象。

用法:

var a = FEOffset.dx

返回值:此属性返回与FEOffset.dx元素的dx组件相对应的SVGAnimatedNumber对象。

范例1:

HTML

<!DOCTYPE html> 
<html> 
  
<body> 
    <svg width="400" height="400"> 
        <defs> 
            <filter id="filter2" x="0" y="0" 
                width="150%" height="150%"> 
                  
                <feOffset result="offOut" dx="30" 
                    dy="30" in="SourceGraphic" id="gfg" /> 
                  
                <feBlend in="SourceGraphic" 
                    in2="blurOut" mode="normal" /> 
            </filter> 
        </defs> 
  
        <g> 
            <rect x="50" y="50" width="150" 
                height="150" stroke="black" 
                stroke-width="5" fill="gray"
                filter="url(#filter2)" /> 
        </g> 
  
        <script type="text/javascript"> 
            var g = document.getElementById("gfg"); 
            console.log(g.dx); 
            console.log("dx value is:", g.dx.baseVal) 
        </script> 
    </svg> 
</body> 
  
</html>

输出:



范例2:

HTML

<!DOCTYPE html> 
<html> 
  
<body> 
    <svg width="400" height="400"> 
        <defs> 
            <filter id="filter2" x="0" y="0" 
                width="150%" height="150%"> 
                  
                <feOffset result="offOut" dx="30" 
                    dy="30" in="SourceGraphic" id="gfg" /> 
                  
                <feGaussianBlur in1="blurOut" 
                    in="offOut" stdDeviation="10" /> 
                  
                <feBlend in="SourceGraphic" 
                    in2="blurOut" mode="normal" /> 
            </filter> 
        </defs> 
  
        <g> 
            <rect x="50" y="50" width="150" 
                height="150" fill="gray" 
                filter="url(#filter2)" /> 
        </g> 
  
        <script type="text/javascript"> 
            var g = document.getElementById("gfg"); 
            console.log(g.dx); 
            console.log("dx value is:", g. 
                dx.baseVal) 
        </script> 
    </svg> 
</body> 
  
</html>

输出:

支持的浏览器:

  • 谷歌浏览器
  • Edge
  • Firefox
  • Safari
  • Opera
  • IE浏览器




相关用法

注:本文由堆栈答案筛选整理自taran910大神的英文原创作品 SVG FEOffset.dx Property。非经特殊声明,原始代码版权归原作者所有,本译文的传播和使用请遵循“署名-相同方式共享 4.0 国际 (CC BY-SA 4.0)”协议。