• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (C) 2024 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 * @file
18 * @kit ArkUI
19 */
20
21/// <reference path="../component/units.d.ts" />
22
23/**
24 * Interface for shape size properties.
25 *
26 * @interface ShapeSize
27 * @syscap SystemCapability.ArkUI.ArkUI.Full
28 * @crossplatform
29 * @since 12
30 * @form
31 */
32interface ShapeSize {
33  /**
34   * Defines the width of Shape.
35   * @type { ? (number | string) }
36   * @syscap SystemCapability.ArkUI.ArkUI.Full
37   * @since 12
38   * @form
39   */
40  width?: number | string;
41
42  /**
43   * Defines the height of Shape.
44   * @type { ? (number | string) }
45   * @syscap SystemCapability.ArkUI.ArkUI.Full
46   * @since 12
47   * @form
48   */
49  height?: number | string;
50}
51
52/**
53 * Interface for RectShape constructor parameters.
54 *
55 * @interface RectShapeOptions
56 * @syscap SystemCapability.ArkUI.ArkUI.Full
57 * @crossplatform
58 * @since 12
59 * @form
60 */
61interface RectShapeOptions extends ShapeSize {
62  /**
63   * Defines the corner radius of the RectShape.
64   * @type { ? (number | string | Array<number | string>) }
65   * @syscap SystemCapability.ArkUI.ArkUI.Full
66   * @since 12
67   * @form
68   */
69  radius?: number | string | Array<number | string>;
70}
71
72/**
73 * Interface for RectShape constructor parameters with separate radius values.
74 *
75 * @interface RoundRectShapeOptions
76 * @syscap SystemCapability.ArkUI.ArkUI.Full
77 * @crossplatform
78 * @since 12
79 * @form
80 */
81interface RoundRectShapeOptions extends ShapeSize {
82  /**
83   * Defines the width of the corner radius for RectShape.
84   * @type { ? (number | string) }
85   * @syscap SystemCapability.ArkUI.ArkUI.Full
86   * @since 12
87   * @form
88   */
89  radiusWidth?: number | string;
90
91  /**
92   * Defines the height of the corner radius for RectShape.
93   * @type { ? (number | string) }
94   * @syscap SystemCapability.ArkUI.ArkUI.Full
95   * @since 12
96   * @form
97   */
98  radiusHeight?: number | string;
99}
100
101/**
102 * Interface for PathShape constructor parameters.
103 *
104 * @interface PathShapeOptions
105 * @syscap SystemCapability.ArkUI.ArkUI.Full
106 * @crossplatform
107 * @since 12
108 * @form
109 */
110interface PathShapeOptions {
111  /**
112   * Defines the commands for drawing the PathShape.
113   * @type { ?string }
114   * @syscap SystemCapability.ArkUI.ArkUI.Full
115   * @since 12
116   * @form
117   */
118  commands?: string;
119}
120
121/**
122 * Common shape method class
123 *
124 * @syscap SystemCapability.ArkUI.ArkUI.Full
125 * @crossplatform
126 * @since 12
127 * @form
128 */
129declare class CommonShapeMethod<T> {
130  /**
131   * Sets coordinate offset relative to the layout completion position.
132   *
133   * @param { Position } offset
134   * @returns { T }
135   * @syscap SystemCapability.ArkUI.ArkUI.Full
136   * @crossplatform
137   * @since 12
138   * @form
139   */
140  offset(offset: Position): T;
141
142  /**
143   * Sets the fill color of the shape.
144   *
145   * @param { ResourceColor } color
146   * @returns { T }
147   * @syscap SystemCapability.ArkUI.ArkUI.Full
148   * @crossplatform
149   * @since 12
150   * @form
151   */
152  fill(color: ResourceColor): T;
153
154  /**
155   * Sets the position of the shape.
156   *
157   * @param { Position } position
158   * @returns { T }
159   * @syscap SystemCapability.ArkUI.ArkUI.Full
160   * @crossplatform
161   * @since 12
162   * @form
163   */
164  position(position: Position): T;
165}
166
167/**
168 * Base shape class
169 *
170 * @extends CommonShapeMethod<T>
171 * @syscap SystemCapability.ArkUI.ArkUI.Full
172 * @crossplatform
173 * @since 12
174 * @form
175 */
176declare class BaseShape<T> extends CommonShapeMethod<T> {
177  /**
178   * Sets the width of the shape.
179   *
180   * @param { Length } width
181   * @returns { T }
182   * @syscap SystemCapability.ArkUI.ArkUI.Full
183   * @crossplatform
184   * @since 12
185   * @form
186   */
187  width(width: Length): T;
188
189  /**
190   * Sets the height of the shape.
191   *
192   * @param { Length } height
193   * @returns { T }
194   * @syscap SystemCapability.ArkUI.ArkUI.Full
195   * @crossplatform
196   * @since 12
197   * @form
198   */
199  height(height: Length): T;
200
201  /**
202   * Sets the size of the shape.
203   *
204   * @param { SizeOptions } size
205   * @returns { T }
206   * @syscap SystemCapability.ArkUI.ArkUI.Full
207   * @crossplatform
208   * @since 12
209   * @form
210   */
211  size(size: SizeOptions): T;
212}
213
214/**
215 * Defines a rect drawing class.
216 *
217 * @extends BaseShape<RectShape>
218 * @syscap SystemCapability.ArkUI.ArkUI.Full
219 * @crossplatform
220 * @since 12
221 * @form
222 */
223export declare class RectShape extends BaseShape<RectShape> {
224  /**
225   * Constructor.
226   *
227   * @param { RectShapeOptions | RoundRectShapeOptions } options
228   * @syscap SystemCapability.ArkUI.ArkUI.Full
229   * @crossplatform
230   * @since 12
231   * @form
232   */
233  constructor(options?: RectShapeOptions | RoundRectShapeOptions);
234
235  /**
236   * Sets the width of the corner radius for RectShape.
237   *
238   * @param { number | string } rWidth
239   * @returns { RectShape }
240   * @syscap SystemCapability.ArkUI.ArkUI.Full
241   * @crossplatform
242   * @since 12
243   * @form
244   */
245  radiusWidth(rWidth: number | string): RectShape;
246
247  /**
248   * Sets the height of the corner radius for RectShape.
249   *
250   * @param { number | string } rHeight
251   * @returns { RectShape }
252   * @syscap SystemCapability.ArkUI.ArkUI.Full
253   * @crossplatform
254   * @since 12
255   * @form
256   */
257  radiusHeight(rHeight: number | string): RectShape;
258
259  /**
260   * Sets the corner radius for RectShape.
261   *
262   * @param { number | string | Array<number | string> } radius
263   * @returns { RectShape }
264   * @syscap SystemCapability.ArkUI.ArkUI.Full
265   * @crossplatform
266   * @since 12
267   * @form
268   */
269  radius(radius: number | string | Array<number | string>): RectShape;
270}
271
272/**
273 * Defines a circle drawing class.
274 *
275 * @extends BaseShape<CircleShape>
276 * @syscap SystemCapability.ArkUI.ArkUI.Full
277 * @crossplatform
278 * @since 12
279 * @form
280 */
281export declare class CircleShape extends BaseShape<CircleShape> {
282  /**
283   * Constructor.
284   *
285   * @param { ShapeSize } options
286   * @syscap SystemCapability.ArkUI.ArkUI.Full
287   * @crossplatform
288   * @since 12
289   * @form
290   */
291  constructor(options?: ShapeSize);
292}
293
294/**
295 * Defines an ellipse drawing class.
296 *
297 * @extends BaseShape<EllipseShape>
298 * @syscap SystemCapability.ArkUI.ArkUI.Full
299 * @crossplatform
300 * @since 12
301 * @form
302 */
303export declare class EllipseShape extends BaseShape<EllipseShape> {
304  /**
305   * Constructor.
306   *
307   * @param { ShapeSize } options
308   * @syscap SystemCapability.ArkUI.ArkUI.Full
309   * @crossplatform
310   * @since 12
311   * @form
312   */
313  constructor(options?: ShapeSize);
314}
315
316/**
317 * Defines a path drawing class.
318 *
319 * @extends CommonShapeMethod<PathShape>
320 * @syscap SystemCapability.ArkUI.ArkUI.Full
321 * @crossplatform
322 * @since 12
323 * @form
324 */
325export declare class PathShape extends CommonShapeMethod<PathShape> {
326  /**
327   * Constructor.
328   *
329   * @param { PathShapeOptions } options
330   * @syscap SystemCapability.ArkUI.ArkUI.Full
331   * @crossplatform
332   * @since 12
333   * @form
334   */
335  constructor(options?: PathShapeOptions);
336
337  /**
338   * Sets the commands for drawing the PathShape.
339   *
340   * @param { string } commands
341   * @returns { PathShape }
342   * @syscap SystemCapability.ArkUI.ArkUI.Full
343   * @crossplatform
344   * @since 12
345   * @form
346   */
347  commands(commands: string): PathShape;
348}