UNPKG

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)

249 lines (248 loc) 8.21 kB
/** @format */ import { Palette } from '../image/palette.js'; import { Channel } from './channel.js'; import { Color, ColorConvertOptions } from './color.js'; import { Format } from './format.js'; /** * A 32-bit floating point color. */ export declare class ColorFloat32 implements Color { /** * The underlying data array for color channels. */ protected data: Float32Array; /** * Gets the format of the color. * @returns {Format} The format of the color. */ get format(): Format; /** * Gets the length of the data array. * @returns {number} The length of the data array. */ get length(): number; /** * Gets the maximum value a channel can have. * @returns {number} The maximum channel value. */ get maxChannelValue(): number; /** * Gets the maximum value an index can have. * @returns {number} The maximum index value. */ get maxIndexValue(): number; /** * Checks if the format is Low Dynamic Range (LDR). * @returns {boolean} True if the format is LDR, otherwise false. */ get isLdrFormat(): boolean; /** * Checks if the format is High Dynamic Range (HDR). * @returns {boolean} True if the format is HDR, otherwise false. */ get isHdrFormat(): boolean; /** * Checks if the color has a palette. * @returns {boolean} True if the color has a palette, otherwise false. */ get hasPalette(): boolean; /** * Gets the palette of the color. * @returns {Palette | undefined} The palette of the color, or undefined if there is no palette. */ get palette(): Palette | undefined; /** * Gets the index value. * @returns {number} The index value. */ get index(): number; /** * Sets the index value. * @param {number} i - The index value to set. */ set index(i: number); /** * Gets the red channel value. * @returns {number} The red channel value. */ get r(): number; /** * Sets the red channel value. * @param {number} r - The red channel value to set. */ set r(r: number); /** * Gets the green channel value. * @returns {number} The green channel value. */ get g(): number; /** * Sets the green channel value. * @param {number} g - The green channel value to set. */ set g(g: number); /** * Gets the blue channel value. * @returns {number} The blue channel value. */ get b(): number; /** * Sets the blue channel value. * @param {number} b - The blue channel value to set. */ set b(b: number); /** * Gets the alpha channel value. * @returns {number} The alpha channel value. */ get a(): number; /** * Sets the alpha channel value. * @param {number} a - The alpha channel value to set. */ set a(a: number); /** * Gets the normalized red channel value. * @returns {number} The normalized red channel value. */ get rNormalized(): number; /** * Sets the normalized red channel value. * @param {number} v - The normalized red channel value to set. */ set rNormalized(v: number); /** * Gets the normalized green channel value. * @returns {number} The normalized green channel value. */ get gNormalized(): number; /** * Sets the normalized green channel value. * @param {number} v - The normalized green channel value to set. */ set gNormalized(v: number); /** * Gets the normalized blue channel value. * @returns {number} The normalized blue channel value. */ get bNormalized(): number; /** * Sets the normalized blue channel value. * @param {number} v - The normalized blue channel value to set. */ set bNormalized(v: number); /** * Gets the normalized alpha channel value. * @returns {number} The normalized alpha channel value. */ get aNormalized(): number; /** * Sets the normalized alpha channel value. * @param {number} v - The normalized alpha channel value to set. */ set aNormalized(v: number); /** * Gets the luminance of the color. * @returns {number} The luminance of the color. */ get luminance(): number; /** * Gets the normalized luminance of the color. * @returns {number} The normalized luminance of the color. */ get luminanceNormalized(): number; /** * Constructs a new ColorFloat32 instance. * @param {Float32Array | number} data - The data array or the number of channels. */ constructor(data: Float32Array | number); /** * Creates a new ColorFloat32 instance from another ColorFloat32 instance. * @param {ColorFloat32} other - The other ColorFloat32 instance. * @returns {ColorFloat32} The new ColorFloat32 instance. */ static from(other: ColorFloat32): ColorFloat32; /** * Creates a new ColorFloat32 instance from a Float32Array. * @param {Float32Array} color - The Float32Array. * @returns {ColorFloat32} The new ColorFloat32 instance. */ static fromArray(color: Float32Array): ColorFloat32; /** * Creates a new ColorFloat32 instance with RGB channels. * @param {number} r - The red channel value. * @param {number} g - The green channel value. * @param {number} b - The blue channel value. * @returns {ColorFloat32} The new ColorFloat32 instance. */ static rgb(r: number, g: number, b: number): ColorFloat32; /** * Creates a new ColorFloat32 instance with RGBA channels. * @param {number} r - The red channel value. * @param {number} g - The green channel value. * @param {number} b - The blue channel value. * @param {number} a - The alpha channel value. * @returns {ColorFloat32} The new ColorFloat32 instance. */ static rgba(r: number, g: number, b: number, a: number): ColorFloat32; /** * Gets the value of a specific channel. * @param {number | Channel} channel - The channel index or Channel enum. * @returns {number} The value of the specified channel. */ getChannel(channel: number | Channel): number; /** * Gets the normalized value of a specific channel. * @param {number | Channel} channel - The channel index or Channel enum. * @returns {number} The normalized value of the specified channel. */ getChannelNormalized(channel: number | Channel): number; /** * Sets the value of a specific channel. * @param {number | Channel} index - The channel index or Channel enum. * @param {number} value - The value to set. */ setChannel(index: number | Channel, value: number): void; /** * Sets the color channels from another Color instance. * @param {Color} c - The Color instance. */ set(c: Color): void; /** * Sets the RGB channels. * @param {number} r - The red channel value. * @param {number} g - The green channel value. * @param {number} b - The blue channel value. */ setRgb(r: number, g: number, b: number): void; /** * Sets the RGBA channels. * @param {number} r - The red channel value. * @param {number} g - The green channel value. * @param {number} b - The blue channel value. * @param {number} a - The alpha channel value. */ setRgba(r: number, g: number, b: number, a: number): void; /** * Converts the color to an array. * @returns {number[]} The color as an array. */ toArray(): number[]; /** * Clones the color. * @returns {ColorFloat32} The cloned color. */ clone(): ColorFloat32; /** * Checks if the color is equal to another color. * @param {Color} other - The other color. * @returns {boolean} True if the colors are equal, otherwise false. */ equals(other: Color): boolean; /** * Converts the color to another format. * @param {ColorConvertOptions} [opt] - The conversion options. * @returns {Color} The converted color. */ convert(opt?: ColorConvertOptions): Color; }