UNPKG

@woosh/meep-engine

Version:

Pure JavaScript game engine. Fully featured and production ready.

152 lines 3.88 kB
/** * Defines a numeric interval, by min and max. * Provides a suite of interval logic operations. * Interval can be of 0 width. */ export class NumericInterval { /** * * @param {number} [min=-Infinity] * @param {number} [max=Infinity] * @constructor */ constructor(min?: number, max?: number); /** * * @type {number} */ min: number; /** * * @type {number} */ max: number; /** * @readonly * @type {Signal<number, number, number, number>} */ readonly onChanged: Signal<number, number, number, number>; /** * * @param {number} min * @param {number} max * @returns {this} */ set(min: number, max: number): this; /** * * @param {number} value * @returns {this} */ multiplyScalar(value: number): this; /** * Compute normalized position of input within this interval, where result is 0 if input is equal to `min`, and 1 when input is equal to `max` * @param {number} v value to be normalized * @returns {number} value between 0..1 if input is within [min,max] range, otherwise result will be extrapolated proportionately outside the 0,1 region */ normalizeValue(v: number): number; /** * Both min and max are exactly 0 * @returns {boolean} */ isZero(): boolean; /** * Whether min and max are the same * In other words if span is 0 * @returns {boolean} */ isExact(): boolean; /** * * @param {function} random Random number generator function, must return values between 0 and 1 * @returns {number} */ sampleRandom(random: Function): number; fromJSON(json: any): void; toJSON(): { min: number; max: number; }; /** * * @param {number[]|Float32Array|Float64Array} array * @param {number} [offset=0] */ fromArray(array: number[] | Float32Array | Float64Array, offset?: number): this; /** * * @param {number[]|Float32Array|Float64Array} [destination=[]] * @param {number} [offset=0] * @return {number[]} */ toArray(destination?: number[] | Float32Array | Float64Array, offset?: number): number[]; toString(): string; /** * * @param {BinaryBuffer} buffer */ toBinaryBuffer(buffer: BinaryBuffer): void; /** * * @param {BinaryBuffer} buffer */ fromBinaryBuffer(buffer: BinaryBuffer): void; /** * * @param {NumericInterval} other * @returns {this} */ copy(other: NumericInterval): this; /** * Performs union operation with another interval, mutates current interval. * @param {NumericInterval} other * @returns {this} */ union(other: NumericInterval): this; /** * * @param {NumericInterval} other * @return {boolean} */ overlaps(other: NumericInterval): boolean; /** * * @param {NumericInterval} other * @return {boolean} */ contains(other: NumericInterval): boolean; /** * * @param {NumericInterval} other * @returns {boolean} */ equals(other: NumericInterval): boolean; /** * * @returns {number} */ hash(): number; /** * Distance between min and max (`= max - min`) * @returns {number} */ get span(): number; get middle(): number; /** * @deprecated use {@link middle} instead * @returns {number} */ computeAverage(): number; /** * @readonly * @type {boolean} */ readonly isNumericInterval: boolean; } export namespace NumericInterval { let zero_zero: NumericInterval; let zero_one: NumericInterval; let one_one: NumericInterval; } import Signal from "../../events/signal/Signal.js"; //# sourceMappingURL=NumericInterval.d.ts.map