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)

201 lines (200 loc) 6.62 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 64-bit floating point color. */ export declare class ColorFloat64 implements Color { /** * The underlying data array for the color channels. */ protected data: Float64Array; /** * Gets the format of the color. */ get format(): Format; /** * Gets the number of channels in the color. */ 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 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, if any. */ get palette(): Palette | undefined; /** * Gets or sets the index of the color. */ 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 ColorFloat64 instance. * @param {Float64Array | number} data - The initial data for the color, either a Float64Array or a number. */ constructor(data: Float64Array | number); /** * Creates a new ColorFloat64 instance from another ColorFloat64 instance. * * @param {ColorFloat64} other - The other ColorFloat64 instance to copy. * @returns {ColorFloat64} A new ColorFloat64 instance. */ static from(other: ColorFloat64): ColorFloat64; /** * Creates a new ColorFloat64 instance from a Float64Array. * * @param {Float64Array} color - The Float64Array to use for the color data. * @returns {ColorFloat64} A new instance of ColorFloat64. */ static fromArray(color: Float64Array): ColorFloat64; /** * Creates a new ColorFloat64 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 {ColorFloat64} A new instance of ColorFloat64 with the specified RGB values. */ static rgb(r: number, g: number, b: number): ColorFloat64; /** * Creates a new ColorFloat64 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. */ static rgba(r: number, g: number, b: number, a: number): ColorFloat64; /** * 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 to copy values from. */ 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[]} The color as an array of numbers. */ toArray(): number[]; /** * Creates a clone of the current color. * * @returns {ColorFloat64} A new ColorFloat64 instance that is a clone of the current instance. */ clone(): ColorFloat64; /** * Checks if the current color is equal to another color. * @param {Color} other - The other color to compare with. * @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 parameter that specifies the conversion options. * @param {string} [opt.format] - The target color format. * @param {number} [opt.numChannels] - The number of color channels. * @param {number} [opt.alpha] - The alpha value for the color. * @returns {Color} The converted color. */ convert(opt?: ColorConvertOptions): Color; }