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)

197 lines (196 loc) 6.42 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 integer color. */ export declare class ColorInt32 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 array. */ 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 ColorInt32 instance. * @param {Int32Array | number} data - The initial data for the color, either an Int32Array or a number. */ constructor(data: Int32Array | number); /** * Creates a new ColorInt32 instance from another ColorInt32 instance. * @param {ColorInt32} other - The other ColorInt32 instance. * @returns {ColorInt32} A new ColorInt32 instance. */ static from(other: ColorInt32): ColorInt32; /** * Creates a new ColorInt32 instance from an array of numbers. * @param {number[]} color - The array of numbers representing the color channels. * @returns {ColorInt32} A new ColorInt32 instance. */ static fromArray(color: number[]): ColorInt32; /** * Creates a new ColorInt32 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 {ColorInt32} A new ColorInt32 instance. */ static rgb(r: number, g: number, b: number): ColorInt32; /** * Creates a new ColorInt32 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 {ColorInt32} A new ColorInt32 instance. */ static rgba(r: number, g: number, b: number, a: number): ColorInt32; /** * Gets the value of a specified 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 specified 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 specified 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 {ColorInt32} A new ColorInt32 instance that is a clone of the current instance. */ clone(): ColorInt32; /** * 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 color to another format. * @param {ColorConvertOptions} opt - The options for color conversion. * @param {string} opt.format - The target format. * @param {number} opt.numChannels - The number of channels in the target format. * @param {number} opt.alpha - The alpha value in the target format. * @returns {Color} The converted color. */ convert(opt?: ColorConvertOptions): Color; }