• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# @ohos.matrix4 (Matrix Transformation)
2
3The **matrix4** module provides APIs for matrix transformation. You can use these APIs to translate, rotate, and scale images.
4
5> **NOTE**
6>
7> The initial APIs of this module are supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version.
8
9
10## Modules to Import
11
12```ts
13import { matrix4 } from '@kit.ArkUI';
14```
15
16
17## matrix4.init
18
19init(options: [number,number,number,number,number,number,number,number,number,number,number,number,number,number,number,number]): Matrix4Transit
20
21Matrix constructor, which is used to create a 4 x 4 matrix with the input parameters. Column-major order is used.
22
23**Atomic service API**: This API can be used in atomic services since API version 11.
24
25**System capability**: SystemCapability.ArkUI.ArkUI.Full
26
27**Parameters**
28
29| Name| Type                                                        | Mandatory| Description                                                        |
30| ------ | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
31| options | [number,number,number,number,<br>number,number,number,number,<br>number,number,number,number,<br>number,number,number,number] | Yes  | A number array whose length is 16 (4 x 4). For details, see **4 x 4 matrix description**.<br>Value range of each number: (-∞, +∞)<br>Default value:<br>[1, 0, 0, 0,<br>0, 1, 0, 0,<br>0, 0, 1, 0,<br>0, 0, 0, 1] |
32
33**Return value**
34
35| Type                             | Description                        |
36| --------------------------------- | ---------------------------- |
37| [Matrix4Transit](#matrix4transit) | 4 x 4 matrix object created based on the input parameters.|
38
39**4 x 4 matrix description**
40
41| Name | Type    | Mandatory  | Description                  |
42| ---- | ------ | ---- | -------------------- |
43| m00  | number | Yes   | Scaling value of the x-axis. The default value is **1** for the identity matrix.     |
44| m01  | number | Yes   | The second value, which is affected by the rotation or tilt of the x, y, and z axes.  |
45| m02  | number | Yes   | The third value, which is affected by the rotation of the x, y, and z axes.  |
46| m03  | number | Yes   | The fourth value, which is affected by perspective projection.              |
47| m10  | number | Yes   | The fifth value, which is affected by the rotation or tilt of the x, y, and z axes.  |
48| m11  | number | Yes   | Scaling value of the y-axis. The default value is **1** for the identity matrix.     |
49| m12  | number | Yes   | The seventh value, which is affected by the rotation of the x, y, and z axes.  |
50| m13  | number | Yes   | The eighth value, which is affected by perspective projection.              |
51| m20  | number | Yes   | The ninth value, which is affected by the rotation of the x, y, and z axes.  |
52| m21  | number | Yes   | The tenth value, which is affected by the rotation of the x, y, and z axes. |
53| m22  | number | Yes   | Scaling value of the z-axis. The default value is **1** for the identity matrix.     |
54| m23  | number | Yes   | The 12th value, which is affected by perspective projection.              |
55| m30  | number | Yes   | Translation value of the x-axis, in px. The default value is **0** for the identity matrix.|
56| m31  | number | Yes   | Translation value of the y-axis, in px. The default value is **0** for the identity matrix.|
57| m32  | number | Yes   | Translation value of the z-axis, in px. The default value is **0** for the identity matrix.|
58| m33  | number | Yes   | Valid in homogeneous coordinates, presenting the perspective projection effect.   |
59
60**Example**
61
62```ts
63import { matrix4 } from '@kit.ArkUI';
64
65// Create a 4 x 4 matrix.
66let matrix = matrix4.init(
67  [1.0, 0.0, 0.0, 0.0,
68    0.0, 1.0, 0.0, 0.0,
69    0.0, 0.0, 1.0, 0.0,
70    0.0, 0.0, 0.0, 1.0])
71
72@Entry
73@Component
74struct Tests {
75  build() {
76    Column() {
77      Image($r("app.media.zh"))
78        .width("40%")
79        .height(100)
80        .transform(matrix)
81    }
82  }
83}
84```
85
86
87## matrix4.identity
88
89identity(): Matrix4Transit
90
91Constructs an identity matrix.
92
93**Atomic service API**: This API can be used in atomic services since API version 11.
94
95**System capability**: SystemCapability.ArkUI.ArkUI.Full
96
97**Return value**
98
99| Type                             | Description          |
100| --------------------------------- | -------------- |
101| [Matrix4Transit](#matrix4transit) | Identity matrix object.|
102
103**Example**
104
105```ts
106// The effect of matrix 1 is the same as that of matrix 2.
107import { matrix4 } from '@kit.ArkUI';
108
109let matrix1 = matrix4.init(
110  [1.0, 0.0, 0.0, 0.0,
111    0.0, 1.0, 0.0, 0.0,
112    0.0, 0.0, 1.0, 0.0,
113    0.0, 0.0, 0.0, 1.0])
114let matrix2 = matrix4.identity()
115
116@Entry
117@Component
118struct Tests {
119  build() {
120    Column() {
121      Image($r("app.media.zh"))
122        .width("40%")
123        .height(100)
124        .transform(matrix1)
125      Image($r("app.media.zh"))
126        .width("40%")
127        .height(100)
128        .margin({ top: 150 })
129        .transform(matrix2)
130    }
131  }
132}
133```
134
135## Matrix4Transit
136
137Implements a **Matrix4Transit** object.
138
139**Atomic service API**: This API can be used in atomic services since API version 11.
140
141**System capability**: SystemCapability.ArkUI.ArkUI.Full
142
143### copy
144
145copy(): Matrix4Transit
146
147Copies this matrix object.
148
149**Atomic service API**: This API can be used in atomic services since API version 11.
150
151**System capability**: SystemCapability.ArkUI.ArkUI.Full
152
153**Return value**
154
155| Type                             | Description                |
156| --------------------------------- | -------------------- |
157| [Matrix4Transit](#matrix4transit) | Copy object of the current matrix.|
158
159
160**Example**
161
162```ts
163// xxx.ets
164import { matrix4 } from '@kit.ArkUI';
165
166@Entry
167@Component
168struct Test {
169  private matrix1 = matrix4.identity().scale({ x: 1.5 })
170  private matrix2 = this.matrix1.copy().translate({ x: 200 })
171  imageSize: Length = '300px'
172
173  build() {
174    Column({ space: "50px" }) {
175      Image($r("app.media.testImage"))
176        .width(this.imageSize)
177        .height(this.imageSize)
178      Image($r("app.media.testImage"))
179        .width(this.imageSize)
180        .height(this.imageSize)
181        .transform(this.matrix1)
182      Image($r("app.media.testImage"))
183        .width(this.imageSize)
184        .height(this.imageSize)
185        .transform(this.matrix2)
186    }.alignItems(HorizontalAlign.Center)
187    .height('100%').width("100%")
188    .justifyContent(FlexAlign.Center)
189  }
190}
191```
192
193![en-us_image_0000001219744181](figures/en-us_image_0000001219744185.png)
194### combine
195
196combine(options: Matrix4Transit): Matrix4Transit
197
198Combines the effects of two matrices to generate a new matrix object. The original matrix that calls this API will be changed.
199
200**Atomic service API**: This API can be used in atomic services since API version 11.
201
202**System capability**: SystemCapability.ArkUI.ArkUI.Full
203
204**Parameters**
205
206| Name| Type                             | Mandatory| Description              |
207| ------ | --------------------------------- | ---- | ------------------ |
208| options | [Matrix4Transit](#matrix4transit) | Yes  | Matrix object to be combined.|
209
210**Return value**
211
212| Type                             | Description              |
213| --------------------------------- | ------------------ |
214| [Matrix4Transit](#matrix4transit) | Object after matrix combination.|
215
216**Example**
217
218```ts
219// xxx.ets
220import { matrix4 } from '@kit.ArkUI';
221
222@Entry
223@Component
224struct Test {
225  private matrix1 = matrix4.identity().translate({ x: 200 })
226  private matrix2 = matrix4.identity().scale({ x: 2 })
227
228  build() {
229    Column() {
230      // Before matrix transformation
231      Image($r("app.media.icon"))
232        .width("40%")
233        .height(100)
234        .margin({ top: 50 })
235      // Translate the x-axis by 200px, and then scale it twice to obtain the resultant matrix.
236      Image($r("app.media.icon"))
237        .transform(this.matrix1.copy().combine(this.matrix2))
238        .width("40%")
239        .height(100)
240        .margin({ top: 50 })
241    }
242  }
243}
244```
245
246![en-us_image_0000001118642902](figures/en-us_image_0000001118642902.png)
247
248
249### invert
250
251invert(): Matrix4Transit
252
253Inverts this matrix object. The original matrix that calls this API will be changed.
254
255**Atomic service API**: This API can be used in atomic services since API version 11.
256
257**System capability**: SystemCapability.ArkUI.ArkUI.Full
258
259**Return value**
260
261| Type                             | Description                  |
262| --------------------------------- | ---------------------- |
263| [Matrix4Transit](#matrix4transit) | Inverse matrix object of the current matrix.|
264
265**Example**
266
267```ts
268import { matrix4 } from '@kit.ArkUI';
269
270// The effect of matrix 1 (width scaled up by 2x) is opposite to that of matrix 2 (width scaled down by 2x).
271let matrix1 = matrix4.identity().scale({ x: 2 })
272let matrix2 = matrix1.copy().invert()
273
274@Entry
275@Component
276struct Tests {
277  build() {
278    Column() {
279      Image($r("app.media.zh"))
280        .width(200)
281        .height(100)
282        .transform(matrix1)
283        .margin({ top: 100 })
284      Image($r("app.media.zh"))
285        .width(200)
286        .height(100)
287        .margin({ top: 150 })
288        .transform(matrix2)
289    }
290  }
291}
292```
293
294
295### translate
296
297translate(options: TranslateOption): Matrix4Transit
298
299Translates this matrix object along the x, y, and z axes. The original matrix that calls this API will be changed.
300
301**Atomic service API**: This API can be used in atomic services since API version 11.
302
303**System capability**: SystemCapability.ArkUI.ArkUI.Full
304
305**Parameters**
306
307| Name| Type                               | Mandatory| Description          |
308| ------ | ----------------------------------- | ---- | -------------- |
309| options | [TranslateOption](#translateoption) | Yes  | Translation configuration.|
310
311**Return value**
312
313| Type                             | Description                        |
314| --------------------------------- | ---------------------------- |
315| [Matrix4Transit](#matrix4transit) | Matrix object after the translation.|
316
317**Example**
318
319```ts
320// xxx.ets
321import { matrix4 } from '@kit.ArkUI';
322
323@Entry
324@Component
325struct Test {
326  private matrix1 = matrix4.identity().translate({ x: 100, y: 200, z: 30 })
327
328  build() {
329    Column() {
330      Image($r("app.media.bg1")).transform(this.matrix1)
331        .width("40%")
332        .height(100)
333    }
334  }
335}
336```
337
338![en-us_image_0000001219662645](figures/en-us_image_0000001219662645.png)
339
340
341### scale
342
343scale(options: ScaleOption): Matrix4Transit
344
345Scales this matrix object along the x, y, and z axes. The matrix that calls this API will be changed.
346
347**Atomic service API**: This API can be used in atomic services since API version 11.
348
349**System capability**: SystemCapability.ArkUI.ArkUI.Full
350
351**Parameters**
352
353| Name| Type                       | Mandatory| Description          |
354| ------ | --------------------------- | ---- | -------------- |
355| options | [ScaleOption](#scaleoption) | Yes  | Scaling configuration.|
356
357**Return value**
358
359| Type                             | Description                        |
360| --------------------------------- | ---------------------------- |
361| [Matrix4Transit](#matrix4transit) | Matrix object after the scaling.|
362
363**Example**
364
365```ts
366// xxx.ets
367import { matrix4 } from '@kit.ArkUI';
368
369@Entry
370@Component
371struct Test {
372  private matrix1 = matrix4.identity()
373    .scale({
374      x: 2,
375      y: 3,
376      z: 4,
377      centerX: 50,
378      centerY: 50
379    })
380
381  build() {
382    Column() {
383      Image($r("app.media.testImage")).transform(this.matrix1)
384        .width("300px")
385        .height("300px")
386    }.width("100%").height("100%").justifyContent(FlexAlign.Center)
387  }
388}
389```
390
391![en-us_image_0000001219864131](figures/en-us_image_0000001219864131.png)
392
393
394### skew<sup>12+</sup>
395
396skew(x: number, y: number): Matrix4Transit
397
398Skews this matrix object along the x and y axes. The matrix that calls this API will be changed.
399
400**Atomic service API**: This API can be used in atomic services since API version 12.
401
402**System capability**: SystemCapability.ArkUI.ArkUI.Full
403
404**Parameters**
405
406| Name| Type                       | Mandatory| Description          |
407| ------ | --------------------------- | ---- | -------------- |
408| x | number | Yes  | Amount of skewing on the x-axis.|
409| y | number | Yes  | Amount of skewing on the y-axis.|
410
411**Return value**
412
413| Type                             | Description                        |
414| --------------------------------- | ---------------------------- |
415| [Matrix4Transit](#matrix4transit) | Matrix object after the skewing.|
416
417**Example**
418
419```ts
420// xxx.ets
421import { matrix4 } from '@kit.ArkUI';
422
423@Entry
424@Component
425struct Test {
426  private matrix1 = matrix4.identity().skew(2, 3)
427
428  build() {
429    Column() {
430      Image($r("app.media.bg1")).transform(this.matrix1)
431        .height(100)
432        .margin({
433          top: 300
434        })
435    }
436    .width("100%")
437    .height("100%")
438  }
439}
440```
441
442![en-us_image_0000001219864132](figures/en-us_image_0000001219864132.jpeg)
443
444
445### rotate
446
447rotate(options: RotateOption): Matrix4Transit
448
449Rotates this matrix object along the x, y, and z axes. The matrix that calls this API will be changed.
450
451**Atomic service API**: This API can be used in atomic services since API version 11.
452
453**System capability**: SystemCapability.ArkUI.ArkUI.Full
454
455**Parameters**
456
457| Name| Type                         | Mandatory| Description          |
458| ------ | ----------------------------- | ---- | -------------- |
459| options | [RotateOption](#rotateoption) | Yes  | Rotation configuration.|
460
461**Return value**
462
463| Type                             | Description                        |
464| --------------------------------- | ---------------------------- |
465| [Matrix4Transit](#matrix4transit) | Matrix object after the rotation.|
466
467**Example**
468
469```ts
470// xxx.ets
471import { matrix4 } from '@kit.ArkUI';
472
473@Entry
474@Component
475struct Test {
476  private matrix1 = matrix4.identity()
477    .rotate({
478      x: 1,
479      y: 1,
480      z: 2,
481      angle: 30
482    })
483
484  build() {
485    Column() {
486      Image($r("app.media.bg1")).transform(this.matrix1)
487        .width("40%")
488        .height(100)
489    }.width("100%").margin({ top: 50 })
490  }
491}
492```
493
494![en-us_image_0000001174422898](figures/en-us_image_0000001174422898.png)
495
496
497### transformPoint
498
499transformPoint(options: [number, number]): [number, number]
500
501Applies the current transformation effect to a coordinate point.
502
503**Atomic service API**: This API can be used in atomic services since API version 11.
504
505**System capability**: SystemCapability.ArkUI.ArkUI.Full
506
507**Parameters**
508
509| Name | Type            | Mandatory| Description              |
510| ------- | ---------------- | ---- | ------------------ |
511| options | [number, number] | Yes  | Point to be transformed.|
512
513**Return value**
514
515| Type            | Description                       |
516| ---------------- | --------------------------- |
517| [number, number] | Point object after matrix transformation|
518
519**Example**
520
521```ts
522// xxx.ets
523import { matrix4 } from '@kit.ArkUI';
524
525@Entry
526@Component
527struct Test {
528  private originPoint: number[] = [50, 50]
529  private matrix_1 = matrix4.identity().translate({ x: 150, y: -50 })
530  private transformPoint = this.matrix_1.transformPoint([this.originPoint[0], this.originPoint[1]])
531  private matrix_2 = matrix4.identity().translate({ x: this.transformPoint[0], y: this.transformPoint[1] })
532
533  build() {
534    Column() {
535      Text(`Coordinates before matrix transformation: [${this.originPoint}]`)
536        .fontSize(16)
537      Image($r("app.media.image"))
538        .width('600px')
539        .height('300px')
540        .margin({ top: 50 })
541      Text(`Coordinates after matrix transformation: [${this.transformPoint}]`)
542        .fontSize(16)
543        .margin({ top: 100 })
544      Image($r("app.media.image"))
545        .width('600px')
546        .height('300px')
547        .margin({ top: 50 })
548        .transform(this.matrix_2)
549    }.width("100%").padding(50)
550  }
551}
552```
553
554![en-us_image_0000001219864133](figures/en-us_image_0000001219864133.PNG)
555
556### setPolyToPoly<sup>12+</sup>
557
558setPolyToPoly(options: PolyToPolyOptions): Matrix4Transit
559
560Maps the vertex coordinates of a polygon to those of another polygon.
561
562**Atomic service API**: This API can be used in atomic services since API version 12.
563
564**System capability**: SystemCapability.ArkUI.ArkUI.Full
565
566**Parameters**
567
568| Name| Type            | Mandatory| Description              |
569| ------ | ---------------- | ---- | ------------------ |
570| options | [PolyToPolyOptions](#polytopolyoptions12)  | Yes  | Parameters for mapping.|
571
572**Return value**
573
574| Type                             | Description                |
575| --------------------------------- | -------------------- |
576| [Matrix4Transit](#matrix4transit) | Matrix object after the mapping.|
577
578> **NOTE**
579>
580> This API must be used with **scale({centerX:0,centerY:0,x:1})** to ensure that the transformation is centered at the upper left corner of the component.
581
582**Example**
583
584```ts
585import { matrix4 } from '@kit.ArkUI'
586
587@Entry
588@Component
589struct Index {
590  private matrix1 = matrix4.identity().setPolyToPoly({
591    src: [{ x: 0, y: 0 }, { x: 500, y: 0 }, { x: 0, y: 500 }, { x: 500, y: 500 }],
592    dst: [{ x: 0, y: 0 }, { x: 500, y: 0 }, { x: 0, y: 500 }, { x: 750, y: 1000 }], pointCount: 4
593  })
594
595  build() {
596    Stack() {
597      Column().backgroundColor(Color.Blue)
598        .width('500px')
599        .height('500px')
600      Image($r('app.media.transition_image1'))
601        .scale({ centerX: 0, centerY: 0, x: 1 })
602        .transform(this.matrix1)
603        .width('500px')
604        .height('500px')
605    }.width("100%").height("100%").opacity(0.5)
606  }
607}
608```
609![en-us_image_0000001174422898](figures/setPolyTopoly.png)
610## TranslateOption
611
612**Atomic service API**: This API can be used in atomic services since API version 11.
613
614**System capability**: SystemCapability.ArkUI.ArkUI.Full
615
616| Name| Type  | Mandatory| Description                                                       |
617| ---- | ------ | ---- | ----------------------------------------------------------- |
618| x    | number | No  | Translation distance along the x-axis.<br>Unit: px<br>Default value: **0**<br>Value range: (-∞, +∞)|
619| y    | number | No  | Translation distance along the y-axis.<br>Unit: px<br>Default value: **0**<br>Value range: (-∞, +∞)|
620| z    | number | No  | Translation distance along the z-axis.<br>Unit: px<br>Default value: **0**<br>Value range: (-∞, +∞)|
621
622## ScaleOption
623
624**Atomic service API**: This API can be used in atomic services since API version 11.
625
626**System capability**: SystemCapability.ArkUI.ArkUI.Full
627
628| Name   | Type  | Mandatory| Description                                                        |
629| ------- | ------ | ---- | ------------------------------------------------------------ |
630| x       | number | No  | Scaling multiple along the x-axis. x > 1: The image is scaled up along the x-axis.<br>0 < x < 1: The image is scaled down along the x-axis.<br>x < 0: The image is scaled in the reverse direction of the x-axis.<br>Default value: **1**<br>Value range: (-∞, +∞)|
631| y       | number | No  | Scaling multiple along the y-axis. y > 1: The image is scaled up along the y-axis.<br>0 < y < 1: The image is scaled down along the y-axis.<br>y < 0: The image is scaled in the reverse direction of the y-axis.<br>Default value: **1**<br>Value range: (-∞, +∞)|
632| z       | number | No  | Scaling multiple along the z-axis. z > 1: The image is scaled up along the z-axis.<br>0 < z < 1: The image is scaled down along the z-axis.<br>z < 0: The image is scaled in the reverse direction of the z-axis.<br>Default value: **1**<br>Value range: (-∞, +∞)|
633| centerX | number | No  | X coordinate of the center point.<br>Unit: px<br>Default value: X-coordinate of the component center<br>Value range: (-∞, +∞)   |
634| centerY | number | No  | Y coordinate of the center point.<br>Unit: px<br>Default value: Y-coordinate of the component center<br>Value range: (-∞, +∞)   |
635
636## RotateOption
637
638**Atomic service API**: This API can be used in atomic services since API version 11.
639
640**System capability**: SystemCapability.ArkUI.ArkUI.Full
641
642| Name   | Type  | Mandatory| Description                                                        |
643| ------- | ------ | ---- | ------------------------------------------------------------ |
644| x       | number | No  | X coordinate of the rotation axis vector.<br>Default value: **0**<br>Value range: (-∞, +∞)     |
645| y       | number | No  | Y coordinate of the rotation axis vector.<br>Default value: **0**<br>Value range: (-∞, +∞)     |
646| z       | number | No  | Z coordinate of the rotation axis vector.<br>Default value: **0**<br>Value range: (-∞, +∞)<br>**NOTE**<br>The rotation axis vector is valid only when at least one of **x**, **y**, and **z** is not 0.|
647| angle   | number | No  | Rotation angle.<br>Default value: **0**                                    |
648| centerX | number | No  | Additional x-axis offset of the transformation center relative to the component's anchor.<br>Unit: px<br>Default value: **0**<br>**NOTE**<br>The value **0** indicates that the transformation center coincides with the component's x-axis anchor. For details about the implementation, see [Example 3: Implementing Rotation Around a Center Point](arkui-ts/ts-universal-attributes-transformation.md#example-3-implementing-rotation-around-a-center-point).|
649| centerY | number | No  | Additional y-axis offset of the transformation center relative to the component's anchor.<br>Unit: px<br>Default value: **0**<br>**NOTE**<br>The value **0** indicates that the transformation center coincides with the component's y-axis anchor. For details about the implementation, see [Example 3: Implementing Rotation Around a Center Point](arkui-ts/ts-universal-attributes-transformation.md#example-3-implementing-rotation-around-a-center-point).|
650
651## PolyToPolyOptions<sup>12+</sup>
652
653**Atomic service API**: This API can be used in atomic services since API version 12.
654
655**System capability**: SystemCapability.ArkUI.ArkUI.Full
656
657| Name| Type  | Mandatory| Description                                                       |
658| ---- | ------ | ---- | ----------------------------------------------------------- |
659| src    |  Array<[Point](#point12)> | Yes  | Coordinates of the source point.|
660| srcIndex    | number | No  | Start index of the source point coordinates.<br>Default value: **0**.<br> Value range: [0, +∞).|
661| dst    |  Array<[Point](#point12)>  | Yes  | Coordinates of the destination point.|
662| dstIndex    | number | No  |  Start index of the destination point coordinates.<br>Default value: **0**.<br> Value range: [0, +∞).|
663| pointCount    | number | No  | Number of used points.<br>Default value: **src.length/2**.<br> Value range: [0, +∞).|
664
665## Point<sup>12+</sup>
666
667**Atomic service API**: This API can be used in atomic services since API version 12.
668
669**System capability**: SystemCapability.ArkUI.ArkUI.Full
670
671| Name| Type  | Mandatory| Description                                                       |
672| ---- | ------ | ---- | ----------------------------------------------------------- |
673| x    |  number | Yes  | X-coordinate.<br>Value range: (-∞, +∞)|
674| y    | number | Yes  | Y-coordinate.<br>Value range: (-∞, +∞)|
675
676## matrix4.copy<sup>(deprecated)</sup>
677
678copy(): Matrix4Transit
679
680
681Copies this matrix object.
682
683> **NOTE**
684>
685> This API is deprecated since API version 10. You are advised to use [Matrix4Transit.copy](#copy) instead.
686
687
688**System capability**: SystemCapability.ArkUI.ArkUI.Full
689
690**Return value**
691
692| Type                             | Description                |
693| --------------------------------- | -------------------- |
694| [Matrix4Transit](#matrix4transit) | Copy object of the current matrix.|
695
696**Example**
697
698```ts
699// xxx.ets
700import { matrix4 } from '@kit.ArkUI';
701
702@Entry
703@Component
704struct Test {
705  private matrix1 = matrix4.identity().translate({ x: 100 })
706  // Perform the scale operation on the copy matrix of matrix1, which does not affect matrix1.
707  private matrix2 = this.matrix1.copy().scale({ x: 2 })
708
709  build() {
710    Column() {
711      Image($r("app.media.bg1"))
712        .width("40%")
713        .height(100)
714        .transform(this.matrix1)
715      Image($r("app.media.bg2"))
716        .width("40%")
717        .height(100)
718        .margin({ top: 50 })
719        .transform(this.matrix2)
720    }
721  }
722}
723```
724
725![en-us_image_0000001219744181](figures/en-us_image_0000001219744181.png)
726
727## matrix4.invert<sup>(deprecated)</sup>
728
729invert(): Matrix4Transit
730
731Inverts this matrix object.
732
733> **NOTE**
734>
735> This API is deprecated since API version 10. You are advised to use [Matrix4Transit.invert](#invert) instead.
736
737**System capability**: SystemCapability.ArkUI.ArkUI.Full
738
739**Return value**
740
741| Type                             | Description                  |
742| --------------------------------- | ---------------------- |
743| [Matrix4Transit](#matrix4transit) | Inverse matrix object of the current matrix.|
744
745## matrix4.combine<sup>(deprecated)</sup>
746
747combine(options: Matrix4Transit): Matrix4Transit
748
749Combines the effects of two matrices to generate a new matrix object.
750
751> **NOTE**
752>
753> This API is deprecated since API version 10. You are advised to use [Matrix4Transit.combine](#combine) instead.
754
755**System capability**: SystemCapability.ArkUI.ArkUI.Full
756
757**Parameters**
758
759| Name | Type                             | Mandatory| Description              |
760| ------- | --------------------------------- | ---- | ------------------ |
761| options | [Matrix4Transit](#matrix4transit) | Yes  | Matrix object to be combined.|
762
763**Return value**
764
765| Type                             | Description                  |
766| --------------------------------- | ---------------------- |
767| [Matrix4Transit](#matrix4transit) | Matrix object after combination.|
768
769## matrix4.translate<sup>(deprecated)</sup>
770
771translate(options: TranslateOption): Matrix4Transit
772
773Translates this matrix object along the x, y, and z axes.
774
775> **NOTE**
776>
777> This API is deprecated since API version 10. You are advised to use [Matrix4Transit.translate](#translate) instead.
778
779**System capability**: SystemCapability.ArkUI.ArkUI.Full
780
781**Parameters**
782
783| Name | Type                               | Mandatory| Description          |
784| ------- | ----------------------------------- | ---- | -------------- |
785| options | [TranslateOption](#translateoption) | Yes  | Translation configuration.|
786
787**Return value**
788
789| Type                             | Description                  |
790| --------------------------------- | ---------------------- |
791| [Matrix4Transit](#matrix4transit) | Matrix object after translation.|
792
793## matrix4.scale<sup>(deprecated)</sup>
794
795scale(options: ScaleOption): Matrix4Transit
796
797Scales this matrix object along the x, y, and z axes.
798
799> **NOTE**
800>
801> This API is deprecated since API version 10. You are advised to use [Matrix4Transit.scale](#scale) instead.
802
803**System capability**: SystemCapability.ArkUI.ArkUI.Full
804
805**Parameters**
806
807| Name | Type                       | Mandatory| Description          |
808| ------- | --------------------------- | ---- | -------------- |
809| options | [ScaleOption](#scaleoption) | Yes  | Scaling configuration.|
810
811**Return value**
812
813| Type                             | Description                  |
814| --------------------------------- | ---------------------- |
815| [Matrix4Transit](#matrix4transit) | Matrix object after scaling.|
816
817## matrix4.rotate<sup>(deprecated)</sup>
818
819rotate(options: RotateOption): Matrix4Transit
820
821Rotates this matrix object along the x, y, and z axes.
822
823> **NOTE**
824>
825> This API is deprecated since API version 10. You are advised to use [Matrix4Transit.rotate](#rotate) instead.
826
827**System capability**: SystemCapability.ArkUI.ArkUI.Full
828
829**Parameters**
830
831| Name | Type                         | Mandatory| Description          |
832| ------- | ----------------------------- | ---- | -------------- |
833| options | [RotateOption](#rotateoption) | Yes  | Rotation configuration.|
834
835**Return value**
836
837| Type                             | Description                  |
838| --------------------------------- | ---------------------- |
839| [Matrix4Transit](#matrix4transit) | Matrix object after rotation.|
840
841## matrix4.transformPoint<sup>(deprecated)</sup>
842
843transformPoint(options: [number, number]): [number, number]
844
845Applies the current transformation effect to a coordinate point.
846
847> **NOTE**
848>
849> This API is deprecated since API version 10. You are advised to use [Matrix4Transit.transformPoint](#transformpoint) instead.
850
851**System capability**: SystemCapability.ArkUI.ArkUI.Full
852
853**Parameters**
854
855| Name | Type            | Mandatory| Description              |
856| ------- | ---------------- | ---- | ------------------ |
857| options | [number, number] | Yes  | Point to be transformed.|
858
859**Return value**
860
861| Type            | Description                       |
862| ---------------- | --------------------------- |
863| [number, number] | Point object after matrix transformation|
864