mirror of
https://github.com/janishutz/color-thief.git
synced 2025-11-25 13:54:25 +00:00
Finish adding support for canvas elements as input
This commit is contained in:
2
dist/color-thief.cjs
vendored
2
dist/color-thief.cjs
vendored
File diff suppressed because one or more lines are too long
18
dist/color-thief.d.ts
vendored
18
dist/color-thief.d.ts
vendored
@@ -10,16 +10,16 @@ declare class ColorThief {
|
|||||||
/**
|
/**
|
||||||
* Use the median cut algorithm provided by quantize.js to cluster similar
|
* Use the median cut algorithm provided by quantize.js to cluster similar
|
||||||
* colors and return the base color from the largest cluster.
|
* colors and return the base color from the largest cluster.
|
||||||
* @param {HTMLImageElement} sourceImage:HTMLImageElement
|
* @param {HTMLImageElement | HTMLCanvasElement} sourceImage The source image or canvas element
|
||||||
* @param {number?} quality (Optional) 1 = highest quality, 10 = default. The bigger the number, the
|
* @param {number?} quality (Optional) 1 = highest quality, 10 = default. The bigger the number, the
|
||||||
* faster a color will be returned but the greater the likelihood that it will not be the visually
|
* faster a color will be returned but the greater the likelihood that it will not be the visually
|
||||||
* most dominant color.
|
* most dominant color.
|
||||||
* @returns {ColorThiefResult} returns {r: num, g: num, b: num}
|
* @returns {ColorThiefResult} returns {r: num, g: num, b: num}
|
||||||
*/
|
*/
|
||||||
getColor(sourceImage: HTMLImageElement, quality?: number): ColorThiefResult;
|
getColor(sourceImage: HTMLImageElement | HTMLCanvasElement, quality?: number): ColorThiefResult;
|
||||||
/**
|
/**
|
||||||
* Use the median cut algorithm provided by quantize.js to cluster similar colors.
|
* Use the median cut algorithm provided by quantize.js to cluster similar colors.
|
||||||
* @param {HTMLImageElement} sourceImage The image you want to have processed, as an HTMLImageElement
|
* @param {HTMLImageElement | HTMLCanvasElement} sourceImage The image you want to have processed, as an HTMLImageElement or HTMLCanvasElement
|
||||||
* @param {number?} colorCount colorCount determines the size of the palette; the number of colors returned. If not set, it
|
* @param {number?} colorCount colorCount determines the size of the palette; the number of colors returned. If not set, it
|
||||||
* defaults to 10.
|
* defaults to 10.
|
||||||
* @param {number?} quality (Optional) 1 = highest quality, 10 = default. The bigger the number, the
|
* @param {number?} quality (Optional) 1 = highest quality, 10 = default. The bigger the number, the
|
||||||
@@ -27,7 +27,7 @@ declare class ColorThief {
|
|||||||
* most dominant color.
|
* most dominant color.
|
||||||
* @returns {ColorThiefResult[] | null} returns array[ {r: num, g: num, b: num}, {r: num, g: num, b: num}, ...]
|
* @returns {ColorThiefResult[] | null} returns array[ {r: num, g: num, b: num}, {r: num, g: num, b: num}, ...]
|
||||||
*/
|
*/
|
||||||
getPalette(sourceImage: HTMLImageElement, colorCount?: number, quality?: number): ColorThiefResult[] | null;
|
getPalette(sourceImage: HTMLImageElement | HTMLCanvasElement, colorCount?: number, quality?: number): ColorThiefResult[] | null;
|
||||||
/**
|
/**
|
||||||
* [ DEPRECATED ] Get the dominant color of an image, which is fetched from a URL.
|
* [ DEPRECATED ] Get the dominant color of an image, which is fetched from a URL.
|
||||||
* @param {string} imageUrl
|
* @param {string} imageUrl
|
||||||
@@ -63,18 +63,18 @@ declare class ColorThief {
|
|||||||
* @returns {void}
|
* @returns {void}
|
||||||
* @deprecated since Version 3.0, in favour of getColorPromise. Only retained for compatibility
|
* @deprecated since Version 3.0, in favour of getColorPromise. Only retained for compatibility
|
||||||
*/
|
*/
|
||||||
getColorAsync: (imageUrl: string, callback: (data: ColorThiefResult, img: HTMLImageElement) => void, quality: number | null) => void;
|
getColorAsync(imageUrl: string, callback: (data: ColorThiefResult, img: HTMLImageElement) => void, quality: number | null): void;
|
||||||
/**
|
/**
|
||||||
* Same as getColor, but promise-based
|
* Get the dominant color of an image from an image URL promise-based. Replaces getColorFromUrl
|
||||||
* @param {string} imageUrl
|
* @param {string} imageUrl
|
||||||
* @param {number?} quality (Optional) 1 = highest quality, 10 = default. The bigger the number, the
|
* @param {number?} quality (Optional) 1 = highest quality, 10 = default. The bigger the number, the
|
||||||
* faster a color will be returned but the greater the likelihood that it will not be the visually
|
* faster a color will be returned but the greater the likelihood that it will not be the visually
|
||||||
* most dominant color.
|
* most dominant color.
|
||||||
* @returns {Promise<{ 'color': ColorThiefResult, 'img': HTMLImageElement }>} Returns a promise resolving to an object containing the color and the image element
|
* @returns {Promise<{ 'color': ColorThiefResult, 'img': HTMLImageElement }>} Returns a promise resolving to an object containing the color and the image element
|
||||||
*/
|
*/
|
||||||
getColorPromise: (imageUrl: string, quality: number | null) => Promise<{
|
getColorFromURLPromise(imageUrl: string, quality: number | null): Promise<{
|
||||||
"color": ColorThiefResult;
|
'color': ColorThiefResult;
|
||||||
"img": HTMLImageElement;
|
'img': HTMLImageElement;
|
||||||
}>;
|
}>;
|
||||||
}
|
}
|
||||||
export default ColorThief;
|
export default ColorThief;
|
||||||
|
|||||||
4
dist/color-thief.min.js
vendored
4
dist/color-thief.min.js
vendored
File diff suppressed because one or more lines are too long
2
dist/color-thief.mjs
vendored
2
dist/color-thief.mjs
vendored
File diff suppressed because one or more lines are too long
2
dist/color-thief.modern.js
vendored
2
dist/color-thief.modern.js
vendored
File diff suppressed because one or more lines are too long
4
dist/color-thief.umd.js
vendored
4
dist/color-thief.umd.js
vendored
File diff suppressed because one or more lines are too long
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@janishutz/colorthief",
|
"name": "@janishutz/colorthief",
|
||||||
"version": "3.0.1",
|
"version": "3.0.2",
|
||||||
"author": {
|
"author": {
|
||||||
"name": "Janis Hutz",
|
"name": "Janis Hutz",
|
||||||
"email": "development@janishutz.com",
|
"email": "development@janishutz.com",
|
||||||
|
|||||||
Reference in New Issue
Block a user