1e41f4b71Sopenharmony_ci# Traditional Curve
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ciTraditional curves are mathematically described curves. A typical representative is the cubic Bezier curve. You define the curve shape with a set of control points, to bring out the expected animation effect, such as ease in and ease out. As aforementioned, a traditional curve is not based on the real-world behavior. This means that it does not change its shape to respond to user behavior, and lacks the natural and engaging feel given by a physics-based curve. When creating animations, prioritize physics-based curves and use traditional curves only in rare cases.
4e41f4b71Sopenharmony_ci
5e41f4b71Sopenharmony_ci
6e41f4b71Sopenharmony_ciArkUI provides APIs for traditional curves such as Bezier and step curves. For details, see [Interpolation Calculation](../reference/apis-arkui/js-apis-curve.md).
7e41f4b71Sopenharmony_ci
8e41f4b71Sopenharmony_ci
9e41f4b71Sopenharmony_ciThe following is an example of a traditional curve.
10e41f4b71Sopenharmony_ci
11e41f4b71Sopenharmony_ci
12e41f4b71Sopenharmony_ci
13e41f4b71Sopenharmony_ci```ts
14e41f4b71Sopenharmony_ciclass MyCurve {
15e41f4b71Sopenharmony_ci  public title: string;
16e41f4b71Sopenharmony_ci  public curve: Curve;
17e41f4b71Sopenharmony_ci  public color: Color | string;
18e41f4b71Sopenharmony_ci
19e41f4b71Sopenharmony_ci  constructor(title: string, curve: Curve, color: Color | string = '') {
20e41f4b71Sopenharmony_ci    this.title = title;
21e41f4b71Sopenharmony_ci    this.curve = curve;
22e41f4b71Sopenharmony_ci    this.color = color;
23e41f4b71Sopenharmony_ci  }
24e41f4b71Sopenharmony_ci}
25e41f4b71Sopenharmony_ci
26e41f4b71Sopenharmony_ciconst myCurves: MyCurve[] = [
27e41f4b71Sopenharmony_ci  new MyCurve(' Linear', Curve.Linear, '#317AF7'),
28e41f4b71Sopenharmony_ci  new MyCurve(' Ease', Curve.Ease, '#D94838'),
29e41f4b71Sopenharmony_ci  new MyCurve(' EaseIn', Curve.EaseIn, '#DB6B42'),
30e41f4b71Sopenharmony_ci  new MyCurve(' EaseOut', Curve.EaseOut, '#5BA854'),
31e41f4b71Sopenharmony_ci  new MyCurve(' EaseInOut', Curve.EaseInOut, '#317AF7'),
32e41f4b71Sopenharmony_ci  new MyCurve(' FastOutSlowIn', Curve.FastOutSlowIn, '#D94838')
33e41f4b71Sopenharmony_ci]
34e41f4b71Sopenharmony_ci
35e41f4b71Sopenharmony_ci@Entry
36e41f4b71Sopenharmony_ci@Component
37e41f4b71Sopenharmony_ciexport struct CurveDemo {
38e41f4b71Sopenharmony_ci  @State dRotate: number = 0; // Rotation angle.
39e41f4b71Sopenharmony_ci
40e41f4b71Sopenharmony_ci  build() {
41e41f4b71Sopenharmony_ci    Column() {
42e41f4b71Sopenharmony_ci      // Curve example
43e41f4b71Sopenharmony_ci      Grid() {
44e41f4b71Sopenharmony_ci        ForEach(myCurves, (item: MyCurve) => {
45e41f4b71Sopenharmony_ci          GridItem() {
46e41f4b71Sopenharmony_ci            Column() {
47e41f4b71Sopenharmony_ci              Row()
48e41f4b71Sopenharmony_ci                .width(30)
49e41f4b71Sopenharmony_ci                .height(30)
50e41f4b71Sopenharmony_ci                .borderRadius(15)
51e41f4b71Sopenharmony_ci                .backgroundColor(item.color)
52e41f4b71Sopenharmony_ci              Text(item.title)
53e41f4b71Sopenharmony_ci                .fontSize(15)
54e41f4b71Sopenharmony_ci                .fontColor(0x909399)
55e41f4b71Sopenharmony_ci            }
56e41f4b71Sopenharmony_ci            .width('100%')
57e41f4b71Sopenharmony_ci          }
58e41f4b71Sopenharmony_ci        })
59e41f4b71Sopenharmony_ci      }
60e41f4b71Sopenharmony_ci      .columnsTemplate('1fr 1fr 1fr')
61e41f4b71Sopenharmony_ci      .rowsTemplate('1fr 1fr 1fr 1fr 1fr')
62e41f4b71Sopenharmony_ci      .padding(10)
63e41f4b71Sopenharmony_ci      .width('100%')
64e41f4b71Sopenharmony_ci      .height(300).margin({top:50})
65e41f4b71Sopenharmony_ci
66e41f4b71Sopenharmony_ci      Stack() {
67e41f4b71Sopenharmony_ci        // Swing pipe
68e41f4b71Sopenharmony_ci        Row()
69e41f4b71Sopenharmony_ci          .width(290)
70e41f4b71Sopenharmony_ci          .height(290)
71e41f4b71Sopenharmony_ci          .border({
72e41f4b71Sopenharmony_ci            width: 15,
73e41f4b71Sopenharmony_ci            color: 0xE6E8EB,
74e41f4b71Sopenharmony_ci            radius: 145
75e41f4b71Sopenharmony_ci          })
76e41f4b71Sopenharmony_ci
77e41f4b71Sopenharmony_ci        ForEach(myCurves, (item: MyCurve) => {
78e41f4b71Sopenharmony_ci          // Balls
79e41f4b71Sopenharmony_ci          Column() {
80e41f4b71Sopenharmony_ci            Row()
81e41f4b71Sopenharmony_ci              .width(30)
82e41f4b71Sopenharmony_ci              .height(30)
83e41f4b71Sopenharmony_ci              .borderRadius(15)
84e41f4b71Sopenharmony_ci              .backgroundColor(item.color)
85e41f4b71Sopenharmony_ci          }
86e41f4b71Sopenharmony_ci          .width(20)
87e41f4b71Sopenharmony_ci          .height(300)
88e41f4b71Sopenharmony_ci          .rotate({ angle: this.dRotate })
89e41f4b71Sopenharmony_ci          .animation({ duration: 2000, iterations: -1, curve: item.curve, delay: 100 })
90e41f4b71Sopenharmony_ci        })
91e41f4b71Sopenharmony_ci      }
92e41f4b71Sopenharmony_ci      .width('100%')
93e41f4b71Sopenharmony_ci      .height(200)
94e41f4b71Sopenharmony_ci      .onClick(() => {
95e41f4b71Sopenharmony_ci        this.dRotate ? null : this.dRotate = 360;
96e41f4b71Sopenharmony_ci      })
97e41f4b71Sopenharmony_ci    }
98e41f4b71Sopenharmony_ci    .width('100%')
99e41f4b71Sopenharmony_ci  }
100e41f4b71Sopenharmony_ci}
101e41f4b71Sopenharmony_ci```
102e41f4b71Sopenharmony_ci
103e41f4b71Sopenharmony_ci
104e41f4b71Sopenharmony_ci![en-us_image_0000001641260233](figures/en-us_image_0000001641260233.gif)
105