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


SVG keyTimes屬性用法及代碼示例

keyTimes屬性用於指定介於0和1(含)之間的浮點數(時間值)列表,該列表用於控製動畫的步調。使用此屬性的元素包括<animate>,<animateColor>,<animateMotion>和<animateTransform>。

用法:

keyTimes = [;<number>]*

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

  • [; <number>] *:它是一個由semi-colon分隔的介於0和1之間的數字的列表。

注意:keyTimes屬性的默認值為none

以下示例說明了keytimes屬性的用法。



範例1:

HTML

<!DOCTYPE html> 
<html> 
  
<body> 
    <h1 style="color:green; margin-left:35px;"> 
        GeeksforGeeks 
    </h1> 
  
    <svg viewBox="-10 80 620 120" 
        xmlns="http://www.w3.org/2000/svg"> 
          
        <polygon fill="green" points="55.724,  
            91.297 41.645, 91.297 36.738,  
            105.038 47.483, 105.038 41.622, 
            124.568 62.783, 98.526 51.388,  
            98.526" /> 
  
        <animate attributeType="CSS" 
            attributeName="visibility" 
            values="hidden;visible;hidden" 
            keyTimes="0; 0.75; 1" dur="1s" 
            repeatCount="indefinite" /> 
    </svg> 
</body> 
  
</html>

輸出:

範例2:

HTML

<!DOCTYPE html> 
<html> 
  
<body> 
    <h1 style="color:green; margin-left:35px;"> 
        GeeksforGeeks 
    </h1> 
  
    <svg viewBox="0 0 620 120" 
        xmlns="http://www.w3.org/2000/svg"> 
          
        <circle cx="60" cy="10" r="10" fill="green"> 
            <animate attributeName="cx" dur="2s" 
                repeatCount="indefinite" 
                values="60 ; 110 ; 60 ; 10 ; 60"
                keyTimes="0 ; 0.3 ; 0.6 ; 0.80 ; 1" /> 
        </circle> 
    </svg> 
</body> 
  
</html>

輸出:




相關用法


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