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.28 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 2-bit unsigned int color with channel values in the range [0, 3].
*/
export declare class ColorUint2 implements Color {
/** Internal data storage for color channels */
private _data;
/**
* Gets the format of the color.
* @returns {Format} The format of the color.
*/
get format(): Format;
/** The length of the color data */
private readonly _length;
/**
* 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 of the color.
* @returns {Palette | undefined} The palette of the color, if any.
*/
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 ColorUint2 instance.
* @param {number[] | number} data - The initial data for the color.
*/
constructor(data: number[] | number);
/**
* Creates a new ColorUint2 instance from another ColorUint2 instance.
* @param {ColorUint2} other - The other ColorUint2 instance.
* @returns {ColorUint2} A new ColorUint2 instance.
*/
static from(other: ColorUint2): ColorUint2;
/**
* Creates a new ColorUint2 instance from an array of numbers.
* @param {number[]} color - The array of numbers.
* @returns {ColorUint2} A new ColorUint2 instance.
*/
static fromArray(color: number[]): ColorUint2;
/**
* Creates a new ColorUint2 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 {ColorUint2} A new ColorUint2 instance.
*/
static rgb(r: number, g: number, b: number): ColorUint2;
/**
* Creates a new ColorUint2 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 {ColorUint2} A new ColorUint2 instance.
*/
static rgba(r: number, g: number, b: number, a: number): ColorUint2;
/**
* 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 to an array of numbers.
* @returns {number[]} An array of numbers representing the color.
*/
toArray(): number[];
/**
* Clones the current color instance.
* @returns {ColorUint2} A new ColorUint2 instance.
*/
clone(): ColorUint2;
/**
* 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;
}