UNPKG

proton-engine

Version:

Proton is a simple and powerful javascript particle animation engine.

1,611 lines (1,575 loc) 75.8 kB
declare class Stats { constructor(proton: any); proton: any; container: HTMLDivElement | null; type: number; emitterIndex: number; rendererIndex: number; update(style: any, body: any): void; add(style: any, body: any): void; getEmitter(): any; getRenderer(): any; concatArr(arr: any): string; getCreatedNumber(renderer: any): any; getEmitterPos(e: any): string; destroy(): void; } declare class Pool { /** * @memberof! Proton# * @constructor * @alias Proton.Pool * * @todo add description * @todo add description of properties * * @property {Number} total * @property {Object} cache */ constructor(num: any); total: number; cache: {}; /** * @todo add description * * @method get * @memberof Proton#Proton.Pool * * @param {Object|Function} target * @param {Object} [params] just add if `target` is a function * * @return {Object} */ get(target: Object | Function, params?: Object, uid: any): Object; /** * @todo add description * * @method set * @memberof Proton#Proton.Pool * * @param {Object} target * * @return {Object} */ expire(target: Object): Object; /** * Creates a new class instance * * @todo add more documentation * * @method create * @memberof Proton#Proton.Pool * * @param {Object|Function} target any Object or Function * @param {Object} [params] just add if `target` is a function * * @return {Object} */ createOrClone(target: Object | Function, params?: Object): Object; /** * @todo add description - what is in the cache? * * @method getCount * @memberof Proton#Proton.Pool * * @return {Number} */ getCount(): number; /** * Destroyes all items from Pool.cache * * @method destroy * @memberof Proton#Proton.Pool */ destroy(): void; /** * Returns Pool.cache * * @method getCache * @memberof Proton#Proton.Pool * @private * * @param {Number} uid the unique id * * @return {Object} */ private getCache; } declare class Integration { constructor(type: any); type: any; calculate(particles: any, time: any, damping: any): void; eulerIntegrate(particle: any, time: any, damping: any): void; } declare class Proton$1 { static USE_CLOCK: boolean; static MEASURE: number; static EULER: string; static RK2: string; static PARTICLE_CREATED: string; static PARTICLE_UPDATE: string; static PARTICLE_SLEEP: string; static PARTICLE_DEAD: string; static EMITTER_ADDED: string; static EMITTER_REMOVED: string; static PROTON_UPDATE: string; static PROTON_UPDATE_AFTER: string; static DEFAULT_INTERVAL: number; static amendChangeTabsBug: boolean; /** * The constructor to add emitters * * @constructor Proton * * @todo add more documentation of the single properties and parameters * * @param {Number | undefined} [integrationType=Proton.EULER] * * @property {String} [integrationType=Proton.EULER] * @property {Array} emitters All added emitter * @property {Array} renderers All added renderer * @property {Number} time The active time * @property {Number} oldtime The old time */ constructor(integrationType?: number | undefined); emitters: any[]; renderers: any[]; time: number; now: number; then: number; elapsed: number; stats: Stats; pool: Pool; integrationType: Mixed; integrator: Integration; _fps: string; _interval: number; /** * Sets the frames per second (FPS) for the Proton system. * @param {number|string} fps - The desired FPS. Use "auto" for default behavior, or a number for a specific FPS. */ set fps(fps: number | string); /** * Gets the current frames per second (FPS) setting. * @returns {number|string} The current FPS setting. Returns "auto" if set to default, or a number representing the specific FPS. */ get fps(): number | string; /** * add a type of Renderer * * @method addRenderer * @memberof Proton * @instance * * @param {Renderer} render */ addRenderer(render: Renderer): void; /** * @name add a type of Renderer * * @method addRenderer * @param {Renderer} render */ removeRenderer(render: Renderer): void; /** * add the Emitter * * @method addEmitter * @memberof Proton * @instance * * @param {Emitter} emitter */ addEmitter(emitter: Emitter): void; /** * Removes an Emitter * * @method removeEmitter * @memberof Proton * @instance * * @param {Proton.Emitter} emitter */ removeEmitter(emitter: Proton$1.Emitter): void; /** * Updates all added emitters * * @method update * @memberof Proton * @instance */ update(): void; emittersUpdate(elapsed: any): void; /** * @todo add description * * @method amendChangeTabsBug * @memberof Proton * @instance */ amendChangeTabsBug(): void; /** * Counts all particles from all emitters * * @method getCount * @memberof Proton * @instance */ getCount(): number; getAllParticles(): any[]; destroyAllEmitters(): void; /** * Destroys everything related to this Proton instance. This includes all emitters, and all properties * * @method destroy * @memberof Proton * @instance */ destroy(remove?: boolean): void; } declare class Vector2D$1 { /** * Creates a new Vector2D instance. * @param {number} [x=0] - The x coordinate. * @param {number} [y=0] - The y coordinate. */ constructor(x?: number, y?: number); /** @type {number} */ x: number; /** @type {number} */ y: number; /** * Sets the x and y components of this vector. * @param {number} x - The x coordinate. * @param {number} y - The y coordinate. * @returns {Vector2D} This vector. */ set(x: number, y: number): Vector2D$1; /** * Sets the x component of this vector. * @param {number} x - The x coordinate. * @returns {Vector2D} This vector. */ setX(x: number): Vector2D$1; /** * Sets the y component of this vector. * @param {number} y - The y coordinate. * @returns {Vector2D} This vector. */ setY(y: number): Vector2D$1; /** * Calculates the gradient (angle) of this vector. * @returns {number} The gradient in radians. */ getGradient(): number; /** * Copies the values of another vector to this one. * @param {Vector2D} v - The vector to copy from. * @returns {Vector2D} This vector. */ copy(v: Vector2D$1): Vector2D$1; /** * Adds another vector to this one. * @param {Vector2D} v - The vector to add. * @param {Vector2D} [w] - An optional second vector to add. * @returns {Vector2D} This vector. */ add(v: Vector2D$1, w?: Vector2D$1): Vector2D$1; /** * Adds scalar values to this vector's components. * @param {number} a - Value to add to x. * @param {number} b - Value to add to y. * @returns {Vector2D} This vector. */ addXY(a: number, b: number): Vector2D$1; /** * Adds two vectors and sets the result to this vector. * @param {Vector2D} a - The first vector to add. * @param {Vector2D} b - The second vector to add. * @returns {Vector2D} This vector. */ addVectors(a: Vector2D$1, b: Vector2D$1): Vector2D$1; /** * Subtracts another vector from this one. * @param {Vector2D} v - The vector to subtract. * @param {Vector2D} [w] - An optional second vector to subtract. * @returns {Vector2D} This vector. */ sub(v: Vector2D$1, w?: Vector2D$1): Vector2D$1; /** * Subtracts one vector from another and sets the result to this vector. * @param {Vector2D} a - The vector to subtract from. * @param {Vector2D} b - The vector to subtract. * @returns {Vector2D} This vector. */ subVectors(a: Vector2D$1, b: Vector2D$1): Vector2D$1; /** * Divides this vector by a scalar. * @param {number} s - The scalar to divide by. * @returns {Vector2D} This vector. */ divideScalar(s: number): Vector2D$1; /** * Multiplies this vector by a scalar. * @param {number} s - The scalar to multiply by. * @returns {Vector2D} This vector. */ multiplyScalar(s: number): Vector2D$1; /** * Negates this vector (inverts its direction). * @returns {Vector2D} This vector. */ negate(): Vector2D$1; /** * Calculates the dot product of this vector with another. * @param {Vector2D} v - The other vector. * @returns {number} The dot product. */ dot(v: Vector2D$1): number; /** * Calculates the squared length of this vector. * @returns {number} The squared length. */ lengthSq(): number; /** * Calculates the length of this vector. * @returns {number} The length. */ length(): number; /** * Normalizes this vector (makes it unit length). * @returns {Vector2D} This vector. */ normalize(): Vector2D$1; /** * Calculates the distance to another vector. * @param {Vector2D} v - The other vector. * @returns {number} The distance. */ distanceTo(v: Vector2D$1): number; /** * Rotates this vector by an angle. * @param {number} tha - The angle to rotate by (in radians). * @returns {Vector2D} This vector. */ rotate(tha: number): Vector2D$1; /** * Calculates the squared distance to another vector. * @param {Vector2D} v - The other vector. * @returns {number} The squared distance. */ distanceToSquared(v: Vector2D$1): number; /** * Linearly interpolates this vector toward another vector. * @param {Vector2D} v - The target vector. * @param {number} alpha - The interpolation factor (0-1). * @returns {Vector2D} This vector. */ lerp(v: Vector2D$1, alpha: number): Vector2D$1; /** * Checks if this vector is equal to another vector. * @param {Vector2D} v - The other vector. * @returns {boolean} True if the vectors are equal, false otherwise. */ equals(v: Vector2D$1): boolean; /** * Sets this vector to zero. * @returns {Vector2D} This vector. */ clear(): Vector2D$1; /** * Creates a new vector with the same x and y values as this one. * @returns {Vector2D} A new Vector2D instance. */ clone(): Vector2D$1; } declare class Rgb { constructor(r?: number, g?: number, b?: number); r: number; g: number; b: number; reset(): void; } /** * Represents a particle in a particle system. * @class Particle */ declare class Particle$1 { /** * Creates a new Particle instance. * @param {Object} [conf] Configuration object for the particle */ constructor(conf?: Object); /** @type {string} The unique identifier of the particle */ id: string; /** @type {{p:Vector2D,v:Vector2D,a:Vector2D}} Old state of the particle */ old: { p: Vector2D$1; v: Vector2D$1; a: Vector2D$1; }; /** @type {object} Custom data associated with the particle */ data: object; /** @type {Behaviour[]} Array of behaviours applied to the particle */ behaviours: Behaviour[]; /** @type {Vector2D} Current position of the particle */ p: Vector2D$1; /** @type {Vector2D} Current velocity of the particle */ v: Vector2D$1; /** @type {Vector2D} Current acceleration of the particle */ a: Vector2D$1; /** @type {Rgb} Color of the particle */ rgb: Rgb; name: string; /** * Gets the direction of the particle's movement in degrees. * @returns {number} The direction in degrees */ getDirection(): number; /** * Resets the particle to its initial state. * @returns {Particle} The particle instance */ reset(): Particle$1; life: number | undefined; age: number | undefined; dead: boolean | undefined; sleep: boolean | undefined; body: any; sprite: any; parent: any; energy: number | undefined; mass: number | undefined; radius: number | undefined; alpha: number | undefined; scale: number | undefined; rotation: number | undefined; color: any; easing: ((value: any) => any) | undefined; /** * Updates the particle's state. * @param {number} time The time elapsed since the last update * @param {number} index The index of the particle in its parent system */ update(time: number, index: number): void; /** * Applies all behaviours attached to the particle. * @param {number} time The time elapsed since the last update * @param {number} index The index of the particle in its parent system */ applyBehaviours(time: number, index: number): void; /** * Adds a behaviour to the particle. * @param {Behaviour} behaviour The behaviour to add */ addBehaviour(behaviour: Behaviour): void; /** * Adds multiple behaviours to the particle. * @param {Behaviour[]} behaviours An array of behaviours to add */ addBehaviours(behaviours: Behaviour[]): void; /** * Removes a specific behaviour from the particle. * @param {Behaviour} behaviour The behaviour to remove */ removeBehaviour(behaviour: Behaviour): void; /** * Removes all behaviours from the particle. */ removeAllBehaviours(): void; /** * Destroys the particle, removing all behaviours and setting it as dead. */ destroy(): void; } declare namespace _default$3 { /** * Returns the default if the value is null or undefined * * @memberof Proton#Proton.Util * @method initValue * * @param {Mixed} value a specific value, could be everything but null or undefined * @param {Mixed} defaults the default if the value is null or undefined */ function initValue(value: Mixed, defaults: Mixed): Mixed; /** * Checks if the value is a valid array * * @memberof Proton#Proton.Util * @method isArray * * @param {Array} value Any array * * @returns {Boolean} */ function isArray(value: any[]): boolean; /** * Destroyes the given array * * @memberof Proton#Proton.Util * @method emptyArray * * @param {Array} array Any array */ function emptyArray(arr: any): void; function toArray(arr: any): any; function sliceArray(arr1: any, index: any, arr2: any): void; function getRandFromArray(arr: any): any; /** * Destroyes the given object * * @memberof Proton#Proton.Util * @method emptyObject * * @param {Object} obj Any object */ function emptyObject(obj: Object, ignore?: null): void; /** * Makes an instance of a class and binds the given array * * @memberof Proton#Proton.Util * @method classApply * * @param {Function} constructor A class to make an instance from * @param {Array} [args] Any array to bind it to the constructor * * @return {Object} The instance of constructor, optionally bind with args */ function classApply(constructor: Function, args?: any[]): Object; /** * This will get the image data. It could be necessary to create a Proton.Zone. * * @memberof Proton#Proton.Util * @method getImageData * * @param {HTMLCanvasElement} context any canvas, must be a 2dContext 'canvas.getContext('2d')' * @param {Object} image could be any dom image, e.g. document.getElementById('thisIsAnImgTag'); * @param {Proton.Rectangle} rect */ function getImageData(context: HTMLCanvasElement, image: Object, rect: Proton.Rectangle): any; function destroyAll(arr: any, param?: null): void; function assign(target: any, source: any): any; } declare namespace _default$2 { /** * @typedef {Object} rgbObject * @property {Number} r red value * @property {Number} g green value * @property {Number} b blue value */ /** * converts a hex value to a rgb object * * @memberof Proton#Proton.Util * @method hexToRgb * * @param {String} h any hex value, e.g. #000000 or 000000 for black * * @return {rgbObject} */ function hexToRgb(h: string): { /** * red value */ r: number; /** * green value */ g: number; /** * blue value */ b: number; }; /** * converts a rgb value to a rgb string * * @memberof Proton#Proton.Util * @method rgbToHex * * @param {Object | Proton.hexToRgb} rgb a rgb object like in {@link Proton#Proton.} * * @return {String} rgb() */ function rgbToHex(rbg: any): string; function getHex16FromParticle(p: any): number; } declare namespace MathUtil { export { PI }; export let PIx2: number; export let PI_2: number; export let PI_180: number; export let N180_PI: number; export let Infinity: number; export function isInfinity(num: any): boolean; export function randomAToB(a: any, b: any, isInt?: boolean): any; export function randomFloating(center: any, f: any, isInt: any): any; export function randomColor(): string; export function randomZone(display: any): void; export function floor(num: any, k?: number): number; export function degreeTransform(a: any): number; export function toColor16(num: any): string; } declare const PI: 3.1415926; declare class Polar2D { constructor(r: any, tha: any); r: number; tha: any; set(r: any, tha: any): this; setR(r: any): this; setTha(tha: any): this; copy(p: any): this; toVector(): Vector2D$1; getX(): number; getY(): number; normalize(): this; equals(v: any): boolean; clear(): this; clone(): Polar2D; } declare namespace Mat3 { function create(mat3: any): Float32Array<ArrayBuffer>; function set(mat1: any, mat2: any): any; function multiply(mat: any, mat2: any, mat3: any): any; function inverse(mat: any, mat3: any): any; function multiplyVec2(m: any, vec: any, mat3: any): any; } /** * Represents a span of values or an array. */ declare class Span { /** * Returns a new Span object. * @param {*|Span} a - The first value or a Span object. * @param {*} [b] - The second value. * @param {*} [c] - The third value. * @returns {Span} A new Span instance. */ static setSpanValue(a: any | Span, b?: any, c?: any): Span; /** * Returns the value from a Span, if the param is not a Span it will return the given parameter. * @param {*|Span} pan - The value or Span to get the value from. * @returns {*} The value of Span OR the parameter if it is not a Span. */ static getSpanValue(pan: any | Span): any; /** * Creates a new Span instance. * @param {number|number[]} a - The first value or an array of values. * @param {number} [b] - The second value (if a is not an array). * @param {boolean} [center=false] - Whether to use center-based calculation. */ constructor(a: number | number[], b?: number, center?: boolean); /** * @type {boolean} * @private */ private isArray; /** * @type {number|number[]} * @private */ private a; /** * @type {number} * @private */ private b; /** * @type {boolean} * @private */ private center; /** * Gets a value from the span. * @param {boolean} [isInt=false] - Whether to return an integer value. * @returns {number} A random value from the span. */ getValue(isInt?: boolean): number; } /** * Represents an ArraySpan, a subclass of Span that works with arrays. * @extends Span */ declare class ArraySpan extends Span { /** * Creates an ArraySpan instance from the given array. * If the input is already an ArraySpan instance, it returns the input. * @static * @param {Array|ArraySpan|any} arr - The array or ArraySpan instance. * @returns {ArraySpan|null} A new ArraySpan instance or null if the input is falsy. */ static createArraySpan(arr: any[] | ArraySpan | any): ArraySpan | null; /** * Creates an instance of ArraySpan. * @param {Array|*|any} arr - The array or value to be converted to an array. */ constructor(arr: any[] | any | any); _arr: any; /** * Gets a random value from the array. * If the value is "random" or "Random", it returns a random color. * @returns {*} A random value from the array or a random color. */ getValue(): any; } declare class Rectangle { constructor(x: any, y: any, w: any, h: any); x: any; y: any; width: any; height: any; bottom: any; right: any; contains(x: any, y: any): boolean; } declare namespace _default$1 { function easeLinear(value: any): any; function easeInQuad(value: any): number; function easeOutQuad(value: any): number; function easeInOutQuad(value: any): number; function easeInCubic(value: any): number; function easeOutCubic(value: any): number; function easeInOutCubic(value: any): number; function easeInQuart(value: any): number; function easeOutQuart(value: any): number; function easeInOutQuart(value: any): number; function easeInSine(value: any): number; function easeOutSine(value: any): number; function easeInOutSine(value: any): number; function easeInExpo(value: any): number; function easeOutExpo(value: any): number; function easeInOutExpo(value: any): number; function easeInCirc(value: any): number; function easeOutCirc(value: any): number; function easeInOutCirc(value: any): number; function easeInBack(value: any): number; function easeOutBack(value: any): number; function easeInOutBack(value: any): number; function getEasing(ease: any): any; } /** * Rate class for controlling particle emission rate. */ declare class Rate { /** * Creates a new Rate instance. * The number of particles per second emission (a [particle]/b [s]). * @param {Array|number|Span} [numpan=1] - The number of particles for each emission. * @param {Array|number|Span} [timepan=1] - The time interval between each emission. * @example * // Create a rate of 10-20 particles every 0.1-0.25 seconds * new Rate(new Span(10, 20), new Span(0.1, 0.25)); */ constructor(numpan?: any[] | number | Span, timepan?: any[] | number | Span); /** * @type {Span} * @private */ private numPan; /** * @type {Span} * @private */ private timePan; /** * @type {number} * @private */ private startTime; /** * @type {number} * @private */ private nextTime; /** * Initializes the rate. * @private */ private init; /** * Gets the number of particles to emit based on the elapsed time. * @param {number} time - The elapsed time since the last update. * @returns {number} The number of particles to emit. */ getValue(time: number): number; } declare class Initialize { reset(): void; init(emitter: any, particle: any): void; initialize(target: any): void; } /** * Life class for initializing particle lifetime. * @extends Initialize */ declare class Life extends Initialize { /** * Creates a new Life instance. * @param {number|Span} a - The lifetime value or the lower bound of the lifetime range. * @param {number} [b] - The upper bound of the lifetime range (if a is a number). * @param {boolean} [c] - Whether to use center-based calculation (if a and b are numbers). */ constructor(a: number | Span, b?: number, c?: boolean); /** * @type {Span} * @private */ private lifePan; /** * @type {string} */ name: string; /** * Initializes the lifetime of a target particle. * @param {object} target - The target particle to initialize. */ initialize(target: object): void; } declare class Zone { vector: Vector2D$1; random: number; crossType: string; alert: boolean; getPosition(): void; crossing(particle: any): void; destroy(): void; } /** * Represents a point zone in a 2D space. * @extends Zone */ declare class PointZone extends Zone { /** * Creates a new PointZone. * @param {number} x - The x-coordinate of the point. * @param {number} y - The y-coordinate of the point. */ constructor(x: number, y: number); /** * The x-coordinate of the point. * @type {number} */ x: number; /** * The y-coordinate of the point. * @type {number} */ y: number; /** * Gets the position of the point. * @returns {Object} An object representing the position vector. */ getPosition(): Object; /** * This method is not supported for PointZone. * @param {Object} particle - The particle object (unused). */ crossing(particle: Object): void; } /** * Position class for initializing particle positions. * @extends Initialize */ declare class Position extends Initialize { /** * Creates a new Position instance. * @param {PointZone|any} [zone] - The zone to use for positioning. Defaults to a new PointZone if not provided. */ constructor(zone?: PointZone | any); /** * @type {PointZone|any} * @private */ private zone; /** * @type {string} */ name: string; /** * Resets this initializer's parameters. * @param {PointZone|any} [zone] - The new zone to use for positioning. Defaults to a new PointZone if not provided. */ reset(zone?: PointZone | any): void; /** * Initializes the particle's position. * @param {object} target - The particle to initialize. * @param {object} target.p - The particle's position object. * @param {number} target.p.x - The particle's x coordinate. * @param {number} target.p.y - The particle's y coordinate. */ initialize(target: { p: { x: number; y: number; }; }): void; } /** * Velocity class for initializing particle velocities. * @extends Initialize */ declare class Velocity extends Initialize { /** * Creates a new Velocity instance. * @param {number|Span} [rpan] - The radial component of the velocity or its range. * @param {number|Span} [thapan] - The angular component of the velocity or its range. * @param {string} [type='vector'] - The type of velocity ('vector' or 'polar'). */ constructor(rpan?: number | Span, thapan?: number | Span, type?: string); /** * @type {Span} * @private */ private rPan; /** * @type {Span} * @private */ private thaPan; /** * @type {string} */ name: string; type: Mixed; /** * Resets the velocity parameters. * @param {number|Span} [rpan] - The radial component of the velocity or its range. * @param {number|Span} [thapan] - The angular component of the velocity or its range. * @param {string} [type='vector'] - The type of velocity ('vector' or 'polar'). */ reset(rpan?: number | Span, thapan?: number | Span, type?: string): void; /** * Normalizes the velocity value. * @param {number} vr - The velocity value to normalize. * @returns {number} The normalized velocity value. * @private */ private normalizeVelocity; /** * Initializes the particle's velocity. * @param {object} target - The particle to initialize. */ initialize(target: object): void; } /** * Mass class for initializing particle mass. * @extends Initialize */ declare class Mass extends Initialize { /** * Creates a new Mass instance. * @param {number|Span} a - The mass value or the lower bound of the mass range. * @param {number} [b] - The upper bound of the mass range (if a is a number). * @param {boolean} [c] - Whether to use center-based calculation (if a and b are numbers). */ constructor(a: number | Span, b?: number, c?: boolean); /** * @type {Span} * @private */ private massPan; /** * @type {string} */ name: string; /** * Initializes the mass of a target particle. * @param {object} target - The target particle to initialize. */ initialize(target: object): void; } /** * Radius class for initializing particle radius. * @extends Initialize */ declare class Radius extends Initialize { /** * Creates a new Radius instance. * @param {number|Span} a - The radius value or the lower bound of the radius range. * @param {number} [b] - The upper bound of the radius range (if a is a number). * @param {boolean} [c] - Whether to use center-based calculation (if a and b are numbers). */ constructor(a: number | Span, b?: number, c?: boolean); /** * @type {Span} */ radius: Span; /** * @type {string} */ name: string; /** * Resets this initializer's parameters. * @param {number|Span} a - The radius value or the lower bound of the radius range. * @param {number} [b] - The upper bound of the radius range (if a is a number). * @param {boolean} [c] - Whether to use center-based calculation (if a and b are numbers). */ reset(a: number | Span, b?: number, c?: boolean): void; /** * Initializes the particle's radius. * @param {Particle} particle - The particle to initialize. */ initialize(particle: Particle): void; } /** * Body class for initializing particle bodies. * @extends Initialize */ declare class Body extends Initialize { /** * Creates a new Body instance. * @param {string|object|Image|HTMLImageElement|ArraySpan} image - The image source or object to use for the particle body. * @param {number} [w=20] - The width of the particle body. * @param {number} [h] - The height of the particle body. Defaults to the width if not provided. */ constructor(image: string | object | (new (width?: number, height?: number) => HTMLImageElement) | HTMLImageElement | ArraySpan, w?: number, h?: number); /** * @type {ArraySpan} * @private */ private image; /** * @type {string} */ name: string; w: Mixed; h: Mixed; /** * Initializes the particle's body. * @param {object} particle - The particle to initialize. */ initialize(particle: object): void; /** * Sets the span value for the image. * @param {string|object|Image|HTMLImageElement|ArraySpan} image - The image source or object to set as span value. * @returns {ArraySpan} The ArraySpan instance. * @private */ private setSpanValue; } /** * The Behaviour class is the base for the other Behaviour * @class */ declare class Behaviour$1 { static id: number; /** * Create a new Behaviour instance * @param {number} [life=Infinity] - The behaviour's life * @param {string} [easing='easeLinear'] - The behaviour's decaying trend, for example ease.easeOutQuart */ constructor(life?: number, easing?: string); /** * The behaviour's life * @type {number} */ life: number; /** * The behaviour's easing function * @type {function} */ easing: Function; /** * The behaviour's current age * @type {number} */ age: number; /** * The behaviour's current energy * @type {number} */ energy: number; /** * Whether the behaviour is dead * @type {boolean} */ dead: boolean; /** * The behaviour's parent emitters * @type {Array} */ parents: any[]; /** * The behaviour's unique id * @type {string} */ id: string; /** * The behaviour's name * @type {string} */ name: string; /** * Reset this behaviour's parameters * @param {number} [life=Infinity] - This behaviour's new life * @param {string} [easing='easeLinear'] - This behaviour's new easing */ reset(life?: number, easing?: string): void; /** * Normalize a force by 1:100 * @param {Proton.Vector2D} force - The force to normalize * @returns {Proton.Vector2D} The normalized force */ normalizeForce(force: Proton.Vector2D): Proton.Vector2D; /** * Normalize a value by 1:100 * @param {number} value - The value to normalize * @returns {number} The normalized value */ normalizeValue(value: number): number; /** * Initialize the behaviour's parameters for a particle * @param {Proton.Particle} particle - The particle to initialize */ initialize(particle: Proton.Particle): void; /** * Compute the behaviour's life cycle * @param {Proton.Particle} particle - The particle to calculate for * @param {number} time - The integrate time 1/ms * @param {number} index - The particle index */ calculate(particle: Proton.Particle, time: number, index: number): void; /** * Apply this behaviour to a particle * @param {Proton.Particle} particle - The particle to apply the behaviour to * @param {number} time - The integrate time 1/ms * @param {number} index - The particle index */ applyBehaviour(particle: Proton.Particle, time: number, index: number): void; /** * Destroy this behaviour */ destroy(): void; } declare class Force extends Behaviour$1 { /** * @memberof! Proton# * @augments Proton.Behaviour * @constructor * @alias Proton.Force * * @param {Number} fx * @param {Number} fy * @param {Number} [life=Infinity] this behaviour's life * @param {String} [easing=ease.easeLinear] this behaviour's easing * * @property {String} name The Behaviour name */ constructor(fx: number, fy: number, life?: number, easing?: string); force: Proton.Vector2D; /** * Reset this behaviour's parameters * * @method reset * @memberof Proton#Proton.Force * @instance * * @param {Number} fx * @param {Number} fy * @param {Number} [life=Infinity] this behaviour's life * @param {String} [easing=ease.easeLinear] this behaviour's easing */ reset(fx: number, fy: number, life?: number, easing?: string): void; /** * Apply this behaviour for all particles every time * * @method applyBehaviour * @memberof Proton#Proton.Force * @instance * * @param {Proton.Particle} particle * @param {Number} the integrate time 1/ms * @param {Int} the particle index */ applyBehaviour(particle: Proton.Particle, time: any, index: any): void; } /** * Attraction behavior for particles. * This behaviour makes particles follow a specific target position. * @extends Behaviour */ declare class Attraction extends Behaviour$1 { /** * Creates an instance of Attraction. * @param {Vector2D} targetPosition - The attraction point coordinates. * @param {number} [force=100] - The strength of the attraction force. * @param {number} [radius=1000] - The radius of influence for the attraction. * @param {number} [life=Infinity] - The life span of this behaviour. * @param {string} [easing='ease.easeLinear'] - The easing function for this behaviour. */ constructor(targetPosition: Vector2D$1, force?: number, radius?: number, life?: number, easing?: string); /** * The target position for attraction. * @type {Vector2D} */ targetPosition: Vector2D$1; /** * The radius of influence for the attraction. * @type {number} */ radius: number; /** * The strength of the attraction force. * @type {number} */ force: number; /** * The squared radius (for optimization). * @type {number} */ radiusSq: number; /** * The attraction force vector. * @type {Vector2D} */ attractionForce: Vector2D$1; /** * The squared length of the attraction force. * @type {number} */ lengthSq: number; /** * Resets the behaviour's parameters. * @param {Vector2D} targetPosition - The new attraction point coordinates. * @param {number} [force=100] - The new strength of the attraction force. * @param {number} [radius=1000] - The new radius of influence for the attraction. * @param {number} [life=Infinity] - The new life span of this behaviour. * @param {string} [easing='ease.easeLinear'] - The new easing function for this behaviour. */ reset(targetPosition: Vector2D$1, force?: number, radius?: number, life?: number, easing?: string): void; } declare class RandomDrift extends Behaviour$1 { /** * @memberof! Proton# * @augments Behaviour * @constructor * @alias RandomDrift * * @param {Number} driftX X value of the new Vector2D * @param {Number} driftY Y value of the new Vector2D * @param {Number} delay How much delay the drift should have * @param {Number} [life=Infinity] this behaviour's life * @param {String} [easing=easeLinear] this behaviour's easing * * @property {Number} time The time of the drift * @property {String} name The Behaviour name */ constructor(driftX: number, driftY: number, delay: number, life?: number, easing?: string); time: number; /** * Reset this behaviour's parameters * * @method reset * @memberof Proton#RandomDrift * @instance * * @param {Number} driftX X value of the new Vector2D * @param {Number} driftY Y value of the new Vector2D * @param {Number} delay How much delay the drift should have * @param {Number} [life=Infinity] this behaviour's life * @param {String} [easing=easeLinear] this behaviour's easing */ reset(driftX: number, driftY: number, delay: number, life?: number, easing?: string): void; panFoce: any; delay: number | undefined; initialize(particle: any): void; /** * Apply this behaviour for all particles every time * * @method applyBehaviour * @memberof Proton#RandomDrift * @instance * * @param {Particle} particle * @param {Number} time the integrate time 1/ms * @param {Int} index the particle index */ applyBehaviour(particle: Particle, time: number, index: Int): void; } declare class Gravity extends Force { /** * @memberof! Proton# * @augments Proton#Proton.Force * @constructor * @alias Proton.Gravity * * @param {Number} g Gravity * @param {Number} [life=Infinity] this behaviour's life * @param {String} [easing=ease.easeLinear] this behaviour's easing * * @property {String} name The Behaviour name */ constructor(g: number, life?: number, easing?: string); /** * Reset this behaviour's parameters * * @method reset * @memberof Proton#Proton.Gravity * @instance * * @param {Number} g Gravity * @param {Number} [life=Infinity] this behaviour's life * @param {String} [easing=ease.easeLinear] this behaviour's easing */ reset(g: number, life?: number, easing?: string): void; } declare class Collision extends Behaviour$1 { /** * The callback after collision * * @callback Callback * * @param {Proton.Particle} particle * @param {Proton.Paritcle} otherParticle */ /** * @memberof! Proton# * @augments Proton.Behaviour * @constructor * @alias Proton.Collision * * @todo add description to mass * * @param {Proton.Emitter} [emitter=null] the attraction point coordinates * @param {Boolean} [mass=true] * @param {Callback} [callback=null] the callback after the collision * @param {Number} [life=Infinity] this behaviour's life * @param {String} [easing=ease.easeLinear] this behaviour's easing * * @property {String} name The Behaviour name */ constructor(emitter?: Proton.Emitter, mass?: boolean, callback?: (particle: Proton.Particle, otherParticle: Proton.Paritcle) => Collision, life?: number, easing?: string); newPool: any[]; pool: any[]; /** * Reset this behaviour's parameters * * @memberof Proton#Proton.Collision * @method reset * @instance * * @todo add description to mass * * @param {Proton.Emitter} [emitter=null] the attraction point coordinates * @param {Boolean} [mass=true] * @param {Callback} [callback=null] the callback after the collision * @param {Number} [life=Infinity] this behaviour's life * @param {String} [easing=ease.easeLinear] this behaviour's easing */ reset(emitter?: Proton.Emitter, mass?: boolean, callback?: (particle: Proton.Particle, otherParticle: Proton.Paritcle) => Collision, life?: number, easing?: string): void; emitter: any; mass: any; callback: any; collisionPool: any[] | undefined; delta: Vector2D$1 | undefined; /** * Apply this behaviour for all particles every time * * @memberof Proton#Proton.Collision * @method applyBehaviour * @instance * * @param {Proton.Particle} particle * @param {Number} time the integrate time 1/ms * @param {Int} index the particle index */ applyBehaviour(particle: Proton.Particle, time: number, index: Int): void; } declare class CrossZone extends Behaviour$1 { /** * Defines what happens if the particles come to the end of the specified zone * * @memberof! Proton# * @augments Proton.Behaviour * @constructor * @alias Proton.CrossZone * * @param {Proton.Zone} zone can be any Proton.Zone - e.g. Proton.RectZone() * @param {String} [crossType=dead] what happens if the particles pass the zone - allowed strings: dead | bound | cross * @param {Number} [life=Infinity] this behaviour's life * @param {String} [easing=ease.easeLinear] this behaviour's easing * * @property {String} name The Behaviour name */ constructor(zone: Proton.Zone, crossType?: string, life?: number, easing?: string); /** * Reset this behaviour's parameters * * @method reset * @memberof Proton#Proton.CrossZone * @instance * * @param {Proton.Zone} zone can be any Proton.Zone - e.g. Proton.RectZone() * @param {String} [crossType=dead] what happens if the particles pass the zone - allowed strings: dead | bound | cross * @param {Number} [life=Infinity] this behaviour's life * @param {String} [easing=easeLinear] this behaviour's easing */ reset(zone: Proton.Zone, crossType?: string, life?: number, easing?: string): void; zone: any; /** * Apply this behaviour for all particles every time * * @method applyBehaviour * @memberof Proton#Proton.CrossZone * @instance * * @param {Proton.Particle} particle * @param {Number} the integrate time 1/ms * @param {Int} the particle index */ applyBehaviour(particle: Proton.Particle, time: any, index: any): void; } /** * Alpha behaviour for controlling particle opacity over time. * @extends Behaviour */ declare class Alpha extends Behaviour$1 { /** * Creates a new Alpha instance. * @param {number|Span} [a=1] - The initial alpha value or range. * @param {number|Span} [b] - The final alpha value or range. If not provided, it will be the same as 'a'. * @param {number} [life=Infinity] - This behaviour's life. * @param {string} [easing='easeLinear'] - This behaviour's easing function. */ constructor(a?: number | Span, b?: number | Span, life?: number, easing?: string); /** * @type {boolean} * @private */ private same; /** * @type {Span} * @private */ private a; /** * @type {Span} * @private */ private b; /** * Resets this behaviour's parameters. * @param {number|Span} [a=1] - The initial alpha value or range. * @param {number|Span} [b] - The final alpha value or range. If not provided, it will be the same as 'a'. * @param {number} [life] - This behaviour's life. * @param {string} [easing] - This behaviour's easing function. */ reset(a?: number | Span, b?: number | Span, life?: number, easing?: string): void; } /** * Scale behaviour for controlling particle size over time. * @extends Behaviour */ declare class Scale extends Behaviour$1 { /** * Creates a new Scale instance. * @param {number|Span} [a=1] - The initial scale value or range. * @param {number|Span} [b] - The final scale value or range. If not provided, it will be the same as 'a'. * @param {number} [life=Infinity] - This behaviour's life. * @param {string} [easing='easeLinear'] - This behaviour's easing function. */ constructor(a?: number | Span, b?: number | Span, life?: number, easing?: string); /** * @type {boolean} * @private */ private same; /** * Resets this behaviour's parameters. * @param {number|Span} a - The initial scale value or range. * @param {number|Span} [b] - The final scale value or range. If not provided, it will be the same as 'a'. * @param {number} [life] - This behaviour's life. * @param {string} [easing] - This behaviour's easing function. */ reset(a: number | Span, b?: number | Span, life?: number, easing?: string): void; a: Span | undefined; b: Span | undefined; } /** * Rotate behaviour for controlling particle rotation. * @extends Behaviour */ declare class Rotate extends Behaviour$1 { /** * Creates a new Rotate instance. * @param {string|number|Span} [influence='Velocity'] - The rotation's influence or initial rotation. * @param {string|number|Span} [b] - The final rotation value or range. * @param {string} [style='to'] - The style of rotation ('to' or 'add'). * @param {number} [life=Infinity] - This behaviour's life. * @param {string} [easing='easeLinear'] - This behaviour's easing function. */ constructor(influence?: string | number | Span, b?: string | number | Span, style?: string, life?: number, easing?: string); /** * @type {boolean} * @private */ private same; /** * @type {Span} * @private */ private a; /** * @type {Span} * @private */ private b; /** * @type {string} * @private */ private style; /** * Resets this behaviour's parameters. * @param {string|number|Span} [a='Velocity'] - The rotation's influence or initial rotation. * @param {string|number|Span} [b] - The final rotation value or range. * @param {string} [style='to'] - The style of rotation ('to' or 'add'). * @param {number} [life] - This behaviour's life. * @param {string} [easing] - This behaviour's easing function. */ reset(a?: string | number | Span, b?: string | number | Span, style?: string, life?: number, easing?: string): void; /** * Initializes the behaviour's parameters for a particle. * @param {object} particle - The particle to initialize. * @param {number} particle.rotation - The particle's rotation. * @param {object} particle.data - The particle's data object. */ initialize(particle: { rotation: number; data: object; }): void; /** * Applies this behaviour to a particle. * @param {object} particle - The particle to apply the behaviour to. * @param {number} time - The integrate time (1/ms). * @param {number} index - The particle index. */ applyBehaviour(particle: object, time: number, index: number): void; } declare class Color extends Behaviour$1 { /** * @memberof! Proton# * @augments Proton.Behaviour * @constructor * @alias Proton.Color * * @param {Proton.ArraySpan | String} [a] the string should be a hex e.g. #000000 for black * @param {Proton.ArraySpan | String} [b] the string should be a hex e.g. #000000 for black * @param {Number} [life=Infinity] this behaviour's life * @param {String} [easing=easeLinear] this behaviour's easing * * @property {String} name The Behaviour name */ constructor(a?: Proton.ArraySpan | string, b?: Proton.ArraySpan | string, life?: number, easing?: string); /** * Reset this behaviour's parameters * * @method reset * @memberof Proton#Proton.Color * @instance * * @param {Proton.ArraySpan | String} a the string should be a hex e.g. #000000 for black * @param {Proton.ArraySpan | String} b the string should be a hex e.g. #000000 for black * @param {Number} [life=Infinity] this behaviour's life * @param {String} [easing=easeLinear] thi