UNPKG

fast-average-color

Version:

A simple library that calculates the average color of images, videos and canvas in browser environment.

32 lines (31 loc) 1.33 kB
import type { FastAverageColorOptions, FastAverageColorResource, FastAverageColorResult, FastAverageColorRgba } from './types'; export * from './types'; export declare class FastAverageColor { canvas: HTMLCanvasElement | OffscreenCanvas | null; ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D | null; /** * Get asynchronously the average color from not loaded image. */ getColorAsync(resource: FastAverageColorResource, options?: FastAverageColorOptions): Promise<FastAverageColorResult>; /** * Get average color from image url */ getColorAsync(imageUrl: string, options?: FastAverageColorOptions): Promise<FastAverageColorResult>; /** * Get the average color from images, videos and canvas. */ getColor(resource: FastAverageColorResource, options?: FastAverageColorOptions): FastAverageColorResult; /** * Get the average color from a array when 1 pixel is 4 bytes. */ getColorFromArray4(arr: number[] | Uint8Array | Uint8ClampedArray, options?: FastAverageColorOptions): FastAverageColorRgba; /** * Get color data from value ([r, g, b, a]). */ prepareResult(value: number[], error?: Error): FastAverageColorResult; /** * Destroy the instance. */ destroy(): void; private bindImageEvents; }