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


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。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。