1e41f4b71Sopenharmony_ci# Defining Animations for SVG Components 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ciYou can use child components in the **\<svg>** component to animate attributes over time. 4e41f4b71Sopenharmony_ci 5e41f4b71Sopenharmony_ci## Attribute Style Animation 6e41f4b71Sopenharmony_ci 7e41f4b71Sopenharmony_ciIn the [animate](../reference/apis-arkui/arkui-js/js-components-svg-animate.md) child component of the **\<svg>** component, set **attributeName** to the attribute you want to animate, **from** to the animation start value, and **to** to the animation end value. 8e41f4b71Sopenharmony_ci 9e41f4b71Sopenharmony_ci 10e41f4b71Sopenharmony_ci```html 11e41f4b71Sopenharmony_ci<!-- xxx.hml --> 12e41f4b71Sopenharmony_ci<div class="container"> 13e41f4b71Sopenharmony_ci <svg> 14e41f4b71Sopenharmony_ci <text x="300" y="300" fill="blue"> 15e41f4b71Sopenharmony_ci Hello 16e41f4b71Sopenharmony_ci <animate attributeName="font-size" from="30" to="60" dur="3s" repeatCount="indefinite"> 17e41f4b71Sopenharmony_ci </animate> 18e41f4b71Sopenharmony_ci <animate attributeName="fill" from="red" to="blue" dur="3s" repeatCount="indefinite"> 19e41f4b71Sopenharmony_ci </animate> 20e41f4b71Sopenharmony_ci <animate attributeName="opacity" from="1" to="0.3" dur="3s" repeatCount="indefinite"> 21e41f4b71Sopenharmony_ci </animate> 22e41f4b71Sopenharmony_ci </text> 23e41f4b71Sopenharmony_ci <text x="300" y="600" fill="blue"> 24e41f4b71Sopenharmony_ci World 25e41f4b71Sopenharmony_ci <animate attributeName="font-size" from="30" to="60" values="30;80" dur="3s" repeatCount="indefinite"> 26e41f4b71Sopenharmony_ci </animate> 27e41f4b71Sopenharmony_ci <animate attributeName="fill" from="red" to="blue" dur="3s" repeatCount="indefinite"> 28e41f4b71Sopenharmony_ci </animate> 29e41f4b71Sopenharmony_ci <animate attributeName="opacity" from="0.3" to="1" dur="3s" repeatCount="indefinite"> 30e41f4b71Sopenharmony_ci </animate> 31e41f4b71Sopenharmony_ci </text> 32e41f4b71Sopenharmony_ci </svg> 33e41f4b71Sopenharmony_ci</div> 34e41f4b71Sopenharmony_ci``` 35e41f4b71Sopenharmony_ci 36e41f4b71Sopenharmony_ci 37e41f4b71Sopenharmony_ci 38e41f4b71Sopenharmony_ci> **NOTE** 39e41f4b71Sopenharmony_ci> 40e41f4b71Sopenharmony_ci> When values is also set, the from and to settings do not take effect. 41e41f4b71Sopenharmony_ci 42e41f4b71Sopenharmony_ci## Motion Path Animation 43e41f4b71Sopenharmony_ci 44e41f4b71Sopenharmony_ciIn the [animateMotion](../reference/apis-arkui/arkui-js/js-components-svg-animatemotion.md) child component of the <svg> component, set path to define a shape for the animation. 45e41f4b71Sopenharmony_ci 46e41f4b71Sopenharmony_ci 47e41f4b71Sopenharmony_ci```html 48e41f4b71Sopenharmony_ci<!-- xxx.hml --> 49e41f4b71Sopenharmony_ci<div class="container"> 50e41f4b71Sopenharmony_ci <svg fill="white" width="800" height="900"> 51e41f4b71Sopenharmony_ci <path d="M300,200 h-150 a150 150 0 1 0 150 -150 z" fill="white" stroke="blue" stroke-width="5" > 52e41f4b71Sopenharmony_ci </path> 53e41f4b71Sopenharmony_ci <path fill="red" d="M-5,-5 L10,0 L-5,5 L0,0 Z" > 54e41f4b71Sopenharmony_ci <animateMotion dur="2000" repeatCount="indefinite" rotate="auto-reverse"path="M300,200 h-150 a150 150 0 1 0 150 -150 z"> 55e41f4b71Sopenharmony_ci </animateMotion> 56e41f4b71Sopenharmony_ci </path> 57e41f4b71Sopenharmony_ci </svg> 58e41f4b71Sopenharmony_ci</div> 59e41f4b71Sopenharmony_ci``` 60e41f4b71Sopenharmony_ci 61e41f4b71Sopenharmony_ci 62e41f4b71Sopenharmony_ci 63e41f4b71Sopenharmony_ci## animateTransform Animation 64e41f4b71Sopenharmony_ci 65e41f4b71Sopenharmony_ciIn the [animateTransform](../reference/apis-arkui/arkui-js/js-components-svg-animatetransform.md) child component of the **\<svg>** component, set attributeName to bind the corresponding attribute to the **transform** attribute, and set **type** to the animation type, **from** to the start value, and **to** to the end value. 66e41f4b71Sopenharmony_ci 67e41f4b71Sopenharmony_ci 68e41f4b71Sopenharmony_ci```html 69e41f4b71Sopenharmony_ci<!-- xxx.hml --> 70e41f4b71Sopenharmony_ci<div class="container" style=""> 71e41f4b71Sopenharmony_ci <svg> 72e41f4b71Sopenharmony_ci <line x1="90" y1="300" x2="90" y2="730" stroke-width="10" stroke="black" stroke-linecap="round"> 73e41f4b71Sopenharmony_ci <animateTransform attributeName="transform" attributeType="XML" type="translate" dur="3s" values="0;30;10;30;20;30;25;30" keyTimes="0;0.3;0.5;0.7;0.8;0.9;1.0;1.1" 74e41f4b71Sopenharmony_ci fill="freeze"> 75e41f4b71Sopenharmony_ci </animateTransform> 76e41f4b71Sopenharmony_ci </line> 77e41f4b71Sopenharmony_ci <circle cx="500" cy="500" r="50" stroke-width="15" fill="red" stroke="#e70d0d"> 78e41f4b71Sopenharmony_ci <animateTransform attributeName="transform" attributeType="XML" type="rotate" dur="3s" values="0;30;10;30;20;30;25;30" keyTimes="0;0.3;0.5;0.7;0.8;0.9;1.0;1.1" fill="freeze"> 79e41f4b71Sopenharmony_ci </animateTransform> 80e41f4b71Sopenharmony_ci <animateTransform attributeName="transform" attributeType="XML" type="scale" dur="6s" values="1;1;1.3" keyTimes="0;0.5;1" fill="freeze"></animateTransform> 81e41f4b71Sopenharmony_ci <animateTransform attributeName="transform" attributeType="XML" type="translate" dur="9s" values="0;0;300 7" keyTimes="0;0.6;0.9" fill="freeze"></animateTransform> 82e41f4b71Sopenharmony_ci </circle> 83e41f4b71Sopenharmony_ci <rect width="500" height="200" x="90" y="840"> 84e41f4b71Sopenharmony_ci <animateTransform attributeName="transform" attributeType="XML" type="skewY" dur="6s" values="0;0;30" keyTimes="0;0.5;1" fill="freeze"></animateTransform> 85e41f4b71Sopenharmony_ci </rect> 86e41f4b71Sopenharmony_ci <line x1="650" y1="300" x2="650" y2="600" stroke-width="20" stroke="blue" stroke-linecap="round"> 87e41f4b71Sopenharmony_ci <animateTransform attributeName="transform" attributeType="XML" type="translate" dur="9s" values="0;0;0 800" keyTimes="0;0.6;1" fill="freeze"></animateTransform> 88e41f4b71Sopenharmony_ci </line> 89e41f4b71Sopenharmony_ci </svg> 90e41f4b71Sopenharmony_ci</div> 91e41f4b71Sopenharmony_ci``` 92e41f4b71Sopenharmony_ci 93e41f4b71Sopenharmony_ci 94e41f4b71Sopenharmony_ci```css 95e41f4b71Sopenharmony_ci/* xxx.css */ 96e41f4b71Sopenharmony_ci.container { 97e41f4b71Sopenharmony_ci flex-direction: column; 98e41f4b71Sopenharmony_ci align-items: center; 99e41f4b71Sopenharmony_ci width: 100%; 100e41f4b71Sopenharmony_ci height: 100%; 101e41f4b71Sopenharmony_ci background-color: #F1F3F5; 102e41f4b71Sopenharmony_ci} 103e41f4b71Sopenharmony_ci``` 104e41f4b71Sopenharmony_ci 105e41f4b71Sopenharmony_ci