• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2022 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 * Describes an opaque object of a template, which is created using the createPattern() method.
18 * @syscap SystemCapability.ArkUI.ArkUI.Full
19 * @since 8
20 */
21 export interface CanvasPattern {
22  /**
23   * Adds the matrix transformation effect to the current template.
24   * @syscap SystemCapability.ArkUI.ArkUI.Full
25   * @param transform transformation matrix
26   * @since 8
27   */
28  setTransform(transform?: Matrix2D): void;
29}
30
31/**
32 * 2D transformation matrix, supporting rotation, translation, and scaling of the X-axis and Y-axis
33 * @syscap SystemCapability.ArkUI.ArkUI.Full
34 * @since 8
35 */
36export class Matrix2D {
37  /**
38   * Horizontal Zoom
39   * @syscap SystemCapability.ArkUI.ArkUI.Full
40   * @since 8
41   */
42  scaleX?: number;
43
44  /**
45   * Vertical Tilt
46   * @syscap SystemCapability.ArkUI.ArkUI.Full
47   * @since 8
48   */
49  rotateY?: number;
50
51  /**
52   * Horizontal Tilt
53   * @syscap SystemCapability.ArkUI.ArkUI.Full
54   * @since 8
55   */
56  rotateX?: number;
57
58  /**
59   * Vertical Zoom
60   * @syscap SystemCapability.ArkUI.ArkUI.Full
61   * @since 8
62   */
63  scaleY?: number;
64
65  /**
66   * Horizontal movement
67   * @syscap SystemCapability.ArkUI.ArkUI.Full
68   * @since 8
69   */
70  translateX?: number;
71
72  /**
73   * Vertical movement
74   * @syscap SystemCapability.ArkUI.ArkUI.Full
75   * @since 8
76   */
77  translateY?: number;
78
79  /**
80   * Transforms the current 2D matrix back to the identity matrix (i.e., without any rotational
81   * translation scaling effect)
82   * @syscap SystemCapability.ArkUI.ArkUI.Full
83   * @since 8
84   */
85  identity(): Matrix2D;
86
87  /**
88   * Transform the current 2D matrix into an inverse matrix (that is, the transformation effect
89   * is the opposite effect of the original)
90   * @syscap SystemCapability.ArkUI.ArkUI.Full
91   * @since 8
92   */
93  invert(): Matrix2D;
94
95  /**
96   * The matrix is superimposed in right multiplication mode. When the input parameter is empty,
97   * the matrix is superimposed.
98   * @syscap SystemCapability.ArkUI.ArkUI.Full
99   * @param other Matrix to be superimposed
100   * @since 8
101   */
102  multiply(other?: Matrix2D): Matrix2D;
103
104  /**
105   * Adds the rotation effect of the X and Y axes to the current matrix.
106   * @syscap SystemCapability.ArkUI.ArkUI.Full
107   * @param rx Rotation effect of the X axis
108   * @param ry Rotation effect of the Y-axis
109   * @since 8
110   */
111  rotate(rx?: number, ry?: number): Matrix2D;
112
113  /**
114   * Adds the translation effect of the X and Y axes to the current matrix.
115   * @syscap SystemCapability.ArkUI.ArkUI.Full
116   * @param tx X-axis translation effect
117   * @param ty Y-axis translation effect
118   * @since 8
119   */
120  translate(tx?: number, ty?: number): Matrix2D;
121
122  /**
123   * Adds the scaling effect of the X and Y axes to the current matrix.
124   * @syscap SystemCapability.ArkUI.ArkUI.Full
125   * @param sx X-axis scaling effect
126   * @param sy Y-axis scaling effect
127   * @since 8
128   */
129  scale(sx?: number, sy?: number): Matrix2D;
130
131  /**
132   * Constructs a 2D change matrix object. The default value is the unit matrix.
133   * @syscap SystemCapability.ArkUI.ArkUI.Full
134   * @since 8
135   */
136  constructor();
137}