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.19 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 16-bit unsigned int color with channel values in the range [0, 65535]. */ export declare class ColorUint16 implements Color { /** * The underlying data array storing the color channels. */ protected data: Uint16Array; /** * Gets the format of the color. * @returns {Format} The format of the color. */ get format(): Format; /** * Gets the number of channels in the color. * @returns {number} The number of channels. */ get length(): number; /** * Gets the maximum value a channel can have. * @returns {number} The maximum channel value. */ get maxChannelValue(): number; /** * Gets the maximum index value. * @returns {number} The maximum index value. */ get maxIndexValue(): number; /** * Checks if the format is a low dynamic range format. * @returns {boolean} True if it is an LDR format, false otherwise. */ get isLdrFormat(): boolean; /** * Checks if the format is a high dynamic range format. * @returns {boolean} True if it is an HDR format, false otherwise. */ get isHdrFormat(): boolean; /** * Checks if the color has a palette. * @returns {boolean} True if it has a palette, false otherwise. */ get hasPalette(): boolean; /** * Gets the palette associated with the color. * @returns {Palette | undefined} The palette or undefined if none exists. */ 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 value. */ get luminance(): number; /** * Gets the normalized luminance of the color. * @returns {number} The normalized luminance value. */ get luminanceNormalized(): number; /** * Constructs a new ColorUint16 instance. * @param {Uint16Array | number} data - The data array or the number of channels. */ constructor(data: Uint16Array | number); /** * Creates a new ColorUint16 instance from another ColorUint16 instance. * @param {ColorUint16} other - The other ColorUint16 instance. * @returns {ColorUint16} The new ColorUint16 instance. */ static from(other: ColorUint16): ColorUint16; /** * Creates a new ColorUint16 instance from an array. * @param {Uint16Array} color - The color array. * @returns {ColorUint16} The new ColorUint16 instance. */ static fromArray(color: Uint16Array): ColorUint16; /** * Creates a new ColorUint16 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 {ColorUint16} The new ColorUint16 instance. */ static rgb(r: number, g: number, b: number): ColorUint16; /** * Creates a new ColorUint16 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 {ColorUint16} The new ColorUint16 instance. */ static rgba(r: number, g: number, b: number, a: number): ColorUint16; /** * Gets the value of a specific channel. * @param {number | Channel} channel - The channel index or Channel enum. * @returns {number} The channel value. */ 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 channel value. */ 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 values from another Color instance. * @param {Color} c - The Color instance. */ set(c: Color): void; /** * Sets the RGB values. * @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 values. * @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 current color instance. * @returns {ColorUint16} The cloned color instance. */ clone(): ColorUint16; /** * Checks if the current color is equal to another color. * @param {Color} other - The other color to compare. * @returns {boolean} True if the colors are equal, false otherwise. */ 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; }