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


SVG <feFlood>用法及代码示例


SVG代表可缩放矢量图形。它可以像HTML画布一样用于制作图形和动画。 SVG <feFlood>元素生成一层连续的颜色,该颜色完全填充了该元素的过滤器基本区域。

用法:

<feFlood x="" y="" width="" height=""
 flood-color="" flood-opacity=""/>

用法:

  • -它定义了用户坐标系中的x轴和y轴坐标。
  • 宽度-外部对象的宽度。
  • 高度-foreignObject的高度。
  • flood-color-告诉新层的颜色。
  • flood-opacity-告诉新层的不透明度值。

范例1:

<!DOCTYPE html> 
<html> 
  
<body> 
    <svg width="200" height="200"> 
        <defs> 
            <filter id="filter1" 
                filterUnits="userSpaceOnUse"> 
                  
                <feFlood x="5%" y="5%" width="198" 
                height="118" flood-color="shadow" 
                flood-opacity="0.3" /> 
            </filter> 
        </defs> 
  
        <rect x="1" y="1" width="198" 
            height="118" style="stroke:#000000; 
                         fill:red;  
                         filter:url(#filter1);" /> 
  
        <g fill="#FFFFFF" stroke="Green" 
            font-size="20" font-family="Verdana"> 
            <text x="28" y="70">GeeksForGeeks</text> 
        </g> 
    </svg> 
</body> 
  
</html>

输出:



范例2:

<!DOCTYPE html> 
<html> 
<title>SVG Filter</title> 
  
<body> 
    <svg width="200" height="200"> 
        <defs> 
            <filter id="filter1" 
                filterUnits="userSpaceOnUse"> 
                  
                <feFlood x="5%" y="5%" width="198" 
                    height="118" flood-color="green" 
                    flood-opacity="0.7" /> 
  
                <feDiffuseLighting in="BackgroundImage" 
                    surfaceScale="14" diffuseConstant="2" 
                    kernelUnitLength="2"> 
  
                    <feSpotLight x="30" y="20" z="30" 
                        limitingConeAngle="40" 
                        pointsAtX="200" pointsAtY="200"
                        pointsAtZ="0" /> 
  
                    <fePointLight x="100" y="80" z="40" /> 
                </feDiffuseLighting> 
            </filter> 
        </defs> 
  
        <rect x="2" y="1" width="198" height="118" 
                        style="stroke:#000000;  
                        fill:green; 
                        filter:url(#filter1);" /> 
  
        <circle cx="108" cy="68" r="55" stroke="black" 
            stroke-width="3" fill="lightgreen" 
            filter:url(#filter1) /> 
  
        <g fill="#FFFFFF" stroke="darkGreen" 
            font-size="12" font-family="Verdana"> 
            <text x="60" y="70">GeeksForGeeks</text> 
        </g> 
    </svg> 
</body> 
  
</html>

输出:




相关用法


注:本文由纯净天空筛选整理自epistler_999大神的英文原创作品 SVG <feFlood> Element。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。