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)
171 lines (170 loc) • 5.83 kB
TypeScript
/** @format */
/**
* A 16-bit floating-point number, used by high-dynamic-range image formats
* as a more efficient storage for floating-point values that don't require
* full 32-bit precision. A list of Half floats can be stored in a
* Uint16Array, and converted to a double using the **float16ToDouble** static
* method.
*
* This class is derived from the OpenEXR library.
*/
export declare class Float16 {
/** @private Stores the Float32Array used for conversion. */
private static _toFloatFloat32Data?;
/** @private Lookup table for exponent conversion. */
private static _eLut;
/**
* @private
* Getter for the Float32Array used for conversion.
* @returns {Float32Array} The Float32Array used for conversion.
*/
private static get _toFloatFloat32();
/** The 16-bit representation of the floating-point number. */
bits: number;
/**
* Constructs a Float16 instance.
* @param {number} [f] - The floating-point number to convert to 16-bit.
*/
constructor(f?: number);
/**
* @private
* Converts a 32-bit integer to a 16-bit floating-point number.
* @param {number} i - The 32-bit integer to convert.
* @returns {number} The 16-bit floating-point representation.
*/
private static convert;
/**
* @private
* Initializes the lookup tables for conversion.
* @returns {Float32Array} The initialized Float32Array.
*/
private static initialize;
/**
* @private
* Converts a 16-bit floating-point number to a 32-bit integer.
* @param {number} y - The 16-bit floating-point number to convert.
* @returns {number} The 32-bit integer representation.
*/
private static halfToFloat;
/**
* Creates a new Float16 instance from another Float16 instance.
* @param {Float16} other - The other Float16 instance.
* @returns {Float16} The new Float16 instance.
*/
static from(other: Float16): Float16;
/**
* Creates a new Float16 instance from a 16-bit representation.
* @param {number} bits - The 16-bit representation.
* @returns {Float16} The new Float16 instance.
*/
static fromBits(bits: number): Float16;
/**
* Converts a 16-bit floating-point number to a double.
* @param {number} bits - The 16-bit floating-point number.
* @returns {number} The double representation.
*/
static float16ToDouble(bits: number): number;
/**
* Converts a double to a 16-bit floating-point number.
* @param {number} n - The double to convert.
* @returns {number} The 16-bit floating-point representation.
*/
static doubleToFloat16(n: number): number;
/**
* Returns +Infinity.
* @returns {Float16} The positive infinity representation.
*/
static posInf(): Float16;
/**
* Returns -Infinity.
* @returns {Float16} The negative infinity representation.
*/
static negInf(): Float16;
/**
* Returns a NaN with the bit pattern 0111111111111111.
* @returns {Float16} The NaN representation.
*/
static qNan(): Float16;
/**
* Returns a NaN with the bit pattern 0111110111111111.
* @returns {Float16} The NaN representation.
*/
static sNan(): Float16;
/**
* Converts the 16-bit floating-point number to a double.
* @returns {number} The double representation.
*/
toDouble(): number;
/**
* Unary minus.
* @returns {Float16} The negated Float16 instance.
*/
minus(): Float16;
/**
* Addition operator for Float16 or number operands.
* @param {Float16 | number} f - The operand to add.
* @returns {Float16} The result of the addition.
*/
add(f: Float16 | number): Float16;
/**
* Subtraction operator for Float16 or number operands.
* @param {Float16 | number} f - The operand to subtract.
* @returns {Float16} The result of the subtraction.
*/
sub(f: Float16 | number): Float16;
/**
* Multiplication operator for Float16 or number operands.
* @param {Float16 | number} f - The operand to multiply.
* @returns {Float16} The result of the multiplication.
*/
mul(f: Float16 | number): Float16;
/**
* Division operator for Float16 or number operands.
* @param {Float16 | number} f - The operand to divide.
* @returns {Float16} The result of the division.
*/
div(f: Float16 | number): Float16;
/**
* Round to n-bit precision (n should be between 0 and 10).
* After rounding, the significand's 10-n least significant
* bits will be zero.
* @param {number} n - The number of bits to round to.
* @returns {Float16} The rounded Float16 instance.
*/
round(n: number): Float16;
/**
* Returns true if the number is finite.
* @returns {boolean} True if finite, false otherwise.
*/
isFinite(): boolean;
/**
* Returns true if the number is normalized.
* @returns {boolean} True if normalized, false otherwise.
*/
isNormalized(): boolean;
/**
* Returns true if the number is denormalized.
* @returns {boolean} True if denormalized, false otherwise.
*/
isDenormalized(): boolean;
/**
* Returns true if the number is zero.
* @returns {boolean} True if zero, false otherwise.
*/
isZero(): boolean;
/**
* Returns true if the number is NaN.
* @returns {boolean} True if NaN, false otherwise.
*/
isNaN(): boolean;
/**
* Returns true if the number is infinity.
* @returns {boolean} True if infinity, false otherwise.
*/
isInfinity(): boolean;
/**
* Returns true if the number is negative.
* @returns {boolean} True if negative, false otherwise.
*/
isNegative(): boolean;
}