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