/* * Copyright (c) 2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * Defines the ParticleOptions Interface. * @interface ParticleOptions * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @since 10 */ interface ParticleOptions< PARTICLE extends ParticleType, COLOR_UPDATER extends ParticleUpdater, OPACITY_UPDATER extends ParticleUpdater, SCALE_UPDATER extends ParticleUpdater, ACC_SPEED_UPDATER extends ParticleUpdater, ACC_ANGLE_UPDATER extends ParticleUpdater, SPIN_UPDATER extends ParticleUpdater > { /** * Particle emitter. * @type { EmitterOptions } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @since 10 */ emitter: EmitterOptions; /** * Particle color. * @type { ?ParticleColorPropertyOptions } * @default {range:['#FFFFFF','#FFFFFF']} * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @since 10 */ color?: ParticleColorPropertyOptions; /** * Particle opacity. * @type { ?ParticlePropertyOptions } * @default {range:[1.0,1.0]} * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @since 10 */ opacity?: ParticlePropertyOptions; /** * Particle scale. * @type { ?ParticlePropertyOptions } * @default {range:[1.0,1.0]} * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @since 10 */ scale?: ParticlePropertyOptions; /** * Particle velocity. * @type { ?object } * @default {speed:[0,0];angle:[0,0]} * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @since 10 */ velocity?: { speed: [number, number]; angle: [number, number]; }; /** * Particle acceleration. * @type { ?object } * @default {speed:{range:[0,0]};angle:{range:[0,0]}} * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @since 10 */ acceleration?: { speed?: ParticlePropertyOptions; angle?: ParticlePropertyOptions; }; /** * Particle spin. * @type { ?ParticlePropertyOptions } * @default {range:[0,0]} * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @since 10 */ spin?: ParticlePropertyOptions; } /** * Defines the parameters for a point-like particle. * @interface PointParticleParameters * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @since 10 */ interface PointParticleParameters { /** * Particle radius. * @type { VP } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @since 10 */ radius: VP; } /** * Defines the parameters for an image-like particle. * @interface ImageParticleParameters * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @since 10 */ interface ImageParticleParameters { /** * Particle image pixelMap. * @type { ResourceStr } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @since 10 */ src: ResourceStr; /** * Particle image size. * @type { [Dimension, Dimension] } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @since 10 */ size: [Dimension, Dimension]; /** * Image fit. * @type { ?ImageFit } * @default ImageFit.Cover * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @since 10 */ objectFit?: ImageFit; } /** * Defines the particle configs. * @interface ParticleConfigs * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @since 10 */ interface ParticleConfigs { /** * Point-like Particle. * @type { PointParticleParameters } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @since 10 */ [ParticleType.POINT]: PointParticleParameters; /** * Image-like Particle. * @type { ImageParticleParameters } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @since 10 */ [ParticleType.IMAGE]: ImageParticleParameters; } /** * Defines the emitter Options. * @interface EmitterOptions * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @since 10 */ interface EmitterOptions { /** * Set particle config. * @type { object } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @since 10 */ particle: { /** * Particle type. * @type { PARTICLE } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @since 10 */ type: PARTICLE; /** * Particle config. * @type { ParticleConfigs[PARTICLE] } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @since 10 */ config: ParticleConfigs[PARTICLE]; /** * Particle count. * @type { number } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @since 10 */ count: number; /** * Particle lifetime. * @type { ?number } * @default 1000 * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @since 10 */ lifetime?: number; }; /** * Emitting rate, that is, the number of particles produced per second. * @type { ?number } * @default 5 * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @since 10 */ emitRate?: number; /** * Shape of emitter. * @type { ?ParticleEmitterShape } * @default ParticleEmitterShape.RECTANGLE * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @since 10 */ shape?: ParticleEmitterShape; /** * Position of emitter. * The first element means X-axis location. * The second element means the Y-axis location. * @type { ?[Dimension, Dimension] } * @default [0,0] * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @since 10 */ position?: [Dimension, Dimension]; /** * Size of emitter. * The first element means emitter width. * The second element means emitter height. * @type { ?[Dimension, Dimension] } * @default ['100%','100%'] * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @since 10 */ size?: [Dimension, Dimension]; } /** * Defines the particle property updater configs. * @interface ParticlePropertyUpdaterConfigs * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @since 10 */ interface ParticlePropertyUpdaterConfigs { /** * No effect of particle updater. * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @since 10 */ [ParticleUpdater.NONE]: void; /** * Random effect of particle updater. * @type { [T, T] } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @since 10 */ [ParticleUpdater.RANDOM]: [T, T]; /** * Curve effect of particle updater. * @type { Array> } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @since 10 */ [ParticleUpdater.CURVE]: Array>; } /** * Defines the particle property Options. * @interface ParticlePropertyOptions * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @since 10 */ interface ParticlePropertyOptions { /** * Initial range, within which the initial value are randomly generated. * @type { [TYPE, TYPE] } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @since 10 */ range: [TYPE, TYPE]; /** * Particle property updater. * @type { ?object } * @default {type:UPDATER.NONE;config:ParticlePropertyUpdaterConfigs[UPDATER.NONE]} * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @since 10 */ updater?: { type: UPDATER; config: ParticlePropertyUpdaterConfigs[UPDATER]; }; } /** * Defines the particle color property updater configs. * @interface ParticleColorPropertyUpdaterConfigs * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @since 10 */ interface ParticleColorPropertyUpdaterConfigs { /** * No effect of particle color property updater. * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @since 10 */ [ParticleUpdater.NONE]: void; /** * Random effect of particle color property updater. * @type { object } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @since 10 */ [ParticleUpdater.RANDOM]: { r: [number, number]; g: [number, number]; b: [number, number]; a: [number, number]; }; /** * Curve effect of particle color property updater. * * @type { Array> } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @since 10 */ [ParticleUpdater.CURVE]: Array>; } /** * Defines the particle color property updater configs which can support generics. * @interface ParticleColorPropertyOptions * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @since 10 */ interface ParticleColorPropertyOptions { /** * Initial color range, within which the initial color is randomly generated. * @type { [ResourceColor, ResourceColor] } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @since 10 */ range: [ResourceColor, ResourceColor]; /** * Particle color property updater. * @type { ?object } * @default {type:UPDATER.NONE;config:ParticleColorPropertyUpdaterConfigs[UPDATER.NONE]} * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @since 10 */ updater?: { type: UPDATER; config: ParticleColorPropertyUpdaterConfigs[UPDATER]; }; } /** * Defines the particle property lifecycle. * @interface ParticlePropertyAnimation * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @since 10 */ interface ParticlePropertyAnimation { /** * Start position of the particle animation. * @type { T } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @since 10 */ from: T; /** * End position of the particle animation. * @type { T } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @since 10 */ to: T; /** * Start millis of the particle animation. * @type { number } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @since 10 */ startMillis: number; /** * End millis of the particle animation. * @type { number } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @since 10 */ endMillis: number; /** * Curve of the particle animation. * @type { ?(Curve | ICurve) } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @since 10 */ curve?: Curve | ICurve; } /** * Defines the particle Interface. * @interface ParticleInterface * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @since 10 */ interface ParticleInterface { /** * create a particle array. * @param { object } value - Particle value * particles - list of ParticleOptions. * @returns { ParticleAttribute } Returns the particle attribute. * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @since 10 */ < PARTICLE extends ParticleType, COLOR_UPDATER extends ParticleUpdater, OPACITY_UPDATER extends ParticleUpdater, SCALE_UPDATER extends ParticleUpdater, ACC_SPEED_UPDATER extends ParticleUpdater, ACC_ANGLE_UPDATER extends ParticleUpdater, SPIN_UPDATER extends ParticleUpdater >(value: { particles: Array< ParticleOptions< PARTICLE, COLOR_UPDATER, OPACITY_UPDATER, SCALE_UPDATER, ACC_SPEED_UPDATER, ACC_ANGLE_UPDATER, SPIN_UPDATER > >; }): ParticleAttribute; } /** * Enumerates the particle types. * @enum { string } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @since 10 */ declare enum ParticleType { /** * Point-like particle. * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @since 10 */ POINT = 'point', /** * Image-like particle. * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @since 10 */ IMAGE = 'image', } /** * Enumerates the emitter shapes of a particle. * @enum { string } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @since 10 */ declare enum ParticleEmitterShape { /** * Rectangle. * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @since 10 */ RECTANGLE = 'rectangle', /** * Circle. * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @since 10 */ CIRCLE = 'circle', /** * Ellipse. * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @since 10 */ ELLIPSE = 'ellipse', } /** * Enumerates the updater types of a particle. * @enum { string } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @since 10 */ declare enum ParticleUpdater { /** * No updater is used. * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @since 10 */ NONE = 'none', /** * Random updater. * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @since 10 */ RANDOM = 'random', /** * Curve updater. * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @since 10 */ CURVE = 'curve', } /** * Defines the Particle component attribute functions. * @extends CommonMethod * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @since 10 */ declare class ParticleAttribute extends CommonMethod {} /** * Defines Particle Component. * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @since 10 */ declare const Particle: ParticleInterface;