1/* 2 * Copyright (c) 2020 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 21import { OffscreenCanvasRenderingContext2D } from './viewmodel' 22 23/** 24 * Sets the interval for repeatedly calling a function. 25 * 26 * @param { Function | string } handler - Indicates the function to be called after the timer goes off. 27 * For devices of "tv", "phone, tablet", and "wearable" types, this parameter can be a function or string. 28 * For devices of "lite wearable" and "smartVision" types, this parameter must be a function. 29 * @param { number } delay - Indicates the interval between each two calls, in milliseconds. The function will be called after this delay. 30 * @param { any[] } arguments - Indicates additional arguments to pass to "handler" when the timer goes off. 31 * @returns { number } Returns the timer ID. 32 * @syscap SystemCapability.ArkUI.ArkUI.Lite 33 * @since 3 34 */ 35export declare function setInterval(handler: Function | string, delay: number, ...arguments: any[]): number; 36 37/** 38 * Sets a timer after which a function will be executed. 39 * 40 * @param { Function | string } handler - Indicates the function to be called after the timer goes off. 41 * For devices of "tv", "phone, tablet", and "wearable" types, this parameter can be a function or string. 42 * For devices of "lite wearable" and "smartVision" types, this parameter must be a function. 43 * @param { number } [delay] - Indicates the delay (in milliseconds) after which the function will be called. 44 * If this parameter is left empty, default value "0" will be used, which means that the function will be called immediately or as soon as possible. 45 * @param { any[] } arguments - Indicates additional arguments to pass to "handler" when the timer goes off. 46 * @returns { number } Returns the timer ID. 47 * @syscap SystemCapability.ArkUI.ArkUI.Lite 48 * @since 3 49 */ 50export declare function setTimeout(handler: Function | string, delay?: number, ...arguments: any[]): number; 51 52/** 53 * Sets a vsync after which a function will be executed. 54 * 55 * @param { Function } handler - Indicates the function to be called when the vsync trigger. 56 * @returns { number } 57 * @syscap SystemCapability.ArkUI.ArkUI.Full 58 * @since 3 59 */ 60/** 61 * Sets a vsync after which a function will be executed. 62 * 63 * @param { Function } handler - Indicates the function to be called when the vsync trigger. 64 * @returns { number } 65 * @syscap SystemCapability.ArkUI.ArkUI.Full 66 * @atomicservice 67 * @since 11 68 */ 69export declare function requestAnimationFrame(handler: Function): number; 70 71/** 72 * Cancels the vsync callback set by "requestAnimationFrame()". 73 * 74 * @param { number } requestId - Indicates the vsync callback ID returned by "requestAnimationFrame()". 75 * @syscap SystemCapability.ArkUI.ArkUI.Full 76 * @since 3 77 */ 78/** 79 * Cancels the vsync callback set by "requestAnimationFrame()". 80 * 81 * @param { number } requestId - Indicates the vsync callback ID returned by "requestAnimationFrame()". 82 * @syscap SystemCapability.ArkUI.ArkUI.Full 83 * @atomicservice 84 * @since 11 85 */ 86export declare function cancelAnimationFrame(requestId: number): void; 87 88/** 89 * Cancels the interval set by " setInterval()". 90 * 91 * @param { number } [intervalID] - Indicates the timer ID returned by "setInterval()". 92 * @syscap SystemCapability.ArkUI.ArkUI.Lite 93 * @since 3 94 */ 95export declare function clearInterval(intervalID?: number): void; 96 97/** 98 * Cancels the timer set by "setTimeout()". 99 * 100 * @param { number } [timeoutID] - Indicates the timer ID returned by "setTimeout()". 101 * @syscap SystemCapability.ArkUI.ArkUI.Lite 102 * @since 3 103 */ 104export declare function clearTimeout(timeoutID?: number): void; 105 106/** 107 * Get the java interface instance. The java instance needs to register, otherwise it cannot be obtained. 108 * After obtaining the instance, you can call the function with the same name on the Java side. 109 * 110 * @param { string } [name] - Java interface name, including package path, such as com.example.test.timeinterfaceimpl. 111 * @returns { any } A promise object is returned. The resolve callback is the object of PA. 112 * The reject callback returns the object containing code and error data. 113 * @syscap SystemCapability.ArkUI.ArkUI.Lite 114 * @since 5 115 * @deprecated since 8 116 */ 117export declare function createLocalParticleAbility(name?: string): any; 118 119/** 120 * Defining syscap function. 121 * 122 * @param { string } syscap 123 * @returns { boolean } 124 * @syscap SystemCapability.ArkUI.ArkUI.Lite 125 * @since 8 126 */ 127export declare function canIUse(syscap: string): boolean; 128 129/** 130 * Obtain the objects exposed in app.js 131 * 132 * @returns { object } 133 * @syscap SystemCapability.ArkUI.ArkUI.Lite 134 * @since 6 135 */ 136export declare function getApp(): object; 137 138/** 139 * You can create an Image object by calling new Image(). 140 * 141 * @syscap SystemCapability.ArkUI.ArkUI.Full 142 * @since 4 143 */ 144/** 145 * You can create an Image object by calling new Image(). 146 * 147 * @syscap SystemCapability.ArkUI.ArkUI.Full 148 * @atomicservice 149 * @since 11 150 */ 151export declare class Image { 152 /** 153 * Network address or local resource. The internal URI is supported. 154 * 155 * @type { string } 156 * @syscap SystemCapability.ArkUI.ArkUI.Full 157 * @since 4 158 */ 159 /** 160 * Network address or local resource. The internal URI is supported. 161 * 162 * @type { string } 163 * @syscap SystemCapability.ArkUI.ArkUI.Full 164 * @atomicservice 165 * @since 11 166 */ 167 src: string; 168 /** 169 * Image width. 170 * 171 * @type { ?number } 172 * @syscap SystemCapability.ArkUI.ArkUI.Full 173 * @since 4 174 */ 175 /** 176 * Image width. 177 * 178 * @type { ?number } 179 * @syscap SystemCapability.ArkUI.ArkUI.Full 180 * @atomicservice 181 * @since 11 182 */ 183 width?: number; 184 /** 185 * Image height. 186 * 187 * @type { ?number } 188 * @syscap SystemCapability.ArkUI.ArkUI.Full 189 * @since 4 190 */ 191 /** 192 * Image height. 193 * 194 * @type { ?number } 195 * @syscap SystemCapability.ArkUI.ArkUI.Full 196 * @atomicservice 197 * @since 11 198 */ 199 height?: number; 200 /** 201 * Called when an image is successfully loaded. This function has no parameter. 202 * 203 * @type { ?function } 204 * @syscap SystemCapability.ArkUI.ArkUI.Full 205 * @since 4 206 */ 207 /** 208 * Called when an image is successfully loaded. This function has no parameter. 209 * 210 * @type { ?function } 211 * @syscap SystemCapability.ArkUI.ArkUI.Full 212 * @atomicservice 213 * @since 11 214 */ 215 onload?: () => void; 216 /** 217 * Called when an image fails to be loaded. This function has no parameter. 218 * 219 * @type { ?function } 220 * @syscap SystemCapability.ArkUI.ArkUI.Full 221 * @since 4 222 */ 223 /** 224 * Called when an image fails to be loaded. This function has no parameter. 225 * 226 * @type { ?function } 227 * @syscap SystemCapability.ArkUI.ArkUI.Full 228 * @atomicservice 229 * @since 11 230 */ 231 onerror?: () => void; 232} 233 234/** 235 * An ImageData object is a common object that stores the actual pixel data of a Canvas object. 236 * 237 * @syscap SystemCapability.ArkUI.ArkUI.Full 238 * @since 4 239 */ 240/** 241 * An ImageData object is a common object that stores the actual pixel data of a Canvas object. 242 * 243 * @syscap SystemCapability.ArkUI.ArkUI.Full 244 * @atomicservice 245 * @since 11 246 */ 247export declare class ImageData { 248 /** 249 * Actual width of the ImageData object, in pixels. 250 * 251 * @type { number } 252 * @syscap SystemCapability.ArkUI.ArkUI.Full 253 * @since 4 254 */ 255 /** 256 * Actual width of the ImageData object, in pixels. 257 * 258 * @type { number } 259 * @syscap SystemCapability.ArkUI.ArkUI.Full 260 * @atomicservice 261 * @since 11 262 */ 263 width: number; 264 /** 265 * Actual height of the ImageData object, in pixels. 266 * 267 * @type { number } 268 * @syscap SystemCapability.ArkUI.ArkUI.Full 269 * @since 4 270 */ 271 /** 272 * Actual height of the ImageData object, in pixels. 273 * 274 * @type { number } 275 * @syscap SystemCapability.ArkUI.ArkUI.Full 276 * @atomicservice 277 * @since 11 278 */ 279 height: number; 280 /** 281 * A one-dimensional array of color values. The color values are sorted in the RGBA order and represented by integers from 0 to 255. 282 * 283 * @type { Uint8ClampedArray } 284 * @syscap SystemCapability.ArkUI.ArkUI.Full 285 * @since 4 286 */ 287 /** 288 * A one-dimensional array of color values. The color values are sorted in the RGBA order and represented by integers from 0 to 255. 289 * 290 * @type { Uint8ClampedArray } 291 * @syscap SystemCapability.ArkUI.ArkUI.Full 292 * @atomicservice 293 * @since 11 294 */ 295 data: Uint8ClampedArray; 296} 297 298/** 299 * OffscreenCanvas provides a Canvas object that can be rendered off-screen. 300 * It works in both window and Web worker environments. 301 * 302 * @syscap SystemCapability.ArkUI.ArkUI.Full 303 * @since 7 304 */ 305/** 306 * OffscreenCanvas provides a Canvas object that can be rendered off-screen. 307 * It works in both window and Web worker environments. 308 * 309 * @syscap SystemCapability.ArkUI.ArkUI.Full 310 * @atomicservice 311 * @since 11 312 */ 313export declare class OffscreenCanvas { 314 /** 315 * The width of the offScreen Canvas object 316 * The height of the offScreen Canvas object 317 * 318 * @param { number } width 319 * @param { number } height 320 * @syscap SystemCapability.ArkUI.ArkUI.Full 321 * @since 7 322 */ 323 /** 324 * The width of the offScreen Canvas object 325 * The height of the offScreen Canvas object 326 * 327 * @param { number } width 328 * @param { number } height 329 * @syscap SystemCapability.ArkUI.ArkUI.Full 330 * @atomicservice 331 * @since 11 332 */ 333 constructor(width: number, height: number); 334 335 /** 336 * The width of the offScreen Canvas object 337 * 338 * @type { number } 339 * @syscap SystemCapability.ArkUI.ArkUI.Full 340 * @since 7 341 */ 342 /** 343 * The width of the offScreen Canvas object 344 * 345 * @type { number } 346 * @syscap SystemCapability.ArkUI.ArkUI.Full 347 * @atomicservice 348 * @since 11 349 */ 350 width: number; 351 352 /** 353 * The height of the offScreen Canvas object 354 * 355 * @type { number } 356 * @syscap SystemCapability.ArkUI.ArkUI.Full 357 * @since 7 358 */ 359 /** 360 * The height of the offScreen Canvas object 361 * 362 * @type { number } 363 * @syscap SystemCapability.ArkUI.ArkUI.Full 364 * @atomicservice 365 * @since 11 366 */ 367 height: number; 368 369 /** 370 * Gets the context object for off-screen drawing. 371 * 372 * @param { "2d" } contextId - creates a CanvasRenderingContext2D object representing a two-dimensional rendering context. 373 * @param { CanvasRenderingContext2DSettings } [options] - object representing a three-dimensional rendering context. 374 * @returns { OffscreenCanvasRenderingContext2D } a render canvas for the offScreen Canvas object. 375 * @syscap SystemCapability.ArkUI.ArkUI.Full 376 * @since 7 377 */ 378 /** 379 * Gets the context object for off-screen drawing. 380 * 381 * @param { "2d" } contextId - creates a CanvasRenderingContext2D object representing a two-dimensional rendering context. 382 * @param { CanvasRenderingContext2DSettings } [options] - object representing a three-dimensional rendering context. 383 * @returns { OffscreenCanvasRenderingContext2D } a render canvas for the offScreen Canvas object. 384 * @syscap SystemCapability.ArkUI.ArkUI.Full 385 * @atomicservice 386 * @since 11 387 */ 388 getContext(contextId: "2d", options?: CanvasRenderingContext2DSettings): OffscreenCanvasRenderingContext2D; 389 390 /** 391 * Converts the draw contents of the current off-screen draw object to a string in the form of a Blob. 392 * 393 * @param { string } [type] - indicating the image format. 394 * @param { number } [quality] - between 0 and 1 indicating image quality if the type option is image/jpeg or image/webp. 395 * @returns { string } A Promise returning a Blob object representing the image contained in the canvas. 396 * @syscap SystemCapability.ArkUI.ArkUI.Full 397 * @since 7 398 */ 399 /** 400 * Converts the draw contents of the current off-screen draw object to a string in the form of a Blob. 401 * 402 * @param { string } [type] - indicating the image format. 403 * @param { number } [quality] - between 0 and 1 indicating image quality if the type option is image/jpeg or image/webp. 404 * @returns { string } A Promise returning a Blob object representing the image contained in the canvas. 405 * @syscap SystemCapability.ArkUI.ArkUI.Full 406 * @atomicservice 407 * @since 11 408 */ 409 toDataURL(type?: string, quality?: number): string; 410 411 /** 412 * Converts the draw content in the current off-screen draw object to a Bitmap object. 413 * 414 * @returns { ImageBitmap } Returns An ImageBitmap object. 415 * @syscap SystemCapability.ArkUI.ArkUI.Full 416 * @since 7 417 */ 418 /** 419 * Converts the draw content in the current off-screen draw object to a Bitmap object. 420 * 421 * @returns { ImageBitmap } Returns An ImageBitmap object. 422 * @syscap SystemCapability.ArkUI.ArkUI.Full 423 * @atomicservice 424 * @since 11 425 */ 426 transferToImageBitmap(): ImageBitmap; 427} 428 429/** 430 * Defines the ImageBitmap. 431 * 432 * @syscap SystemCapability.ArkUI.ArkUI.Full 433 * @since 7 434 */ 435/** 436 * Defines the ImageBitmap. 437 * 438 * @syscap SystemCapability.ArkUI.ArkUI.Full 439 * @atomicservice 440 * @since 11 441 */ 442export declare class ImageBitmap { 443 /** 444 * The height of the Image Bitmap object. 445 * 446 * @type { number } 447 * @syscap SystemCapability.ArkUI.ArkUI.Full 448 * @since 7 449 */ 450 /** 451 * The height of the Image Bitmap object. 452 * 453 * @type { number } 454 * @syscap SystemCapability.ArkUI.ArkUI.Full 455 * @atomicservice 456 * @since 11 457 */ 458 readonly height: number; 459 460 /** 461 * The width of the Image Bitmap object. 462 * 463 * @type { number } 464 * @syscap SystemCapability.ArkUI.ArkUI.Full 465 * @since 7 466 */ 467 /** 468 * The width of the Image Bitmap object. 469 * 470 * @type { number } 471 * @syscap SystemCapability.ArkUI.ArkUI.Full 472 * @atomicservice 473 * @since 11 474 */ 475 readonly width: number; 476} 477 478/** 479 * Conditional compilation for rich equipment 480 * 481 * @syscap SystemCapability.ArkUI.ArkUI.Lite 482 * @systemapi 483 * @since 4 484 */ 485export declare const STANDARD: string; 486 487/** 488 * Conditional compilation for lite equipment 489 * 490 * @syscap SystemCapability.ArkUI.ArkUI.Lite 491 * @systemapi 492 * @since 4 493 */ 494export declare const LITE: string; 495