import { clamp } from '../../../../external/uui/index.js'; export { clamp }; /** * Performs linear interpolation (lerp) between two numbers based on a blending factor. * @param {number} start - The starting value. * @param {number} end - The ending value. * @param {number} alpha - The blending factor, clamped to the range [0, 1]. * @returns {number} The result of linear interpolation between `start` and `end` using `alpha`. * @example * // Interpolate between two values. * const value1 = 10; * const value2 = 20; * const alpha = 0.5; // Blend halfway between value1 and value2. * const result = lerp(value1, value2, alpha); * // result is 15 * * // Ensure alpha is clamped to the range [0, 1]. * const value3 = 5; * const value4 = 15; * const invalidAlpha = 1.5; // This will be clamped to 1. * const result2 = lerp(value3, value4, invalidAlpha); * // result2 is 15, equivalent to lerp(value3, value4, 1) */ export declare function lerp(start: number, end: number, alpha: number): number; /** * Calculates the inverse linear interpolation (inverse lerp) factor based on a value between two numbers. * The inverse lerp factor indicates where the given `value` falls between `start` and `end`. * * If `value` is equal to `start`, the function returns 0. If `value` is equal to `end`, the function returns 1. * @param {number} start - The starting value. * @param {number} end - The ending value. * @param {number} value - The value to calculate the inverse lerp factor for. * @returns {number} The inverse lerp factor, a value in the range [0, 1], indicating where `value` falls between `start` and `end`. * - If `start` and `end` are equal, the function returns 0. * - If `value` is less than `start`, the factor is less than 0, indicating it's before `start`. * - If `value` is greater than `end`, the factor is greater than 1, indicating it's after `end`. * - If `value` is between `start` and `end`, the factor is between 0 and 1, indicating where `value` is along that range. * @example * // Calculate the inverse lerp factor for a value between two points. * const startValue = 10; * const endValue = 20; * const targetValue = 15; // The value we want to find the factor for. * const result = inverseLerp(startValue, endValue, targetValue); * // result is 0.5, indicating that targetValue is halfway between startValue and endValue. * * // Handle the case where start and end are equal. * const equalStartAndEnd = 5; * const result2 = inverseLerp(equalStartAndEnd, equalStartAndEnd, equalStartAndEnd); * // result2 is 0, as start and end are equal. */ export declare function inverseLerp(start: number, end: number, value: number): number; /** * Calculates the absolute difference between two numbers. * @param {number} a - The first number. * @param {number} b - The second number. * @returns {number} The absolute difference between `a` and `b`. * @example * // Calculate the distance between two points on a number line. * const point1 = 5; * const point2 = 8; * const result = distance(point1, point2); * // result is 3 * * // Calculate the absolute difference between two values. * const value1 = -10; * const value2 = 20; * const result2 = distance(value1, value2); * // result2 is 30 */ export declare function distance(a: number, b: number): number; /** * Calculates the extrapolated final value based on an initial value and an increase factor. * @param {number} initialValue - The starting value. * @param {number} increaseFactor - The factor by which the value should increase * (must be in the range [0(inclusive), 1(exclusive)] where 0 means no increase and 1 means no limit). * @returns {number} The extrapolated final value. * Returns NaN if the increase factor is not within the valid range. * @example * // Valid input * const result = calculateExtrapolatedValue(100, 0.2); * // result is 125 * * // Valid input * const result2 = calculateExtrapolatedValue(50, 0.5); * // result2 is 100 * * // Invalid input (increaseFactor is out of range) * const result3 = calculateExtrapolatedValue(200, 1.2); * // result3 is NaN */ export declare function calculateExtrapolatedValue(initialValue: number, increaseFactor: number): number; /** * Find the index for a target value on an array of individual values. * @param {number} target - The target value to interpolate to. * @param {Array} weights - An array of values to interpolate between. * @returns */ export declare function getInterpolatedIndexOfPositionInWeightMap(target: number, weights: Array): number; /** * Combine the values of an array up to a certain index. * @param {number} index - The index to accumulate to, everything after this index will not be accumulated. * @param {Array} weights - An array of values to accumulate. * @returns */ export declare function getAccumulatedValueOfIndex(index: number, weights: Array): number; /** * * @param {number} x - The x coordinate. * @param {number} y - The y coordinate. * @param {DOMRect} rect - The rectangle to check. * @param {number} expand - The amount to expand or contract the rectangle. * @returns */ export declare function isWithinRect(x: number, y: number, rect: DOMRect, expand?: number): boolean;