@thi.ng/pixel
Version:
Typedarray integer & float pixel buffers w/ customizable formats, blitting, drawing, convolution
98 lines • 4.31 kB
TypeScript
import type { Fn2, FnN2, ICopy, IEmpty, Range0_3 } from "@thi.ng/api";
import { type UIntArray } from "@thi.ng/api/typedarray";
import { type BlendFnInt, type BlitCanvasOpts, type BlitOpts, type Filter, type FloatFormat, type IBlend, type IBlit, type IInvert, type IPixelBuffer, type IResizable, type IRotate, type ISetImageData, type IToImageData, type IntFormat, type IntFormatSpec, type IntSampler } from "./api.js";
import { FloatBuffer } from "./float.js";
/**
* Syntax sugar for {@link IntBuffer} ctor.
*
* @param w -
* @param h -
* @param fmt -
* @param data -
*/
export declare function intBuffer(w: number, h: number, fmt?: IntFormat | IntFormatSpec, data?: UIntArray): IntBuffer;
export declare function intBuffer(src: IntBuffer, fmt?: IntFormat | IntFormatSpec): IntBuffer;
/**
* Creates a new pixel buffer from given HTML image element with optional
* support for format conversion (default: {@link ABGR8888} & resizing.
*
* @param img -
* @param fmt -
* @param width -
* @param height -
*/
export declare const intBufferFromImage: (img: HTMLImageElement, fmt?: IntFormat, width?: number, height?: number | undefined) => IntBuffer;
/**
* Creates a new pixel buffer from given HTML canvas element with optional
* support for format conversion (default: {@link ABGR8888}.
*
* @param canvas -
* @param fmt -
*/
export declare const intBufferFromCanvas: (canvas: HTMLCanvasElement | OffscreenCanvas, fmt?: IntFormat) => IntBuffer;
export declare class IntBuffer implements IPixelBuffer<UIntArray, number>, IBlend<IntBuffer, BlendFnInt>, IBlit<IntBuffer>, ICopy<IntBuffer>, IEmpty<IntBuffer>, IInvert<IntBuffer>, IResizable<IntBuffer, IntSampler>, IRotate<IntBuffer>, ISetImageData, IToImageData {
readonly size: [number, number];
readonly stride: [number, number];
format: IntFormat;
data: UIntArray;
constructor(w: number, h: number, fmt?: IntFormat | IntFormatSpec, data?: UIntArray);
/** @deprecated use `.data` instead */
get pixels(): UIntArray;
get width(): number;
get height(): number;
get offset(): number;
get dim(): 2;
[Symbol.iterator](): Generator<number, void, unknown>;
as(fmt: IntFormat): IntBuffer;
as(fmt: FloatFormat): FloatBuffer;
copy(): IntBuffer;
empty(): IntBuffer;
order(): number[];
includes(x: number, y: number): boolean;
indexAt(x: number, y: number): number;
indexAtUnsafe(x: number, y: number): number;
getAt(x: number, y: number): number;
getAtUnsafe(x: number, y: number): number;
setAt(x: number, y: number, col: number): boolean;
setAtUnsafe(x: number, y: number, col: number): boolean;
getChannelAt(x: number, y: number, id: number, normalized?: boolean): number;
setChannelAt(x: number, y: number, id: number, col: number, normalized?: boolean): this;
blend(op: BlendFnInt, dest: IntBuffer, opts?: Partial<BlitOpts>): IntBuffer;
blit(dest: IntBuffer, opts?: Partial<BlitOpts>): IntBuffer;
blitCanvas(canvas: HTMLCanvasElement | CanvasRenderingContext2D | OffscreenCanvas | OffscreenCanvasRenderingContext2D, opts?: Partial<BlitCanvasOpts>): void;
setImageData(idata: ImageData): this;
toImageData(idata?: ImageData): ImageData;
getRegion(x: number, y: number, width: number, height: number, fmt?: IntFormat): IntBuffer | undefined;
getChannel(id: number): IntBuffer;
setChannel(id: number, src: IntBuffer | number): this;
invert(): this;
premultiply(): this;
postmultiply(): this;
isPremultiplied(): boolean;
forEach(f: Fn2<number, number, number>): this;
fill(x: number): void;
/**
* Flips image horizontally.
*/
flipX(): this;
/**
* Flips image vertically.
*/
flipY(): this;
rotateByID(id: Range0_3): this;
rotateCW(): this;
rotateCCW(): this;
rotate180(): this;
/**
* Returns scaled version of this buffer using given sampler or filter
* (default: `"linear"`) for interpolation. Syntax sugar for
* {@link IntBuffer.resize}.
*
* @param scale -
*/
scale(scale: number, sampler?: IntSampler | Filter): IntBuffer;
resize(w: number, h: number, sampler?: IntSampler | Filter): IntBuffer;
upsize(): IntBuffer;
protected _rotate(idxFn: FnN2): void;
}
//# sourceMappingURL=int.d.ts.map