image-in-browser
Version:
Package for encoding / decoding images, transforming images, applying filters, drawing primitives on images on the client side (no need for server Node.js)
80 lines (79 loc) • 2.95 kB
TypeScript
/**
* Abstract class containing various mathematical utility functions.
*
* @format
*/
export declare abstract class MathUtils {
/**
* Returns the fractional part of a number.
* @param {number} x - The input number.
* @returns {number} The fractional part of the input number.
*/
static fract(x: number): number;
/**
* Performs smooth interpolation between two edges.
* @param {number} edge0 - The lower edge.
* @param {number} edge1 - The upper edge.
* @param {number} x - The input value.
* @returns {number} The interpolated value.
*/
static smoothStep(edge0: number, edge1: number, x: number): number;
/**
* Linearly interpolates between two values.
* @param {number} x - The first value.
* @param {number} y - The second value.
* @param {number} a - The interpolation factor.
* @returns {number} The interpolated value.
*/
static mix(x: number, y: number, a: number): number;
/**
* Returns the sign of a number.
* @param {number} x - The input number.
* @returns {number} -1 if the number is negative, 1 if positive, 0 if zero.
*/
static sign(x: number): number;
/**
* Returns 0 if the input is less than the edge, otherwise returns 1.
* @param {number} edge - The edge value.
* @param {number} x - The input value.
* @returns {number} 0 or 1 based on the comparison.
*/
static step(edge: number, x: number): number;
/**
* Calculates the Euclidean length of a 3D vector.
* @param {number} x - The x component.
* @param {number} y - The y component.
* @param {number} z - The z component.
* @returns {number} The length of the vector.
*/
static length3(x: number, y: number, z: number): number;
/**
* Returns the greatest common divisor of **x** and **y**.
* @param {number} x - The first number.
* @param {number} y - The second number.
* @returns {number} The greatest common divisor.
*/
static gcd(x: number, y: number): number;
/**
* Clamp **num** to [**low**, **high**]
* @param {number} num - The number to clamp.
* @param {number} low - The lower bound.
* @param {number} high - The upper bound.
* @returns {number} The clamped value.
*/
static clamp(num: number, low: number, high: number): number;
/**
* Clamp **num** to [**low**, **high**] and truncate
* @param {number} num - The number to clamp.
* @param {number} low - The lower bound.
* @param {number} high - The upper bound.
* @returns {number} The clamped and truncated value.
*/
static clampInt(num: number, low: number, high: number): number;
/**
* Clamp **num** to [0, 255] and truncate
* @param {number} num - The number to clamp.
* @returns {number} The clamped and truncated value.
*/
static clampInt255(num: number): number;
}