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


SVG surfaceScale屬性用法及代碼示例

surfaceScale屬性用作表麵的高度。使用此屬性的元素包括<feSpecularLighting>和<feDiffuseLighting>

用法:

surfaceScale = "number"

屬性值:surfaceScale屬性接受上麵提到的和下麵描述的值

  • 數:該屬性值接受數字,例如原始整數,正分數,負分數,零,無前導零的分數等。

注意:默認屬性值被視為1。

範例1:下麵的示例說明了surfaceScale屬性的用法。



HTML

<!DOCTYPE html> 
<html> 
  
<body> 
    <h1 style="color:green;"> 
        GeeksforGeeks 
    </h1> 
  
    <p> 
        value of surfaceScale = "1" 
    </p> 
  
    <svg viewBox="0 0 820 600" 
        xmlns="http://www.w3.org/2000/svg"> 
          
        <filter id="geek1" x="0" y="0" 
            width="100%" height="100%"> 
              
            <feDiffuseLighting surfaceScale="1"> 
                <fePointLight x="60" y="60" z="20" /> 
            </feDiffuseLighting> 
        </filter> 
          
        <rect width="150" height="150" 
            style="filter:url(#geek1);" /> 
    </svg> 
</body> 
  
</html>

輸出:

範例2:

HTML

<!DOCTYPE html> 
<html> 
  
<body> 
    <h1 style="color:green;"> 
        GeeksforGeeks 
    </h1> 
    <p> 
        value of surfaceScale = "20" 
    </p> 
  
    <svg viewBox="0 0 820 600" 
        xmlns="http://www.w3.org/2000/svg"> 
          
        <filter id="geeks2" x="0" y="0" 
            width="100%" height="100%"> 
              
            <feDiffuseLighting in="SourceGraphic" 
                surfaceScale="20"> 
  
                <fePointLight x="60" y="60" z="20" /> 
            </feDiffuseLighting> 
        </filter> 
          
        <rect x="0" y="0" width="150" height="150" 
            style="filter:url(#geeks2);" /> 
    </svg> 
</body> 
  
</html>

輸出:




相關用法


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