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)

198 lines (197 loc) 6.45 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 integer color. */ export declare class ColorInt16 implements Color { /** * Internal storage for color data. */ private _data; /** * Gets the format of the color. */ get format(): Format; /** * Gets the length of the color data. */ get length(): number; /** * Gets the maximum value for a color channel. */ get maxChannelValue(): number; /** * Gets the maximum index value. */ get maxIndexValue(): number; /** * Checks if the format is Low Dynamic Range (LDR). */ get isLdrFormat(): boolean; /** * Checks if the format is High Dynamic Range (HDR). */ get isHdrFormat(): boolean; /** * Checks if the color has a palette. */ get hasPalette(): boolean; /** * Gets the palette associated with the color. */ get palette(): Palette | undefined; /** * Gets or sets the index value. */ get index(): number; set index(i: number); /** * Gets or sets the red channel value. */ get r(): number; set r(r: number); /** * Gets or sets the green channel value. */ get g(): number; set g(g: number); /** * Gets or sets the blue channel value. */ get b(): number; set b(b: number); /** * Gets or sets the alpha channel value. */ get a(): number; set a(a: number); /** * Gets or sets the normalized red channel value. */ get rNormalized(): number; set rNormalized(v: number); /** * Gets or sets the normalized green channel value. */ get gNormalized(): number; set gNormalized(v: number); /** * Gets or sets the normalized blue channel value. */ get bNormalized(): number; set bNormalized(v: number); /** * Gets or sets the normalized alpha channel value. */ get aNormalized(): number; set aNormalized(v: number); /** * Gets the luminance of the color. */ get luminance(): number; /** * Gets the normalized luminance of the color. */ get luminanceNormalized(): number; /** * Constructs a new ColorInt16 instance. * @param {Int16Array | number} data - The initial data for the color. */ constructor(data: Int16Array | number); /** * Creates a new ColorInt16 instance from another ColorInt16 instance. * @param {ColorInt16} other - The other ColorInt16 instance. * @returns {ColorInt16} A new ColorInt16 instance. */ static from(other: ColorInt16): ColorInt16; /** * Creates a new ColorInt16 instance from an array of numbers. * @param {number[]} color - The array of numbers representing the color. * @returns {ColorInt16} A new ColorInt16 instance. */ static fromArray(color: number[]): ColorInt16; /** * Creates a new ColorInt16 instance with RGB values. * * @param {number} r - The red channel value. * @param {number} g - The green channel value. * @param {number} b - The blue channel value. * @returns {ColorInt16} A new ColorInt16 instance. */ static rgb(r: number, g: number, b: number): ColorInt16; /** * Creates a new ColorInt16 instance with 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. */ static rgba(r: number, g: number, b: number, a: number): ColorInt16; /** * 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 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 data to an array of numbers. * @returns {number[]} - The array of numbers representing the color. */ toArray(): number[]; /** * Creates a clone of the current ColorInt16 instance. * @returns {ColorInt16} - A new ColorInt16 instance that is a clone of the current instance. */ clone(): ColorInt16; /** * Checks if the current color is equal to another color. * @param {Color} other - The other Color instance. * @returns {boolean} - True if the colors are equal, false otherwise. */ equals(other: Color): boolean; /** * Converts the current color instance to a different format based on the provided options. * * @param {ColorConvertOptions} [opt] - Optional parameters for the color conversion. * @param {string} [opt.format] - The target color format (e.g., 'rgb', 'hex'). * @param {number} [opt.numChannels] - The number of color channels to include in the conversion. * @param {number} [opt.alpha] - The alpha value for the color conversion. * @returns {Color} - The converted color. */ convert(opt?: ColorConvertOptions): Color; }