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)
247 lines (246 loc) • 8.26 kB
TypeScript
/** @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 unsigned int color.
*/
export declare class ColorUint32 implements Color {
/** The underlying data storage for the color channels. */
protected data: Uint32Array;
/**
* Gets the format of the color.
* @returns {Format} The format of the color.
*/
get format(): Format;
/**
* Gets the length of the color data.
* @returns {number} The length of the color data.
*/
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 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 associated with the color.
* @returns {Palette | undefined} The palette or undefined if none exists.
*/
get palette(): Palette | undefined;
/**
* Gets the index of the color.
* @returns {number} The index of the color.
*/
get index(): number;
/**
* Sets the index of the color.
* @param {number} i - The index 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 ColorUint32 instance.
* @param {Uint32Array | number} data - The initial data or length of the color.
*/
constructor(data: Uint32Array | number);
/**
* Creates a new ColorUint32 instance from another ColorUint32 instance.
* @param {ColorUint32} other - The other ColorUint32 instance.
* @returns {ColorUint32} A new ColorUint32 instance.
*/
static from(other: ColorUint32): ColorUint32;
/**
* Creates a new ColorUint32 instance from an array of color values.
* @param {Uint32Array} color - The array of color values.
* @returns {ColorUint32} A new ColorUint32 instance.
*/
static fromArray(color: Uint32Array): ColorUint32;
/**
* Creates a new ColorUint32 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 {ColorUint32} A new ColorUint32 instance.
*/
static rgb(r: number, g: number, b: number): ColorUint32;
/**
* Creates a new ColorUint32 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.
* @returns {ColorUint32} A new ColorUint32 instance.
*/
static rgba(r: number, g: number, b: number, a: number): ColorUint32;
/**
* 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 of the color.
* @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 of the color.
* @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.
* @returns {number[]} An array of color values.
*/
toArray(): number[];
/**
* Creates a clone of the current ColorUint32 instance.
* @returns {ColorUint32} A new ColorUint32 instance.
*/
clone(): ColorUint32;
/**
* 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, 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;
}