diff --git a/build.cjs b/build.cjs index 777444ba..24aa7764 100644 --- a/build.cjs +++ b/build.cjs @@ -1,6 +1,6 @@ // eslint-disable-next-line no-undef var { build } = require('esbuild'); -var { dependencies } = require('../../../package.json'); +var { dependencies } = require('./package.json'); build({ legalComments: 'inline', diff --git a/demo.js b/demo.js deleted file mode 100644 index 72811bf8..00000000 --- a/demo.js +++ /dev/null @@ -1,76 +0,0 @@ -import * as huetiful from '../src/index.js'; -import { log } from 'console'; - -// (1. Parsing color tokens to different types -var [colArrWithAlpha, colorObj, namedColor, colorNum, colorHex, sample] = [ - ['rgb', 100, 30, 80, 0.2], - { l: 20, c: 40, h: 80, mode: 'lch' }, - pink, - 6000, - '#fc3ba1', - [ - '#00ffdc', - '#00ff78', - '#00c000', - '#007e00', - '#164100', - '#ffff00', - '#310000', - '#3e0000', - '#4e0000', - '#600000', - '#720000' - ] -]; - -log(huetiful.color2hex(colorObj)); -log(huetiful.num2color(colorNum)); -log(huetiful.toCIE('lab')(namedColor)); -log(huetiful.color2hex(colArrWithAlpha)); -log(huetiful.color2tuple(colorHex, 'oklch')); - -// (2. Fetching swatches from bundled color maps -let swatches = huetiful.tailwindColors('all', '400'); -log(swatches); -// (3. Getting and setting properties - -// Setting luminance -let setLum = huetiful.setLuminance(colArrWithAlpha, 0.5); - -// Check the color's initial luminance -log(huetiful.getLuminance(colArrWithAlpha)); - -log(huetiful.getLuminance(setLum)); - -// (4. Sorting and filtering collections of color - -// sort colors by hue angle in descending order -console.log(huetiful.sortByHue(sample, 'desc')); - -// Filter out colors that have chroma channel below 0.1 -console.log(filterByChroma(sample, 0.1)); - -// (5. Getting the stats of color attributes in a collection - -let [meanHue, meanDistance] = [ - huetiful.getMeanHue(sample, 'lch'), - huetiful.getMeanDistance(sample, 'blue') -]; - -// log the mean hue angle from the collection -log(meanHue); - -// log the mean distance between colors in the collection -log(meanDistance); - -// (6. Method chaining - -// Chaining collection methods -let chain1 = huetiful - .load(sample) - .filterByHue(30, 80) - .sortByHue('desc') - .output(); - -// Chaining color methods we first convert it to a pastel color and then return the color visision deficiency simulation of the color for someone who has trouble seeing red. -let chain2 = huetiful.color(colorHex).pastel().deficiency('red', 0.4); diff --git a/demo/demo.js b/demo/demo.js deleted file mode 100644 index d5622e8f..00000000 --- a/demo/demo.js +++ /dev/null @@ -1,75 +0,0 @@ -import * as huetiful from '../src/index.js'; -import { log } from 'console'; - -// (1. Parsing color tokens to different types -var [colArrWithAlpha, colorObj, namedColor, colorNum, colorHex, sample] = [ - ['rgb', 100, 30, 80, 0.2], - { l: 20, c: 40, h: 80, mode: 'lch' }, - 'pink', - 6000, - '#fc3ba1', - [ - '#00ffdc', - '#00ff78', - '#00c000', - '#007e00', - '#164100', - '#ffff00', - '#310000', - '#3e0000', - '#4e0000', - '#600000', - '#720000' - ] -]; - -log(huetiful.color2hex(colorObj)); -log(huetiful.num2color(colorNum)); -log(huetiful.color2hex(colArrWithAlpha)); -log(huetiful.color2tuple(colorHex, 'oklch')); - -// (2. Fetching swatches from bundled color maps -let swatches = huetiful.tailwindColors('all', '400'); -log(swatches); -// (3. Getting and setting properties - -// Setting luminance -let setLum = huetiful.setLuminance(colArrWithAlpha, 0.5); - -// Check the color's initial luminance -log(huetiful.getLuminance(colArrWithAlpha)); - -log(huetiful.getLuminance(setLum)); - -// (4. Sorting and filtering collections of color - -// sort colors by hue angle in descending order -console.log(huetiful.sortByHue(sample, 'desc')); - -// Filter out colors that have chroma channel below 0.1 -console.log(huetiful.filterByChroma(sample, 0.1)); - -// (5. Getting the stats of color attributes in a collection - -let [meanHue, meanDistance] = [ - huetiful.getMeanHue(sample, 'lch'), - huetiful.getMeanDistance(sample, 'blue') -]; - -// log the mean hue angle from the collection -log(meanHue); - -// log the mean distance between colors in the collection -log(meanDistance); - -// (6. Method chaining - -// Chaining collection methods -let chain1 = huetiful - .load(sample) - .filterByHue(30, 80) - .sortByHue('desc') - .output(); - -// Chaining color methods we first convert it to a pastel color and then return the color visision deficiency simulation of the color for someone who has trouble seeing red. -let chain2 = huetiful.color(colorHex).pastel().deficiency('red', 0.4); diff --git a/demo/sample.png b/demo/sample.png deleted file mode 100644 index ab1b168e..00000000 Binary files a/demo/sample.png and /dev/null differ diff --git a/types/colors.d.ts b/types/colors.d.ts index 91fd7e85..f0cbf433 100644 --- a/types/colors.d.ts +++ b/types/colors.d.ts @@ -26,32 +26,6 @@ declare function getNearestColor( num?: number ): ColorToken | Array | Map; -/** - * - * Returns the color as a simulation of the passed in `defeciencyType` of color vision deficiency with the deficiency filter's intensity determined by the `severity` value. - * @param deficiencyType The type of color vision deficiency. To avoid writing the long types, the expected parameters are simply the colors that are hard to perceive for the type of color blindness. For example those with 'tritanopia' are unable to perceive 'blue' light. Default is `'red'` when the defeciency parameter is undefined or any falsy value. - * @param color The color to return its simulated variant. - * @param severity The intensity of the filter. The exepected value is between [0,1]. For example 0.5 - * @returns The color as its simulated variant. Preserves the `ColorToken` type of the pased in color. - * @example - * - * import { colorDeficiency, color2hex } from 'huetiful-js' - -// Here we are simulating color blindness of tritanomaly or we can't see 'blue'. -// We are passing in our color as an array of channel values in the mode "rgb". The severity is set to 0.1 -let tritanomaly = colorDeficiency('blue') -console.log(tritanomaly(['rgb', 230, 100, 50, 0.5], 0.1)) -// #dd663680 - -// Here we are simulating color blindness of tritanomaly or we can't see 'red'. The severity is not explicitly set so it defaults to 1 -let protanopia = colorDeficiency('red') -console.log(protanopia({ h: 20, w: 50, b: 30, mode: 'hwb' })) -// #9f9f9f - */ -declare function colorDeficiency( - deficiencyType?: DeficiencyType -): (color: ColorToken, severity?: number) => string; - /** * * A wrapper function for ColorBrewer's map of sequential color schemes. @@ -151,11 +125,4 @@ declare function tailwindColors( shade: TailwindColorFamilies | 'all', value?: ScaleValues ): string | Array; -export { - colorDeficiency, - getNearestColor, - diverging, - qualitative, - sequential, - tailwindColors -}; +export { getNearestColor, diverging, qualitative, sequential, tailwindColors }; diff --git a/types/utils.d.ts b/types/utils.d.ts index 944e4002..c0f0f370 100644 --- a/types/utils.d.ts +++ b/types/utils.d.ts @@ -3,7 +3,6 @@ import { ColorToken, HueColorSpaces, HueFamily, - DeficiencyType, UniformColorSpaces } from './types';