• 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 ArkGraphics2D
19 */
20
21import { AsyncCallback } from './@ohos.base';
22
23
24/**
25 * @namespace uiEffect
26 * @syscap SystemCapability.Graphics.Drawing
27 * @since 12
28 */
29declare namespace uiEffect {
30
31  /**
32   * The Filter for Component.
33   * @typedef Filter
34   * @syscap SystemCapability.Graphics.Drawing
35   * @since 12
36   */
37  interface Filter {
38    /**
39     * Set the edge pixel stretch effect of the Component.
40     *
41     * @param { Array<number> } stretchSizes
42     * @param { TileMode } tileMode
43     * @returns { Filter }
44     * @syscap SystemCapability.Graphics.Drawing
45     * @systemapi
46     * @since 12
47     */
48    pixelStretch(stretchSizes: Array<number>, tileMode: TileMode): Filter;
49
50    /**
51     * Set blur effect of the Component.
52     *
53     * @param { number } blurRadius
54     * @returns { Filter }
55     * @syscap SystemCapability.Graphics.Drawing
56     * @since 12
57     */
58    blur(blurRadius: number): Filter;
59
60    /**
61     * Set waterRipple effect of the Component.
62     *
63     * @param { number } progress - Indicates the ripple progress. The value 1 indicates that ripples are displayed on all screens.
64     * @param { number } waveCount - The number of waves when the water ripples. The maximum count of waves is 3, the minimum value is 1,  default is 2.
65     * @param { number } x - Represents the X-axis position of center point  where the water ripple first appears on the screen.
66     * @param { number } y - Represents the Y-axis position of center point  where the water ripple first appears on the screen.
67     * @param { WaterRippleMode } rippleMode - Set the mode of water ripple,
68     * 0 for mobile to desktop(Receive), 1 for mobile to desktop(Send), 2 for mobile to mobile.
69     * @returns { Filter } - Returns  water ripple Filter.
70     * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API.
71     * @syscap SystemCapability.Graphics.Drawing
72     * @systemapi
73     * @since 12
74     */
75    waterRipple(progress: number, waveCount: number, x: number, y: number, rippleMode: WaterRippleMode): Filter;
76
77    /**
78     * Set the fly in or fly out effect of the component.
79     *
80     * @param { number } degree - set the degree of fly in or fly out effect, value range [0, 1].
81     * @param { FlyMode } flyMode - set the location of stretching when fly in or out
82     * If the value is 0, the component keep same, else the value is 1, component are fully fly out or fly in.
83     * @returns { Filter } - Returns  fly in fly out Filter.
84     * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API.
85     * @syscap SystemCapability.Graphics.Drawing
86     * @systemapi
87     * @since 12
88     */
89    flyInFlyOutEffect(degree: number, flyMode: FlyMode): Filter;
90
91    /**
92     * Set distort effect of the component.
93     *
94     * @param { number } distortionK - set the degree of distort effect, value range [-1, 1].
95     * If the value is 0, the component keep same,
96     * if the value is less than 0, the component is barrel distortion,
97     * if the value is more than 0, the component is pincushion distortion.
98     * @returns { Filter } - Returns distort Filter.
99     * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API.
100     * @syscap SystemCapability.Graphics.Drawing
101     * @systemapi
102     * @since 13
103     */
104    distort(distortionK: number): Filter;
105  }
106
107  /**
108   * TileMode enumeration description
109   *
110   * @enum { number }
111   * @syscap SystemCapability.Graphics.Drawing
112   * @systemapi
113   * @since 12
114   */
115  enum TileMode {
116    /**
117     * Clamp mode.
118     *
119     * @syscap SystemCapability.Graphics.Drawing
120     * @systemapi
121     * @since 12
122     */
123    CLAMP = 0,
124
125    /**
126     * Repeat mode.
127     *
128     * @syscap SystemCapability.Graphics.Drawing
129     * @systemapi
130     * @since 12
131     */
132    REPEAT = 1,
133
134    /**
135     * Mirror mode.
136     *
137     * @syscap SystemCapability.Graphics.Drawing
138     * @systemapi
139     * @since 12
140     */
141    MIRROR = 2,
142
143    /**
144     * Decal mode.
145     *
146     * @syscap SystemCapability.Graphics.Drawing
147     * @systemapi
148     * @since 12
149     */
150    DECAL = 3,
151  }
152
153  /**
154   * WaterRippleMode enumeration description
155   *
156   * @enum { number }
157   * @syscap SystemCapability.Graphics.Drawing
158   * @systemapi
159   * @since 12
160   */
161  enum WaterRippleMode {
162    /**
163     * SMALL2MEDIUM_RECV mode.
164     *
165     * @syscap SystemCapability.Graphics.Drawing
166     * @systemapi
167     * @since 12
168     */
169    SMALL2MEDIUM_RECV = 0,
170
171    /**
172     * SMALL2MEDIUM_SEND mode.
173     *
174     * @syscap SystemCapability.Graphics.Drawing
175     * @systemapi
176     * @since 12
177     */
178    SMALL2MEDIUM_SEND = 1,
179
180    /**
181     * SMALL2SMALL mode.
182     *
183     * @syscap SystemCapability.Graphics.Drawing
184     * @systemapi
185     * @since 12
186     */
187    SMALL2SMALL = 2,
188  }
189
190  /**
191   * FlyMode enumeration description
192   *
193   * @enum { number }
194   * @syscap SystemCapability.Graphics.Drawing
195   * @systemapi
196   * @since 12
197   */
198  enum FlyMode {
199    /**
200     * BOTTOM fly mode.
201     *
202     * @syscap SystemCapability.Graphics.Drawing
203     * @systemapi
204     * @since 12
205     */
206    BOTTOM = 0,
207
208    /**
209     * TOP fly mode.
210     *
211     * @syscap SystemCapability.Graphics.Drawing
212     * @systemapi
213     * @since 12
214     */
215    TOP = 1,
216  }
217
218  /**
219   * The VisualEffect of Component.
220   * @typedef VisualEffect
221   * @syscap SystemCapability.Graphics.Drawing
222   * @since 12
223   */
224  interface VisualEffect {
225    /**
226    * A backgroundColorEffect effect is added to the Component.
227    * @param { BrightnessBlender } blender - The blender to blend backgroundColor.
228    * @returns { VisualEffect } VisualEffects for the current effect have been added.
229    * @syscap SystemCapability.Graphics.Drawing
230    * @systemapi
231    * @since 12
232    */
233    backgroundColorBlender(blender: BrightnessBlender): VisualEffect;
234  }
235
236  /**
237   * Defines the blending effect.
238   * @typedef Blender
239   * @syscap SystemCapability.Graphics.Drawing
240   * @systemapi
241   * @since 13
242   */
243  type Blender = BrightnessBlender;
244
245  /**
246   * The Blender of backgroundColorEffect.
247   * @typedef BrightnessBlender
248   * @syscap SystemCapability.Graphics.Drawing
249   * @systemapi
250   * @since 12
251   */
252  interface BrightnessBlender {
253    /**
254     * Defines third-order rate for grayscale adjustment.
255     *
256     * @type { number }
257     * @syscap SystemCapability.Graphics.Drawing
258     * @systemapi
259     * @since 12
260     */
261    cubicRate: number;
262
263    /**
264     * Defines second-order rate for grayscale adjustment.
265     *
266     * @type { number }
267     * @syscap SystemCapability.Graphics.Drawing
268     * @systemapi
269     * @since 12
270     */
271    quadraticRate: number;
272
273    /**
274     * Defines linear rate for grayscale adjustment.
275     *
276     * @type { number }
277     * @syscap SystemCapability.Graphics.Drawing
278     * @systemapi
279     * @since 12
280     */
281    linearRate: number;
282
283    /**
284     * Defines grayscale adjustment degree.
285     *
286     * @type { number }
287     * @syscap SystemCapability.Graphics.Drawing
288     * @systemapi
289     * @since 12
290     */
291    degree: number;
292
293    /**
294     * Defines the reference saturation for brightness.
295     *
296     * @type { number }
297     * @syscap SystemCapability.Graphics.Drawing
298     * @systemapi
299     * @since 12
300     */
301    saturation: number;
302
303    /**
304     * Defines the positive adjustment coefficients in RGB channels based on the reference saturation.
305     *
306     * @type { [number, number, number] }
307     * @syscap SystemCapability.Graphics.Drawing
308     * @systemapi
309     * @since 12
310     */
311    positiveCoefficient: [number, number, number];
312
313    /**
314     * Defines the negative adjustment coefficients in RGB channels based on the reference saturation.
315     *
316     * @type { [number, number, number] }
317     * @syscap SystemCapability.Graphics.Drawing
318     * @systemapi
319     * @since 12
320     */
321    negativeCoefficient: [number, number, number];
322
323    /**
324     * Defines the blending fraction for brightness effect.
325     *
326     * @type { number }
327     * @syscap SystemCapability.Graphics.Drawing
328     * @systemapi
329     * @since 12
330     */
331    fraction: number;
332  }
333
334  /**
335   * Create a Filter to add multiple effects to the component.
336   * @returns { Filter } Returns the head node of Filter.
337   * @syscap SystemCapability.Graphics.Drawing
338   * @since 12
339   */
340  function createFilter(): Filter;
341
342  /**
343   * Create a VisualEffect to add multiple effects to the component.
344   * @returns { VisualEffect } Returns the head node of visualEffect.
345   * @syscap SystemCapability.Graphics.Drawing
346   * @since 12
347   */
348  function createEffect(): VisualEffect;
349
350  /**
351   * Create a BrightnessBlender to add BrightnessBlender to the component.
352   * @param { BrightnessBlenderParam } param - The brightness blender parameters.
353   * @returns { BrightnessBlender } Returns the blender.
354   * @syscap SystemCapability.Graphics.Drawing
355   * @systemapi
356   * @since 12
357   */
358  function createBrightnessBlender(param: BrightnessBlenderParam): BrightnessBlender;
359}
360
361/**
362 * The parameters of brightness blender.
363 * @typedef BrightnessBlenderParam
364 * @syscap SystemCapability.Graphics.Drawing
365 * @systemapi
366 * @since 12
367 */
368declare interface BrightnessBlenderParam {
369  /**
370   * Defines third-order rate for grayscale adjustment.
371   *
372   * @type { number }
373   * @syscap SystemCapability.Graphics.Drawing
374   * @systemapi
375   * @since 12
376   */
377  cubicRate: number;
378
379  /**
380   * Defines second-order rate for grayscale adjustment.
381   *
382   * @type { number }
383   * @syscap SystemCapability.Graphics.Drawing
384   * @systemapi
385   * @since 12
386   */
387  quadraticRate: number;
388
389  /**
390   * Defines linear rate for grayscale adjustment.
391   *
392   * @type { number }
393   * @syscap SystemCapability.Graphics.Drawing
394   * @systemapi
395   * @since 12
396   */
397  linearRate: number;
398
399  /**
400   * Defines grayscale adjustment degree.
401   *
402   * @type { number }
403   * @syscap SystemCapability.Graphics.Drawing
404   * @systemapi
405   * @since 12
406   */
407  degree: number;
408
409  /**
410   * Defines the reference saturation for brightness.
411   *
412   * @type { number }
413   * @syscap SystemCapability.Graphics.Drawing
414   * @systemapi
415   * @since 12
416   */
417  saturation: number;
418
419  /**
420   * Defines the positive adjustment coefficients in RGB channels based on the reference saturation.
421   *
422   * @type { [number, number, number] }
423   * @syscap SystemCapability.Graphics.Drawing
424   * @systemapi
425   * @since 12
426   */
427  positiveCoefficient: [number, number, number];
428
429  /**
430   * Defines the negative adjustment coefficients in RGB channels based on the reference saturation.
431   *
432   * @type { [number, number, number] }
433   * @syscap SystemCapability.Graphics.Drawing
434   * @systemapi
435   * @since 12
436   */
437  negativeCoefficient: [number, number, number];
438
439  /**
440   * Defines the blending fraction for brightness effect.
441   *
442   * @type { number }
443   * @syscap SystemCapability.Graphics.Drawing
444   * @systemapi
445   * @since 12
446   */
447  fraction: number;
448}
449
450export default uiEffect;