• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2020 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16/**
17 * Used to do matrix operations
18 * @import import Matrix4 from '@ohos.matrix4'
19 * @syscap SystemCapability.ArkUI.ArkUI.Full
20 * @since 7
21 */
22declare namespace matrix4 {
23  /**
24   * Set translation parameters
25   * @syscap SystemCapability.ArkUI.ArkUI.Full
26   * @since 7
27   */
28  interface TranslateOption {
29    /**
30     * Indicates the translation distance of the x-axis, in px.
31     * @since 7
32     */
33    x?: number;
34
35    /**
36     * Indicates the translation distance of the y-axis, in px.
37     * @since 7
38     */
39    y?: number;
40
41    /**
42     * Indicates the translation distance of the z-axis, in px.
43     * @since 7
44     */
45    z?: number;
46  }
47
48  /**
49   * Set scaling parameters
50   * @syscap SystemCapability.ArkUI.ArkUI.Full
51   * @since 7
52   */
53  interface ScaleOption {
54    /**
55     * Zoom factor of the x-axis.
56     * @since 7
57     */
58    x?: number;
59
60    /**
61     * Zoom factor of the y-axis.
62     * @since 7
63     */
64    y?: number;
65
66    /**
67     * Zoom factor of the z-axis.
68     * @since 7
69     */
70    z?: number;
71
72    /**
73     * Transform the x-axis coordinate of the center point.
74     * @since 7
75     */
76    centerX?: number;
77
78    /**
79     * Transform the y-axis coordinate of the center point.
80     * @since 7
81     */
82    centerY?: number;
83  }
84
85  /**
86   * Set Rotation Parameters.
87   * @syscap SystemCapability.ArkUI.ArkUI.Full
88   * @since 7
89   */
90  interface RotateOption {
91    /**
92     * Axis of rotation vector x coordinate.
93     * @since 7
94     */
95    x?: number;
96
97    /**
98     * Axis of rotation vector y coordinate.
99     * @since 7
100     */
101    y?: number;
102
103    /**
104     * Axis of rotation vector z coordinate.
105     * @since 7
106     */
107    z?: number;
108
109    /**
110     * Transform the x-axis coordinate of the center point.
111     * @since 7
112     */
113    centerX?: number;
114
115    /**
116     * Transform the y-axis coordinate of the center point.
117     * @since 7
118     */
119    centerY?: number;
120
121    /**
122     * Rotation angle.
123     * @since 7
124     */
125    angle?: number;
126  }
127
128  /**
129   * Matrix4Transit.
130   * @syscap SystemCapability.ArkUI.ArkUI.Full
131   * @since 7
132   */
133  interface Matrix4Transit {
134    /**
135     * Copy function of Matrix, which can copy a copy of the current matrix object.
136     * @syscap SystemCapability.ArkUI.ArkUI.Full
137     * @since 7
138     * @returns Return to Matrix4Transit
139     */
140    copy(): Matrix4Transit;
141
142    /**
143     * The inverse function of Matrix returns an inverse matrix of the current matrix object, that is, the effect is exactly the opposite.
144     * @syscap SystemCapability.ArkUI.ArkUI.Full
145     * @since 7
146     * @returns Return to Matrix4Transit
147     */
148    invert(): Matrix4Transit;
149
150    /**
151     * Matrix superposition function, which can superpose the effects of two matrices to generate a new matrix object.
152     * @syscap SystemCapability.ArkUI.ArkUI.Full
153     * @since 7
154     * @returns Return to Matrix4Transit
155     */
156    combine(options: Matrix4Transit): Matrix4Transit;
157
158    /**
159     * Matrix translation function, which can add the x-axis, Y-axis, or Z-axis translation effect to the current matrix.
160     * @syscap SystemCapability.ArkUI.ArkUI.Full
161     * @since 7
162     * @returns Return to Matrix4Transit
163     */
164    translate(options: TranslateOption): Matrix4Transit;
165
166    /**
167     * Scaling function of the Matrix, which can add the x-axis, Y-axis, or Z-axis scaling effect to the current matrix.
168     * @syscap SystemCapability.ArkUI.ArkUI.Full
169     * @since 7
170     * @returns Return to Matrix4Transit
171     */
172    scale(options: ScaleOption): Matrix4Transit;
173
174    /**
175     * Rotation function of the Matrix. You can add the x-axis, Y-axis, or Z-axis rotation effect to the current matrix.
176     * @syscap SystemCapability.ArkUI.ArkUI.Full
177     * @since 7
178     * @returns Return to Matrix4Transit
179     */
180    rotate(options: RotateOption): Matrix4Transit;
181
182    /**
183     * Matrix coordinate point conversion function, which can apply the current transformation effect to a coordinate point.
184     * @syscap SystemCapability.ArkUI.ArkUI.Full
185     * @since 7
186     * @returns Return to Matrix4Transit
187     */
188    transformPoint(options: [number, number]): [number, number];
189  }
190
191  /**
192   * Constructor of Matrix, which can create a fourth-order matrix based on the input parameters. The matrix is column-first.
193   * @syscap SystemCapability.ArkUI.ArkUI.Full
194   * @since 7
195   * @returns Return to Matrix4Transit
196   */
197  function init(
198    options: [
199      number,
200      number,
201      number,
202      number,
203      number,
204      number,
205      number,
206      number,
207      number,
208      number,
209      number,
210      number,
211      number,
212      number,
213      number,
214      number,
215    ],
216  ): Matrix4Transit;
217
218  /**
219   * Matrix initialization function, which can return an identity matrix object.
220   * @syscap SystemCapability.ArkUI.ArkUI.Full
221   * @since 7
222   * @returns Return to Matrix4Transit
223   */
224  function identity(): Matrix4Transit;
225
226  /**
227   * Copy function of Matrix, which can copy a copy of the current matrix object.
228   * @syscap SystemCapability.ArkUI.ArkUI.Full
229   * @since 7
230   * @returns Return to Matrix4Transit
231   */
232  function copy(): Matrix4Transit;
233
234  /**
235   * The inverse function of Matrix returns an inverse matrix of the current matrix object, that is, the effect is exactly the opposite.
236   * @syscap SystemCapability.ArkUI.ArkUI.Full
237   * @since 7
238   * @returns Return to Matrix4Transit
239   */
240  function invert(): Matrix4Transit;
241
242  /**
243   * Matrix superposition function, which can superpose the effects of two matrices to generate a new matrix object.
244   * @syscap SystemCapability.ArkUI.ArkUI.Full
245   * @since 7
246   * @returns Return to Matrix4Transit
247   */
248  function combine(options: Matrix4Transit): Matrix4Transit;
249
250  /**
251   * Matrix translation function, which can add the x-axis, Y-axis, or Z-axis translation effect to the current matrix.
252   * @syscap SystemCapability.ArkUI.ArkUI.Full
253   * @since 7
254   * @returns Return to Matrix4Transit
255   */
256  function translate(options: TranslateOption): Matrix4Transit;
257
258  /**
259   * Scaling function of the Matrix, which can add the x-axis, Y-axis, or Z-axis scaling effect to the current matrix.
260   * @syscap SystemCapability.ArkUI.ArkUI.Full
261   * @since 7
262   * @returns Return to Matrix4Transit
263   */
264  function scale(options: ScaleOption): Matrix4Transit;
265
266  /**
267   * Rotation function of the Matrix. You can add the x-axis, Y-axis, or Z-axis rotation effect to the current matrix.
268   * @syscap SystemCapability.ArkUI.ArkUI.Full
269   * @since 7
270   * @returns Return to Matrix4Transit
271   */
272  function rotate(options: RotateOption): Matrix4Transit;
273
274  /**
275   * Matrix coordinate point conversion function, which can apply the current transformation effect to a coordinate point.
276   * @syscap SystemCapability.ArkUI.ArkUI.Full
277   * @since 7
278   * @returns Return to Matrix4Transit
279   */
280  function transformPoint(options: [number, number]): [number, number];
281}
282
283export default matrix4;
284