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)
322 lines (321 loc) • 10.1 kB
TypeScript
/** @format */
import { Channel } from '../color/channel.js';
import { Color, ColorConvertOptions } from '../color/color.js';
import { Format } from '../color/format.js';
import { MemoryImage } from './image.js';
import { MemoryImageDataFloat64 } from './image-data-float64.js';
import { Palette } from './palette.js';
import { Pixel } from './pixel.js';
/**
* Represents a pixel with 64-bit floating point color channels.
* Implements Pixel, Iterable<Pixel>, and Iterator<Pixel>.
*/
export declare class PixelFloat64 implements Pixel, Iterable<Pixel>, Iterator<Pixel> {
private _index;
private readonly _image;
/**
* Gets the image data associated with this pixel.
* @returns {MemoryImageDataFloat64} The image data.
*/
get image(): MemoryImageDataFloat64;
private _x;
/**
* Gets the x-coordinate of the pixel.
* @returns {number} The x-coordinate.
*/
get x(): number;
private _y;
/**
* Gets the y-coordinate of the pixel.
* @returns {number} The y-coordinate.
*/
get y(): number;
/**
* Gets the normalized x-coordinate of the pixel.
* @returns {number} The normalized x-coordinate.
*/
get xNormalized(): number;
/**
* Gets the normalized y-coordinate of the pixel.
* @returns {number} The normalized y-coordinate.
*/
get yNormalized(): number;
/**
* Gets the index of the pixel.
* @returns {number} The index.
*/
get index(): number;
/**
* Sets the index of the pixel.
* @param {number} i - The index to set.
*/
set index(i: number);
/**
* Gets the raw data of the pixel.
* @returns {Float64Array} The raw data.
*/
get data(): Float64Array;
/**
* Checks if the pixel is valid.
* @returns {boolean} True if valid, otherwise false.
*/
get isValid(): boolean;
/**
* Gets the width of the image.
* @returns {number} The width.
*/
get width(): number;
/**
* Gets the height of the image.
* @returns {number} The height.
*/
get height(): number;
/**
* Gets the number of channels in the image.
* @returns {number} The number of channels.
*/
get length(): number;
/**
* Gets the number of channels in the image.
* @returns {number} The number of channels.
*/
get numChannels(): number;
/**
* Gets the maximum channel value.
* @returns {number} The maximum channel value.
*/
get maxChannelValue(): number;
/**
* Gets the maximum index value.
* @returns {number} The maximum index value.
*/
get maxIndexValue(): number;
/**
* Gets the format of the image.
* @returns {Format} The format.
*/
get format(): Format;
/**
* Checks if the image is in LDR format.
* @returns {boolean} True if in LDR format, otherwise false.
*/
get isLdrFormat(): boolean;
/**
* Checks if the image is in HDR format.
* @returns {boolean} True if in HDR format, otherwise false.
*/
get isHdrFormat(): boolean;
/**
* Checks if the image has a palette.
* @returns {boolean} True if it has a palette, otherwise false.
*/
get hasPalette(): boolean;
/**
* Gets the palette of the image.
* @returns {Palette | undefined} The palette, or undefined if none.
*/
get palette(): Palette | undefined;
/**
* 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 pixel.
* @returns {number} The luminance.
*/
get luminance(): number;
/**
* Gets the normalized luminance of the pixel.
* @returns {number} The normalized luminance.
*/
get luminanceNormalized(): number;
/**
* Constructs a new PixelFloat64 instance.
* @param {number} x - The x-coordinate.
* @param {number} y - The y-coordinate.
* @param {number} index - The index.
* @param {MemoryImageDataFloat64} image - The image data.
*/
constructor(x: number, y: number, index: number, image: MemoryImageDataFloat64);
/**
* Creates a new PixelFloat64 instance from image data.
* @param {MemoryImageDataFloat64} image - The image data.
* @returns {PixelFloat64} The new PixelFloat64 instance.
*/
static imageData(image: MemoryImageDataFloat64): PixelFloat64;
/**
* Creates a new PixelFloat64 instance from an image.
* @param {MemoryImage} image - The image.
* @returns {PixelFloat64} The new PixelFloat64 instance.
*/
static image(image: MemoryImage): PixelFloat64;
/**
* Creates a new PixelFloat64 instance from another PixelFloat64 instance.
* @param {PixelFloat64} other - The other PixelFloat64 instance.
* @returns {PixelFloat64} The new PixelFloat64 instance.
*/
static from(other: PixelFloat64): PixelFloat64;
/**
* Returns an iterator for the PixelFloat64 instance.
* @returns {Iterator<Pixel>} The iterator.
*/
[Symbol.iterator](): Iterator<Pixel>;
/**
* Advances the iterator and returns the next result.
* @returns {IteratorResult<Pixel>} The next result.
*/
next(): IteratorResult<Pixel>;
/**
* Sets the position of the pixel.
* @param {number} x - The x-coordinate.
* @param {number} y - The y-coordinate.
*/
setPosition(x: number, y: number): void;
/**
* Sets the normalized position of the pixel.
* @param {number} x - The normalized x-coordinate.
* @param {number} y - The normalized y-coordinate.
*/
setPositionNormalized(x: number, y: number): void;
/**
* Gets the value of a specific channel.
* @param {number | Channel} channel - The channel number or type.
* @returns {number} The channel value.
*/
getChannel(channel: number | Channel): number;
/**
* Gets the normalized value of a specific channel.
* @param {Channel} channel - The channel type.
* @returns {number} The normalized channel value.
*/
getChannelNormalized(channel: Channel): number;
/**
* Sets the value of a specific channel.
* @param {number} channel - The channel number.
* @param {number} value - The value to set.
*/
setChannel(channel: number, value: number): void;
/**
* Sets the color of the pixel.
* @param {Color} color - The color to set.
*/
set(color: Color): void;
/**
* Sets the RGB values of the pixel.
* @param {number} r - The red value.
* @param {number} g - The green value.
* @param {number} b - The blue value.
*/
setRgb(r: number, g: number, b: number): void;
/**
* Sets the RGBA values of the pixel.
* @param {number} r - The red value.
* @param {number} g - The green value.
* @param {number} b - The blue value.
* @param {number} a - The alpha value.
*/
setRgba(r: number, g: number, b: number, a: number): void;
/**
* Converts the pixel to an array of channel values.
* @returns {number[]} The array of channel values.
*/
toArray(): number[];
/**
* Checks if the pixel is equal to another pixel or array of channel values.
* @param {Pixel | number[]} other - The other pixel or array.
* @returns {boolean} True if equal, otherwise false.
*/
equals(other: Pixel | number[]): boolean;
/**
* Clones the pixel.
* @returns {PixelFloat64} The cloned pixel.
*/
clone(): PixelFloat64;
/**
* Converts the pixel to a color.
* @param {ColorConvertOptions} opt - The conversion options.
* @returns {Color} The converted color.
*/
convert(opt: ColorConvertOptions): Color;
/**
* Converts the pixel to a string representation.
* @returns {string} The string representation.
*/
toString(): string;
}