1e41f4b71Sopenharmony_ci# animate
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ci
4e41f4b71Sopenharmony_ci>  **NOTE**
5e41f4b71Sopenharmony_ci>
6e41f4b71Sopenharmony_ci>  This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version.
7e41f4b71Sopenharmony_ci
8e41f4b71Sopenharmony_ciThe **\<animate>** component is used to apply animation to an **\<svg>** component.
9e41f4b71Sopenharmony_ci
10e41f4b71Sopenharmony_ci## Required Permissions
11e41f4b71Sopenharmony_ci
12e41f4b71Sopenharmony_ciNone
13e41f4b71Sopenharmony_ci
14e41f4b71Sopenharmony_ci
15e41f4b71Sopenharmony_ci## Child Components
16e41f4b71Sopenharmony_ci
17e41f4b71Sopenharmony_ciNot supported
18e41f4b71Sopenharmony_ci
19e41f4b71Sopenharmony_ci
20e41f4b71Sopenharmony_ci## Attributes
21e41f4b71Sopenharmony_ci
22e41f4b71Sopenharmony_ci| Name| Type| Default Value| Mandatory| Description|
23e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | -------- |
24e41f4b71Sopenharmony_ci| id | string | - | No| Unique ID of the component.|
25e41f4b71Sopenharmony_ci| attributeName | string | - | No| Name of the component to which the animation is applied.|
26e41f4b71Sopenharmony_ci| begin | &lt;time&gt; | 0 | No| Delay time of the animation.<br>The value can be ms (ms), s (second), or m (minute). The default value is s (second). Other formats are not supported.|
27e41f4b71Sopenharmony_ci| dur | &lt;time&gt; | 0 | No| Animation duration. If **dur** is not set, the value of **end**-**begin** is used as the duration. If the value is less than or equal to 0, the animation is not triggered.<br>The value can be ms (ms), s (second), or m (minute). The default value is s (second). Other formats are not supported.|
28e41f4b71Sopenharmony_ci| end | &lt;time&gt; | 0 | No| Duration after which the animation ends. The value can be ms (ms), s (second), or m (minute). The default value is s (second). Other formats are not supported.|
29e41f4b71Sopenharmony_ci| repeatCount | &lt;number \| indefinite&gt; | 1 | No| Number of times the animation is played. The default value is indefinite. You can set the value to **1** to play the animation only once.|
30e41f4b71Sopenharmony_ci| fill | &lt;freeze \| remove&gt; | remove | No| State when the animation ends.|
31e41f4b71Sopenharmony_ci| calcMode | &lt;discrete \| linear \| paced \| spline&gt; | linear | No| Interpolation mode of the animation.<br>**discrete**: The animation directly jumps from the value specified by **from** to the value specified by **to**.<br>**linear**: Linear interpolation between values is used.<br>**paced**: Interpolation that produces an even paced change is used. If this value is set, the values of **keyTimes** and **keyPoints** will not take effect.<br>**spline**: Interpolation is implemented based on a custom Bezier spline. The spline points are defined in the **keyTimes** attribute, and the control points of each interval are defined in the **keySplines** attribute.|
32e41f4b71Sopenharmony_ci| keyTimes | string | - | No| Start time of the key frame animation. The value is a semicolon-separated list of values ranging from 0 to 1, for example, **0;0.3;0.8;1**. **keyTimes**, **keySplines**, and **values** are combined to set the key frame animation. The number of values defined for **keyTimes** is the same as that for **values**. The number of values defined for **keySplines** is the number of values defined for **keyTimes** minus 1.|
33e41f4b71Sopenharmony_ci| keySplines | string | - | No| A set of Bezier control points associated with **keyTimes**. You can define the Bezier curves for each key frame, separating them with semicolons (;). The format of the two control points in the curve is x1 y1 x2 y2, for example, **0.5 0 0.5 1; 0.5 0 0.5 1;0.5 0 0.5 1**.|
34e41f4b71Sopenharmony_ci| by | number | - | No| Relative offset value to add to a specified attribute in the animation. The default value of **from** is the original attribute value.|
35e41f4b71Sopenharmony_ci| from | string | - | No| Start value of the attribute to which the animation is applied.<br>If the **values** attribute has been set, the **from** attribute is invalid.|
36e41f4b71Sopenharmony_ci| to | string | - | No| End value of the attribute to which the animation is applied.<br>If the **values** attribute has been set, the **to** attribute is invalid.|
37e41f4b71Sopenharmony_ci| values | string | - | No| Change value of a group of animations. The format is value1;value2;value3.|
38e41f4b71Sopenharmony_ci
39e41f4b71Sopenharmony_ci
40e41f4b71Sopenharmony_ci## Example
41e41f4b71Sopenharmony_ci
42e41f4b71Sopenharmony_ci```html
43e41f4b71Sopenharmony_ci<!-- xxx.hml -->
44e41f4b71Sopenharmony_ci<div class="container">
45e41f4b71Sopenharmony_ci  <svg width="400" height="400">
46e41f4b71Sopenharmony_ci    <rect x="20" y="20" width="100" height="100" fill="red" rx="0" ry="20">
47e41f4b71Sopenharmony_ci      <animate attributeName="rx" values="0;10;30;0" keyTimes="0;0.25;0.75;1" keySplines="0.5 0 0.5 1; 0.5 0 0.5 1; 0.5 0 0.5 1" dur="1000" repeatCount="indefinite">
48e41f4b71Sopenharmony_ci      </animate>
49e41f4b71Sopenharmony_ci    </rect>
50e41f4b71Sopenharmony_ci  </svg>
51e41f4b71Sopenharmony_ci</div>
52e41f4b71Sopenharmony_ci```
53e41f4b71Sopenharmony_ci
54e41f4b71Sopenharmony_ci
55e41f4b71Sopenharmony_ci![en-us_image_0000001173324703](figures/en-us_image_0000001173324703.gif)
56e41f4b71Sopenharmony_ci
57e41f4b71Sopenharmony_ci
58e41f4b71Sopenharmony_ci```html
59e41f4b71Sopenharmony_ci<!-- xxx.hml -->
60e41f4b71Sopenharmony_ci<div class="container">
61e41f4b71Sopenharmony_ci  <svg width="400" height="400">
62e41f4b71Sopenharmony_ci    <rect x="20" y="20" width="100" height="100" fill="red" rx="0" ry="20">
63e41f4b71Sopenharmony_ci      <animate attributeName="fill" from="red" to="blue" dur="1000" repeatCount="indefinite"></animate>
64e41f4b71Sopenharmony_ci      <animate attributeName="height" from="50" to="150" begin="500" end="1000" repeatCount="indefinite">  </animate>
65e41f4b71Sopenharmony_ci    </rect>
66e41f4b71Sopenharmony_ci  </svg>
67e41f4b71Sopenharmony_ci</div>
68e41f4b71Sopenharmony_ci```
69e41f4b71Sopenharmony_ci
70e41f4b71Sopenharmony_ci
71e41f4b71Sopenharmony_ci![en-us_image_0000001167662852](figures/en-us_image_0000001167662852.gif)
72e41f4b71Sopenharmony_ci
73e41f4b71Sopenharmony_ci
74e41f4b71Sopenharmony_ci```html
75e41f4b71Sopenharmony_ci<!-- xxx.hml -->
76e41f4b71Sopenharmony_ci<div class="container">
77e41f4b71Sopenharmony_ci  <svg width="400" height="400">
78e41f4b71Sopenharmony_ci    <rect x="20" y="20" width="100" height="100" fill="red" rx="0" ry="20">
79e41f4b71Sopenharmony_ci      <animate attributeName="rx" values="0;30" dur="1000" repeatCount="indefinite" fill="freeze" calcMode="linear"></animate>
80e41f4b71Sopenharmony_ci    </rect>
81e41f4b71Sopenharmony_ci  </svg>
82e41f4b71Sopenharmony_ci</div>
83e41f4b71Sopenharmony_ci```
84e41f4b71Sopenharmony_ci
85e41f4b71Sopenharmony_ci
86e41f4b71Sopenharmony_ci![en-us_image_0000001127284938](figures/en-us_image_0000001127284938.gif)
87e41f4b71Sopenharmony_ci
88e41f4b71Sopenharmony_ci
89e41f4b71Sopenharmony_ci```html
90e41f4b71Sopenharmony_ci<!-- xxx.hml -->
91e41f4b71Sopenharmony_ci<div class="container">
92e41f4b71Sopenharmony_ci  <svg fill="white" width="600" height="600">
93e41f4b71Sopenharmony_ci    <circle cx="60" cy="70" r="50" stroke-width="4" fill="white" stroke="blue">
94e41f4b71Sopenharmony_ci      <animate attributeName="r" from="0" to="50" dur="2000" repeatCount="indefinite"></animate>
95e41f4b71Sopenharmony_ci      <animate attributeName="cx" from="60" to="200" dur="2000" repeatCount="indefinite"></animate>
96e41f4b71Sopenharmony_ci    </circle>
97e41f4b71Sopenharmony_ci    <circle cx="60" cy="200" r="50" stroke-width="4" fill="white" stroke="blue">
98e41f4b71Sopenharmony_ci      <animate attributeName="stroke-width" from="4" to="10" calcMode="discrete" dur="2000" repeatCount="indefinite"></animate>
99e41f4b71Sopenharmony_ci      <animate attributeName="stroke" values="red;blue" dur="2000" repeatCount="indefinite"></animate>
100e41f4b71Sopenharmony_ci    </circle>
101e41f4b71Sopenharmony_ci    <circle cx="180" cy="200" r="50" stroke-width="10" stroke="red" stroke-dasharray="60 10" stroke-dashoffset="3">
102e41f4b71Sopenharmony_ci      <animate attributeName="stroke-opacity" from="1.0" to="0.5" dur="2000" repeatCount="indefinite"></animate>
103e41f4b71Sopenharmony_ci      <animate attributeName="stroke-dashoffset" values="30;0;30" dur="500" repeatCount="indefinite"></animate>
104e41f4b71Sopenharmony_ci     <animate attributeName="cx" from="180" to="400" dur="2000" repeatCount="indefinite"></animate>
105e41f4b71Sopenharmony_ci    </circle>
106e41f4b71Sopenharmony_ci    <circle cx="180" cy="200" r="5" fill="blue">
107e41f4b71Sopenharmony_ci      <animate attributeName="cx" from="180" to="400" dur="2000" repeatCount="indefinite"></animate>
108e41f4b71Sopenharmony_ci    </circle>
109e41f4b71Sopenharmony_ci    <circle cx="60" cy="380" r="50"  fill="blue">
110e41f4b71Sopenharmony_ci      <animate attributeName="fill" values="red;blue" dur="2000" repeatCount="indefinite"></animate>
111e41f4b71Sopenharmony_ci    </circle>
112e41f4b71Sopenharmony_ci    <circle cx="180" cy="380" r="50"  fill="blue">
113e41f4b71Sopenharmony_ci      <animate attributeName="fill-opacity" from="1.0" to="0.5" dur="2000" repeatCount="indefinite"></animate>
114e41f4b71Sopenharmony_ci    </circle>
115e41f4b71Sopenharmony_ci    </svg>
116e41f4b71Sopenharmony_ci</div>
117e41f4b71Sopenharmony_ci```
118e41f4b71Sopenharmony_ci
119e41f4b71Sopenharmony_ci
120e41f4b71Sopenharmony_ci![en-us_image_0000001127125126](figures/en-us_image_0000001127125126.gif)
121