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.47 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 8-bit integer color. */ export declare class ColorInt8 implements Color { /** * Internal data storage for color channels. */ 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 any channel. */ get maxChannelValue(): number; /** * Gets the maximum index value. */ get maxIndexValue(): number; /** * Checks if the format is LDR (Low Dynamic Range). */ get isLdrFormat(): boolean; /** * Checks if the format is HDR (High Dynamic Range). */ get isHdrFormat(): boolean; /** * Checks if the color has a palette. */ get hasPalette(): boolean; /** * Gets the palette if available. */ 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 ColorInt8 instance. * @param {Int8Array | number} data - The initial data for the color, either an Int8Array or a number. */ constructor(data: Int8Array | number); /** * Creates a new ColorInt8 instance from another ColorInt8 instance. * @param {ColorInt8} other - The other ColorInt8 instance. * @returns {ColorInt8} A new ColorInt8 instance. */ static from(other: ColorInt8): ColorInt8; /** * Creates a new ColorInt8 instance from an array of numbers. * * @param {number[]} color - The array of numbers representing the color channels. * @returns {ColorInt8} - A new instance of ColorInt8. */ static fromArray(color: number[]): ColorInt8; /** * Creates a new ColorInt8 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. */ static rgb(r: number, g: number, b: number): ColorInt8; /** * Creates a new ColorInt8 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 {ColorInt8} A new ColorInt8 instance. */ static rgba(r: number, g: number, b: number, a: number): ColorInt8; /** * 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 to an array of numbers. * @returns {number[]} - An array of numbers representing the color channels. */ toArray(): number[]; /** * Creates a clone of the current color instance. * @returns {ColorInt8} - A new ColorInt8 instance that is a clone of the current instance. */ clone(): ColorInt8; /** * 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 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 instance. */ convert(opt?: ColorConvertOptions): Color; }