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)
163 lines (162 loc) • 5.99 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 16-bit floating point color.
*/
export declare class ColorFloat16 implements Color {
/** The data array holding the color values */
protected data: Uint16Array;
/** Gets the format of the color */
get format(): Format;
/** Gets the length of the data array */
get length(): number;
/** Gets the maximum channel value */
get maxChannelValue(): number;
/** Gets the maximum index value */
get maxIndexValue(): number;
/** Checks if the format is LDR */
get isLdrFormat(): boolean;
/** Checks if the format is HDR */
get isHdrFormat(): boolean;
/** Checks if the color has a palette */
get hasPalette(): boolean;
/** Gets the palette of the color */
get palette(): Palette | undefined;
/** Gets the index of the color */
get index(): number;
/** Sets the index of the color */
set index(i: number);
/** Gets the red channel value */
get r(): number;
/** Sets the red channel value */
set r(r: number);
/** Gets the green channel value */
get g(): number;
/** Sets the green channel value */
set g(g: number);
/** Gets the blue channel value */
get b(): number;
/** Sets the blue channel value */
set b(b: number);
/** Gets the alpha channel value */
get a(): number;
/** Sets the alpha channel value */
set a(a: number);
/** Gets the normalized red channel value */
get rNormalized(): number;
/** Sets the normalized red channel value */
set rNormalized(v: number);
/** Gets the normalized green channel value */
get gNormalized(): number;
/** Sets the normalized green channel value */
set gNormalized(v: number);
/** Gets the normalized blue channel value */
get bNormalized(): number;
/** Sets the normalized blue channel value */
set bNormalized(v: number);
/** Gets the normalized alpha channel value */
get aNormalized(): number;
/** Sets the normalized alpha channel value */
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 ColorFloat16 instance.
* @param {Uint16Array | number} data The data array or number of channels.
*/
constructor(data: Uint16Array | number);
/**
* Creates a new ColorFloat16 instance from another instance.
* @param {ColorFloat16} other The other ColorFloat16 instance.
* @returns {ColorFloat16} A new ColorFloat16 instance.
*/
static from(other: ColorFloat16): ColorFloat16;
/**
* Creates a new ColorFloat16 instance from an array.
* @param {Uint16Array} color The color array.
* @returns {ColorFloat16} A new ColorFloat16 instance.
*/
static fromArray(color: Uint16Array): ColorFloat16;
/**
* Creates a new ColorFloat16 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 {ColorFloat16} A new ColorFloat16 instance.
*/
static rgb(r: number, g: number, b: number): ColorFloat16;
/**
* Creates a new ColorFloat16 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 {ColorFloat16} A new ColorFloat16 instance.
*/
static rgba(r: number, g: number, b: number, a: number): ColorFloat16;
/**
* Gets the value of a specific channel.
* @param {number | Channel} channel The channel index or Channel enum.
* @returns {number} The channel value.
*/
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 channel value.
*/
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.
* @param {Color} c The other color.
*/
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.
* @returns {number[]} The color as an array.
*/
toArray(): number[];
/**
* Clones the color.
* @returns {ColorFloat16} A new ColorFloat16 instance.
*/
clone(): ColorFloat16;
/**
* Checks if the color is equal to another color.
* @param {Color} other The other color.
* @returns {boolean} True if the colors are equal, false otherwise.
*/
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;
}