mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-10 04:30:25 +02:00
add ignored colors to both hook and function
This commit is contained in:
@@ -1,6 +1,15 @@
|
|||||||
import { FastAverageColor } from 'fast-average-color';
|
import { FastAverageColor, FastAverageColorIgnoredColor } from 'fast-average-color';
|
||||||
import { useEffect, useRef, useState } from 'react';
|
import { useEffect, useRef, useState } from 'react';
|
||||||
|
|
||||||
|
const ignoredColors: FastAverageColorIgnoredColor = [
|
||||||
|
[255, 255, 255, 255, 90], // White
|
||||||
|
[255, 255, 255, 255, 50], // Light gray
|
||||||
|
[255, 255, 255, 255, 30], // Very light gray
|
||||||
|
[255, 255, 255, 255, 10], // Very very light gray
|
||||||
|
[0, 0, 0, 255, 30], // Black
|
||||||
|
[0, 0, 0, 0, 40], // Transparent
|
||||||
|
];
|
||||||
|
|
||||||
export const getFastAverageColor = async (args: {
|
export const getFastAverageColor = async (args: {
|
||||||
algorithm?: 'dominant' | 'simple' | 'sqrt';
|
algorithm?: 'dominant' | 'simple' | 'sqrt';
|
||||||
src: string;
|
src: string;
|
||||||
@@ -8,14 +17,7 @@ export const getFastAverageColor = async (args: {
|
|||||||
const fac = new FastAverageColor();
|
const fac = new FastAverageColor();
|
||||||
const background = await fac.getColorAsync(args.src, {
|
const background = await fac.getColorAsync(args.src, {
|
||||||
algorithm: args.algorithm || 'dominant',
|
algorithm: args.algorithm || 'dominant',
|
||||||
ignoredColor: [
|
ignoredColor: ignoredColors,
|
||||||
[255, 255, 255, 255, 90], // White
|
|
||||||
[255, 255, 255, 255, 50], // Light gray
|
|
||||||
[255, 255, 255, 255, 30], // Very light gray
|
|
||||||
[255, 255, 255, 255, 10], // Very very light gray
|
|
||||||
[0, 0, 0, 255, 30], // Black
|
|
||||||
[0, 0, 0, 0, 40], // Transparent
|
|
||||||
],
|
|
||||||
mode: 'speed',
|
mode: 'speed',
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -52,11 +54,7 @@ export const useFastAverageColor = (args: {
|
|||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
fac.getColorAsync(src, {
|
fac.getColorAsync(src, {
|
||||||
algorithm: algorithm || 'dominant',
|
algorithm: algorithm || 'dominant',
|
||||||
ignoredColor: [
|
ignoredColor: ignoredColors,
|
||||||
[255, 255, 255, 255, 90], // White
|
|
||||||
[0, 0, 0, 255, 30], // Black
|
|
||||||
[0, 0, 0, 0, 40], // Transparent
|
|
||||||
],
|
|
||||||
mode: 'speed',
|
mode: 'speed',
|
||||||
})
|
})
|
||||||
.then((color) => {
|
.then((color) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user