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, 3 for cross platform. 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 * MINI_RECV mode. 191 * 192 * @syscap SystemCapability.Graphics.Drawing 193 * @systemapi 194 * @since 17 195 */ 196 MINI_RECV = 3, 197 } 198 199 /** 200 * FlyMode enumeration description 201 * 202 * @enum { number } 203 * @syscap SystemCapability.Graphics.Drawing 204 * @systemapi 205 * @since 12 206 */ 207 enum FlyMode { 208 /** 209 * BOTTOM fly mode. 210 * 211 * @syscap SystemCapability.Graphics.Drawing 212 * @systemapi 213 * @since 12 214 */ 215 BOTTOM = 0, 216 217 /** 218 * TOP fly mode. 219 * 220 * @syscap SystemCapability.Graphics.Drawing 221 * @systemapi 222 * @since 12 223 */ 224 TOP = 1, 225 } 226 227 /** 228 * The VisualEffect of Component. 229 * @typedef VisualEffect 230 * @syscap SystemCapability.Graphics.Drawing 231 * @since 12 232 */ 233 interface VisualEffect { 234 /** 235 * A backgroundColorEffect effect is added to the Component. 236 * @param { BrightnessBlender } blender - The blender to blend backgroundColor. 237 * @returns { VisualEffect } VisualEffects for the current effect have been added. 238 * @syscap SystemCapability.Graphics.Drawing 239 * @systemapi 240 * @since 12 241 */ 242 backgroundColorBlender(blender: BrightnessBlender): VisualEffect; 243 } 244 245 /** 246 * Defines the blending effect. 247 * @typedef { BrightnessBlender } 248 * @syscap SystemCapability.Graphics.Drawing 249 * @systemapi 250 * @since 13 251 */ 252 type Blender = BrightnessBlender; 253 254 /** 255 * The Blender of backgroundColorEffect. 256 * @typedef BrightnessBlender 257 * @syscap SystemCapability.Graphics.Drawing 258 * @systemapi 259 * @since 12 260 */ 261 interface BrightnessBlender { 262 /** 263 * Defines third-order rate for grayscale adjustment. 264 * 265 * @type { number } 266 * @syscap SystemCapability.Graphics.Drawing 267 * @systemapi 268 * @since 12 269 */ 270 cubicRate: number; 271 272 /** 273 * Defines second-order rate for grayscale adjustment. 274 * 275 * @type { number } 276 * @syscap SystemCapability.Graphics.Drawing 277 * @systemapi 278 * @since 12 279 */ 280 quadraticRate: number; 281 282 /** 283 * Defines linear rate for grayscale adjustment. 284 * 285 * @type { number } 286 * @syscap SystemCapability.Graphics.Drawing 287 * @systemapi 288 * @since 12 289 */ 290 linearRate: number; 291 292 /** 293 * Defines grayscale adjustment degree. 294 * 295 * @type { number } 296 * @syscap SystemCapability.Graphics.Drawing 297 * @systemapi 298 * @since 12 299 */ 300 degree: number; 301 302 /** 303 * Defines the reference saturation for brightness. 304 * 305 * @type { number } 306 * @syscap SystemCapability.Graphics.Drawing 307 * @systemapi 308 * @since 12 309 */ 310 saturation: number; 311 312 /** 313 * Defines the positive adjustment coefficients in RGB channels based on the reference saturation. 314 * 315 * @type { [number, number, number] } 316 * @syscap SystemCapability.Graphics.Drawing 317 * @systemapi 318 * @since 12 319 */ 320 positiveCoefficient: [number, number, number]; 321 322 /** 323 * Defines the negative adjustment coefficients in RGB channels based on the reference saturation. 324 * 325 * @type { [number, number, number] } 326 * @syscap SystemCapability.Graphics.Drawing 327 * @systemapi 328 * @since 12 329 */ 330 negativeCoefficient: [number, number, number]; 331 332 /** 333 * Defines the blending fraction for brightness effect. 334 * 335 * @type { number } 336 * @syscap SystemCapability.Graphics.Drawing 337 * @systemapi 338 * @since 12 339 */ 340 fraction: number; 341 } 342 343 /** 344 * Create a Filter to add multiple effects to the component. 345 * @returns { Filter } Returns the head node of Filter. 346 * @syscap SystemCapability.Graphics.Drawing 347 * @since 12 348 */ 349 function createFilter(): Filter; 350 351 /** 352 * Create a VisualEffect to add multiple effects to the component. 353 * @returns { VisualEffect } Returns the head node of visualEffect. 354 * @syscap SystemCapability.Graphics.Drawing 355 * @since 12 356 */ 357 function createEffect(): VisualEffect; 358 359 /** 360 * Create a BrightnessBlender to add BrightnessBlender to the component. 361 * @param { BrightnessBlenderParam } param - The brightness blender parameters. 362 * @returns { BrightnessBlender } Returns the blender. 363 * @syscap SystemCapability.Graphics.Drawing 364 * @systemapi 365 * @since 12 366 */ 367 function createBrightnessBlender(param: BrightnessBlenderParam): BrightnessBlender; 368} 369 370/** 371 * The parameters of brightness blender. 372 * @typedef BrightnessBlenderParam 373 * @syscap SystemCapability.Graphics.Drawing 374 * @systemapi 375 * @since 12 376 */ 377declare interface BrightnessBlenderParam { 378 /** 379 * Defines third-order rate for grayscale adjustment. 380 * 381 * @type { number } 382 * @syscap SystemCapability.Graphics.Drawing 383 * @systemapi 384 * @since 12 385 */ 386 cubicRate: number; 387 388 /** 389 * Defines second-order rate for grayscale adjustment. 390 * 391 * @type { number } 392 * @syscap SystemCapability.Graphics.Drawing 393 * @systemapi 394 * @since 12 395 */ 396 quadraticRate: number; 397 398 /** 399 * Defines linear rate for grayscale adjustment. 400 * 401 * @type { number } 402 * @syscap SystemCapability.Graphics.Drawing 403 * @systemapi 404 * @since 12 405 */ 406 linearRate: number; 407 408 /** 409 * Defines grayscale adjustment degree. 410 * 411 * @type { number } 412 * @syscap SystemCapability.Graphics.Drawing 413 * @systemapi 414 * @since 12 415 */ 416 degree: number; 417 418 /** 419 * Defines the reference saturation for brightness. 420 * 421 * @type { number } 422 * @syscap SystemCapability.Graphics.Drawing 423 * @systemapi 424 * @since 12 425 */ 426 saturation: number; 427 428 /** 429 * Defines the positive adjustment coefficients in RGB channels based on the reference saturation. 430 * 431 * @type { [number, number, number] } 432 * @syscap SystemCapability.Graphics.Drawing 433 * @systemapi 434 * @since 12 435 */ 436 positiveCoefficient: [number, number, number]; 437 438 /** 439 * Defines the negative adjustment coefficients in RGB channels based on the reference saturation. 440 * 441 * @type { [number, number, number] } 442 * @syscap SystemCapability.Graphics.Drawing 443 * @systemapi 444 * @since 12 445 */ 446 negativeCoefficient: [number, number, number]; 447 448 /** 449 * Defines the blending fraction for brightness effect. 450 * 451 * @type { number } 452 * @syscap SystemCapability.Graphics.Drawing 453 * @systemapi 454 * @since 12 455 */ 456 fraction: number; 457} 458 459export default uiEffect;