完成世界书、骰子、apiconfig页面处理
This commit is contained in:
3
frontend/node_modules/khroma/dist/channels/reusable.d.ts
generated
vendored
Normal file
3
frontend/node_modules/khroma/dist/channels/reusable.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import Channels from './';
|
||||
declare const channels: Channels;
|
||||
export default channels;
|
||||
9
frontend/node_modules/khroma/dist/color/hsl.d.ts
generated
vendored
Normal file
9
frontend/node_modules/khroma/dist/color/hsl.d.ts
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
import type { Channels } from '../types';
|
||||
declare const HSL: {
|
||||
re: RegExp;
|
||||
hueRe: RegExp;
|
||||
_hue2deg: (hue: string) => number;
|
||||
parse: (color: string) => Channels | void;
|
||||
stringify: (channels: Channels) => string;
|
||||
};
|
||||
export default HSL;
|
||||
7
frontend/node_modules/khroma/dist/color/rgb.d.ts
generated
vendored
Normal file
7
frontend/node_modules/khroma/dist/color/rgb.d.ts
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
import type { Channels } from '../types';
|
||||
declare const RGB: {
|
||||
re: RegExp;
|
||||
parse: (color: string) => Channels | void;
|
||||
stringify: (channels: Channels) => string;
|
||||
};
|
||||
export default RGB;
|
||||
7
frontend/node_modules/khroma/dist/constants.d.ts
generated
vendored
Normal file
7
frontend/node_modules/khroma/dist/constants.d.ts
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
declare const DEC2HEX: Record<number, string>;
|
||||
declare const TYPE: {
|
||||
readonly ALL: 0;
|
||||
readonly RGB: 1;
|
||||
readonly HSL: 2;
|
||||
};
|
||||
export { DEC2HEX, TYPE };
|
||||
13
frontend/node_modules/khroma/dist/constants.js
generated
vendored
Normal file
13
frontend/node_modules/khroma/dist/constants.js
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
/* IMPORT */
|
||||
import _ from './utils/index.js';
|
||||
/* MAIN */
|
||||
const DEC2HEX = {};
|
||||
for (let i = 0; i <= 255; i++)
|
||||
DEC2HEX[i] = _.unit.dec2hex(i); // Populating dynamically, striking a balance between code size and performance
|
||||
const TYPE = {
|
||||
ALL: 0,
|
||||
RGB: 1,
|
||||
HSL: 2
|
||||
};
|
||||
/* EXPORT */
|
||||
export { DEC2HEX, TYPE };
|
||||
14
frontend/node_modules/khroma/dist/methods/adjust_channel.js
generated
vendored
Normal file
14
frontend/node_modules/khroma/dist/methods/adjust_channel.js
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
/* IMPORT */
|
||||
import _ from '../utils/index.js';
|
||||
import Color from '../color/index.js';
|
||||
/* MAIN */
|
||||
const adjustChannel = (color, channel, amount) => {
|
||||
const channels = Color.parse(color);
|
||||
const amountCurrent = channels[channel];
|
||||
const amountNext = _.channel.clamp[channel](amountCurrent + amount);
|
||||
if (amountCurrent !== amountNext)
|
||||
channels[channel] = amountNext;
|
||||
return Color.stringify(channels);
|
||||
};
|
||||
/* EXPORT */
|
||||
export default adjustChannel;
|
||||
8
frontend/node_modules/khroma/dist/methods/alpha.js
generated
vendored
Normal file
8
frontend/node_modules/khroma/dist/methods/alpha.js
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
/* IMPORT */
|
||||
import channel from './channel.js';
|
||||
/* MAIN */
|
||||
const alpha = (color) => {
|
||||
return channel(color, 'a');
|
||||
};
|
||||
/* EXPORT */
|
||||
export default alpha;
|
||||
3
frontend/node_modules/khroma/dist/methods/blue.d.ts
generated
vendored
Normal file
3
frontend/node_modules/khroma/dist/methods/blue.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import type { Channels } from '../types';
|
||||
declare const blue: (color: string | Channels) => number;
|
||||
export default blue;
|
||||
3
frontend/node_modules/khroma/dist/methods/complement.d.ts
generated
vendored
Normal file
3
frontend/node_modules/khroma/dist/methods/complement.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import type { Channels } from '../types';
|
||||
declare const complement: (color: string | Channels) => string;
|
||||
export default complement;
|
||||
2
frontend/node_modules/khroma/dist/methods/contrast.d.ts
generated
vendored
Normal file
2
frontend/node_modules/khroma/dist/methods/contrast.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
declare const contrast: (color1: string, color2: string) => number;
|
||||
export default contrast;
|
||||
3
frontend/node_modules/khroma/dist/methods/darken.d.ts
generated
vendored
Normal file
3
frontend/node_modules/khroma/dist/methods/darken.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import type { Channels } from '../types';
|
||||
declare const darken: (color: string | Channels, amount: number) => string;
|
||||
export default darken;
|
||||
3
frontend/node_modules/khroma/dist/methods/desaturate.d.ts
generated
vendored
Normal file
3
frontend/node_modules/khroma/dist/methods/desaturate.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import type { Channels } from '../types';
|
||||
declare const desaturate: (color: string | Channels, amount: number) => string;
|
||||
export default desaturate;
|
||||
8
frontend/node_modules/khroma/dist/methods/grayscale.js
generated
vendored
Normal file
8
frontend/node_modules/khroma/dist/methods/grayscale.js
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
/* IMPORT */
|
||||
import change from './change.js';
|
||||
/* MAIN */
|
||||
const grayscale = (color) => {
|
||||
return change(color, { s: 0 });
|
||||
};
|
||||
/* EXPORT */
|
||||
export default grayscale;
|
||||
8
frontend/node_modules/khroma/dist/methods/green.js
generated
vendored
Normal file
8
frontend/node_modules/khroma/dist/methods/green.js
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
/* IMPORT */
|
||||
import channel from './channel.js';
|
||||
/* MAIN */
|
||||
const green = (color) => {
|
||||
return channel(color, 'g');
|
||||
};
|
||||
/* EXPORT */
|
||||
export default green;
|
||||
16
frontend/node_modules/khroma/dist/methods/hsla.js
generated
vendored
Normal file
16
frontend/node_modules/khroma/dist/methods/hsla.js
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
/* IMPORT */
|
||||
import _ from '../utils/index.js';
|
||||
import ChannelsReusable from '../channels/reusable.js';
|
||||
import Color from '../color/index.js';
|
||||
/* MAIN */
|
||||
const hsla = (h, s, l, a = 1) => {
|
||||
const channels = ChannelsReusable.set({
|
||||
h: _.channel.clamp.h(h),
|
||||
s: _.channel.clamp.s(s),
|
||||
l: _.channel.clamp.l(l),
|
||||
a: _.channel.clamp.a(a)
|
||||
});
|
||||
return Color.stringify(channels);
|
||||
};
|
||||
/* EXPORT */
|
||||
export default hsla;
|
||||
40
frontend/node_modules/khroma/dist/methods/index.d.ts
generated
vendored
Normal file
40
frontend/node_modules/khroma/dist/methods/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
import hex from './rgba';
|
||||
import rgb from './rgba';
|
||||
import rgba from './rgba';
|
||||
import hsl from './hsla';
|
||||
import hsla from './hsla';
|
||||
import toKeyword from './to_keyword';
|
||||
import toHex from './to_hex';
|
||||
import toRgba from './to_rgba';
|
||||
import toHsla from './to_hsla';
|
||||
import channel from './channel';
|
||||
import red from './red';
|
||||
import green from './green';
|
||||
import blue from './blue';
|
||||
import hue from './hue';
|
||||
import saturation from './saturation';
|
||||
import lightness from './lightness';
|
||||
import alpha from './alpha';
|
||||
import opacity from './alpha';
|
||||
import contrast from './contrast';
|
||||
import luminance from './luminance';
|
||||
import isDark from './is_dark';
|
||||
import isLight from './is_light';
|
||||
import isTransparent from './is_transparent';
|
||||
import isValid from './is_valid';
|
||||
import saturate from './saturate';
|
||||
import desaturate from './desaturate';
|
||||
import lighten from './lighten';
|
||||
import darken from './darken';
|
||||
import opacify from './opacify';
|
||||
import fadeIn from './opacify';
|
||||
import transparentize from './transparentize';
|
||||
import fadeOut from './transparentize';
|
||||
import complement from './complement';
|
||||
import grayscale from './grayscale';
|
||||
import adjust from './adjust';
|
||||
import change from './change';
|
||||
import invert from './invert';
|
||||
import mix from './mix';
|
||||
import scale from './scale';
|
||||
export { hex, rgb, rgba, hsl, hsla, toKeyword, toHex, toRgba, toHsla, channel, red, green, blue, hue, saturation, lightness, alpha, opacity, contrast, luminance, isDark, isLight, isTransparent, isValid, saturate, desaturate, lighten, darken, opacify, fadeIn, transparentize, fadeOut, complement, grayscale, adjust, change, invert, mix, scale };
|
||||
3
frontend/node_modules/khroma/dist/methods/is_transparent.d.ts
generated
vendored
Normal file
3
frontend/node_modules/khroma/dist/methods/is_transparent.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import type { Channels } from '../types';
|
||||
declare const isTransparent: (color: string | Channels) => boolean;
|
||||
export default isTransparent;
|
||||
14
frontend/node_modules/khroma/dist/methods/is_valid.js
generated
vendored
Normal file
14
frontend/node_modules/khroma/dist/methods/is_valid.js
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
/* IMPORT */
|
||||
import Color from '../color/index.js';
|
||||
/* MAIN */
|
||||
const isValid = (color) => {
|
||||
try {
|
||||
Color.parse(color);
|
||||
return true;
|
||||
}
|
||||
catch {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
/* EXPORT */
|
||||
export default isValid;
|
||||
3
frontend/node_modules/khroma/dist/methods/lightness.d.ts
generated
vendored
Normal file
3
frontend/node_modules/khroma/dist/methods/lightness.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import type { Channels } from '../types';
|
||||
declare const lightness: (color: string | Channels) => number;
|
||||
export default lightness;
|
||||
8
frontend/node_modules/khroma/dist/methods/lightness.js
generated
vendored
Normal file
8
frontend/node_modules/khroma/dist/methods/lightness.js
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
/* IMPORT */
|
||||
import channel from './channel.js';
|
||||
/* MAIN */
|
||||
const lightness = (color) => {
|
||||
return channel(color, 'l');
|
||||
};
|
||||
/* EXPORT */
|
||||
export default lightness;
|
||||
22
frontend/node_modules/khroma/dist/methods/mix.js
generated
vendored
Normal file
22
frontend/node_modules/khroma/dist/methods/mix.js
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
/* IMPORT */
|
||||
import Color from '../color/index.js';
|
||||
import rgba from './rgba.js';
|
||||
/* MAIN */
|
||||
//SOURCE: https://github.com/sass/dart-sass/blob/7457d2e9e7e623d9844ffd037a070cf32d39c348/lib/src/functions/color.dart#L718-L756
|
||||
const mix = (color1, color2, weight = 50) => {
|
||||
const { r: r1, g: g1, b: b1, a: a1 } = Color.parse(color1);
|
||||
const { r: r2, g: g2, b: b2, a: a2 } = Color.parse(color2);
|
||||
const weightScale = weight / 100;
|
||||
const weightNormalized = (weightScale * 2) - 1;
|
||||
const alphaDelta = a1 - a2;
|
||||
const weight1combined = ((weightNormalized * alphaDelta) === -1) ? weightNormalized : (weightNormalized + alphaDelta) / (1 + weightNormalized * alphaDelta);
|
||||
const weight1 = (weight1combined + 1) / 2;
|
||||
const weight2 = 1 - weight1;
|
||||
const r = (r1 * weight1) + (r2 * weight2);
|
||||
const g = (g1 * weight1) + (g2 * weight2);
|
||||
const b = (b1 * weight1) + (b2 * weight2);
|
||||
const a = (a1 * weightScale) + (a2 * (1 - weightScale));
|
||||
return rgba(r, g, b, a);
|
||||
};
|
||||
/* EXPORT */
|
||||
export default mix;
|
||||
8
frontend/node_modules/khroma/dist/methods/opacify.js
generated
vendored
Normal file
8
frontend/node_modules/khroma/dist/methods/opacify.js
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
/* IMPORT */
|
||||
import adjustChannel from './adjust_channel.js';
|
||||
/* MAIN */
|
||||
const opacify = (color, amount) => {
|
||||
return adjustChannel(color, 'a', amount);
|
||||
};
|
||||
/* EXPORT */
|
||||
export default opacify;
|
||||
19
frontend/node_modules/khroma/dist/methods/rgba.js
generated
vendored
Normal file
19
frontend/node_modules/khroma/dist/methods/rgba.js
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
/* IMPORT */
|
||||
import _ from '../utils/index.js';
|
||||
import ChannelsReusable from '../channels/reusable.js';
|
||||
import Color from '../color/index.js';
|
||||
import change from './change.js';
|
||||
/* MAIN */
|
||||
const rgba = (r, g, b = 0, a = 1) => {
|
||||
if (typeof r !== 'number')
|
||||
return change(r, { a: g });
|
||||
const channels = ChannelsReusable.set({
|
||||
r: _.channel.clamp.r(r),
|
||||
g: _.channel.clamp.g(g),
|
||||
b: _.channel.clamp.b(b),
|
||||
a: _.channel.clamp.a(a)
|
||||
});
|
||||
return Color.stringify(channels);
|
||||
};
|
||||
/* EXPORT */
|
||||
export default rgba;
|
||||
8
frontend/node_modules/khroma/dist/methods/transparentize.js
generated
vendored
Normal file
8
frontend/node_modules/khroma/dist/methods/transparentize.js
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
/* IMPORT */
|
||||
import adjustChannel from './adjust_channel.js';
|
||||
/* MAIN */
|
||||
const transparentize = (color, amount) => {
|
||||
return adjustChannel(color, 'a', -amount);
|
||||
};
|
||||
/* EXPORT */
|
||||
export default transparentize;
|
||||
2
frontend/node_modules/khroma/dist/types.js
generated
vendored
Normal file
2
frontend/node_modules/khroma/dist/types.js
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
/* IMPORT */
|
||||
export {};
|
||||
34
frontend/node_modules/khroma/dist/utils/channel.d.ts
generated
vendored
Normal file
34
frontend/node_modules/khroma/dist/utils/channel.d.ts
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
import type { RGB, HSL } from '../types';
|
||||
declare const Channel: {
|
||||
min: {
|
||||
r: number;
|
||||
g: number;
|
||||
b: number;
|
||||
s: number;
|
||||
l: number;
|
||||
a: number;
|
||||
};
|
||||
max: {
|
||||
r: number;
|
||||
g: number;
|
||||
b: number;
|
||||
h: number;
|
||||
s: number;
|
||||
l: number;
|
||||
a: number;
|
||||
};
|
||||
clamp: {
|
||||
r: (r: number) => number;
|
||||
g: (g: number) => number;
|
||||
b: (b: number) => number;
|
||||
h: (h: number) => number;
|
||||
s: (s: number) => number;
|
||||
l: (l: number) => number;
|
||||
a: (a: number) => number;
|
||||
};
|
||||
toLinear: (c: number) => number;
|
||||
hue2rgb: (p: number, q: number, t: number) => number;
|
||||
hsl2rgb: ({ h, s, l }: HSL, channel: keyof RGB) => number;
|
||||
rgb2hsl: ({ r, g, b }: RGB, channel: keyof HSL) => number;
|
||||
};
|
||||
export default Channel;
|
||||
42
frontend/node_modules/khroma/dist/utils/index.d.ts
generated
vendored
Normal file
42
frontend/node_modules/khroma/dist/utils/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
declare const Utils: {
|
||||
channel: {
|
||||
min: {
|
||||
r: number;
|
||||
g: number;
|
||||
b: number;
|
||||
s: number;
|
||||
l: number;
|
||||
a: number;
|
||||
};
|
||||
max: {
|
||||
r: number;
|
||||
g: number;
|
||||
b: number;
|
||||
h: number;
|
||||
s: number;
|
||||
l: number;
|
||||
a: number;
|
||||
};
|
||||
clamp: {
|
||||
r: (r: number) => number;
|
||||
g: (g: number) => number;
|
||||
b: (b: number) => number;
|
||||
h: (h: number) => number;
|
||||
s: (s: number) => number;
|
||||
l: (l: number) => number;
|
||||
a: (a: number) => number;
|
||||
};
|
||||
toLinear: (c: number) => number;
|
||||
hue2rgb: (p: number, q: number, t: number) => number;
|
||||
hsl2rgb: ({ h, s, l }: import("../types").HSL, channel: keyof import("../types").RGB) => number;
|
||||
rgb2hsl: ({ r, g, b }: import("../types").RGB, channel: keyof import("../types").HSL) => number;
|
||||
};
|
||||
lang: {
|
||||
clamp: (number: number, lower: number, upper: number) => number;
|
||||
round: (number: number) => number;
|
||||
};
|
||||
unit: {
|
||||
dec2hex: (dec: number) => string;
|
||||
};
|
||||
};
|
||||
export default Utils;
|
||||
4
frontend/node_modules/khroma/dist/utils/unit.d.ts
generated
vendored
Normal file
4
frontend/node_modules/khroma/dist/utils/unit.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
declare const Unit: {
|
||||
dec2hex: (dec: number) => string;
|
||||
};
|
||||
export default Unit;
|
||||
37
frontend/node_modules/khroma/package.json
generated
vendored
Normal file
37
frontend/node_modules/khroma/package.json
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
{
|
||||
"name": "khroma",
|
||||
"repository": "github:fabiospampinato/khroma",
|
||||
"description": "A collection of functions for manipulating CSS colors, inspired by SASS.",
|
||||
"version": "2.1.0",
|
||||
"type": "module",
|
||||
"sideEffects": false,
|
||||
"main": "dist/index.js",
|
||||
"exports": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
"scripts": {
|
||||
"benchmark": "tsex benchmark",
|
||||
"benchmark:watch": "tsex benchmark --watch",
|
||||
"clean": "tsex clean",
|
||||
"compile": "tsex compile",
|
||||
"compile:watch": "tsex compile --watch",
|
||||
"test": "tsex test",
|
||||
"test:watch": "tsex test --watch",
|
||||
"prepublishOnly": "tsex prepare"
|
||||
},
|
||||
"keywords": [
|
||||
"sass",
|
||||
"color",
|
||||
"manipulation",
|
||||
"manipulate",
|
||||
"css",
|
||||
"hex",
|
||||
"rgb",
|
||||
"hsl"
|
||||
],
|
||||
"devDependencies": {
|
||||
"benchloop": "^2.1.1",
|
||||
"fava": "^0.2.1",
|
||||
"tsex": "^3.0.1",
|
||||
"typescript": "^5.1.6"
|
||||
}
|
||||
}
|
||||
169
frontend/node_modules/khroma/src/channels/index.ts
generated
vendored
Normal file
169
frontend/node_modules/khroma/src/channels/index.ts
generated
vendored
Normal file
@@ -0,0 +1,169 @@
|
||||
|
||||
/* IMPORT */
|
||||
|
||||
import _ from '~/utils';
|
||||
import Type from '~/channels/type';
|
||||
import {TYPE} from '~/constants';
|
||||
import type {RGBA, HSLA, CHANNELS} from '~/types';
|
||||
|
||||
/* MAIN */
|
||||
|
||||
class Channels {
|
||||
|
||||
/* VARIABLES */
|
||||
|
||||
color?: string;
|
||||
changed: boolean;
|
||||
data: CHANNELS; //TSC: It should really be "Partial<CHANNELS>", but TS gets excessively noisy
|
||||
type: Type;
|
||||
|
||||
/* CONSTRUCTOR */
|
||||
|
||||
constructor ( data: RGBA | HSLA | CHANNELS, color?: string ) {
|
||||
|
||||
this.color = color;
|
||||
this.changed = false;
|
||||
this.data = data as CHANNELS; //TSC
|
||||
this.type = new Type ();
|
||||
|
||||
}
|
||||
|
||||
/* API */
|
||||
|
||||
set ( data: RGBA | HSLA | CHANNELS, color?: string ): this {
|
||||
|
||||
this.color = color;
|
||||
this.changed = false;
|
||||
this.data = data as CHANNELS; //TSC
|
||||
this.type.type = TYPE.ALL;
|
||||
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
/* HELPERS */
|
||||
|
||||
_ensureHSL (): void {
|
||||
|
||||
const data = this.data;
|
||||
const {h, s, l} = data;
|
||||
|
||||
if ( h === undefined ) data.h = _.channel.rgb2hsl ( data, 'h' );
|
||||
if ( s === undefined ) data.s = _.channel.rgb2hsl ( data, 's' );
|
||||
if ( l === undefined ) data.l = _.channel.rgb2hsl ( data, 'l' );
|
||||
|
||||
}
|
||||
|
||||
_ensureRGB (): void {
|
||||
|
||||
const data = this.data;
|
||||
const {r, g, b} = data;
|
||||
|
||||
if ( r === undefined ) data.r = _.channel.hsl2rgb ( data, 'r' );
|
||||
if ( g === undefined ) data.g = _.channel.hsl2rgb ( data, 'g' );
|
||||
if ( b === undefined ) data.b = _.channel.hsl2rgb ( data, 'b' );
|
||||
|
||||
}
|
||||
|
||||
/* GETTERS */
|
||||
|
||||
get r (): number {
|
||||
const data = this.data;
|
||||
const r = data.r;
|
||||
if ( !this.type.is ( TYPE.HSL ) && r !== undefined ) return r;
|
||||
this._ensureHSL ();
|
||||
return _.channel.hsl2rgb ( data, 'r' );
|
||||
}
|
||||
|
||||
get g (): number {
|
||||
const data = this.data;
|
||||
const g = data.g;
|
||||
if ( !this.type.is ( TYPE.HSL ) && g !== undefined ) return g;
|
||||
this._ensureHSL ();
|
||||
return _.channel.hsl2rgb ( data, 'g' );
|
||||
}
|
||||
|
||||
get b (): number {
|
||||
const data = this.data;
|
||||
const b = data.b;
|
||||
if ( !this.type.is ( TYPE.HSL ) && b !== undefined ) return b;
|
||||
this._ensureHSL ();
|
||||
return _.channel.hsl2rgb ( data, 'b' );
|
||||
}
|
||||
|
||||
get h (): number {
|
||||
const data = this.data;
|
||||
const h = data.h;
|
||||
if ( !this.type.is ( TYPE.RGB ) && h !== undefined ) return h;
|
||||
this._ensureRGB ();
|
||||
return _.channel.rgb2hsl ( data, 'h' );
|
||||
}
|
||||
|
||||
get s (): number {
|
||||
const data = this.data;
|
||||
const s = data.s;
|
||||
if ( !this.type.is ( TYPE.RGB ) && s !== undefined ) return s;
|
||||
this._ensureRGB ();
|
||||
return _.channel.rgb2hsl ( data, 's' );
|
||||
}
|
||||
|
||||
get l (): number {
|
||||
const data = this.data;
|
||||
const l = data.l;
|
||||
if ( !this.type.is ( TYPE.RGB ) && l !== undefined ) return l;
|
||||
this._ensureRGB ();
|
||||
return _.channel.rgb2hsl ( data, 'l' );
|
||||
}
|
||||
|
||||
get a (): number {
|
||||
return this.data.a;
|
||||
}
|
||||
|
||||
/* SETTERS */
|
||||
|
||||
set r ( r: number ) {
|
||||
this.type.set ( TYPE.RGB );
|
||||
this.changed = true;
|
||||
this.data.r = r;
|
||||
}
|
||||
|
||||
set g ( g: number ) {
|
||||
this.type.set ( TYPE.RGB );
|
||||
this.changed = true;
|
||||
this.data.g = g;
|
||||
}
|
||||
|
||||
set b ( b: number ) {
|
||||
this.type.set ( TYPE.RGB );
|
||||
this.changed = true;
|
||||
this.data.b = b;
|
||||
}
|
||||
|
||||
set h ( h: number ) {
|
||||
this.type.set ( TYPE.HSL );
|
||||
this.changed = true;
|
||||
this.data.h = h;
|
||||
}
|
||||
|
||||
set s ( s: number ) {
|
||||
this.type.set ( TYPE.HSL );
|
||||
this.changed = true;
|
||||
this.data.s = s;
|
||||
}
|
||||
|
||||
set l ( l: number ) {
|
||||
this.type.set ( TYPE.HSL );
|
||||
this.changed = true;
|
||||
this.data.l = l;
|
||||
}
|
||||
|
||||
set a ( a: number ) {
|
||||
this.changed = true;
|
||||
this.data.a = a;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* EXPORT */
|
||||
|
||||
export default Channels;
|
||||
46
frontend/node_modules/khroma/src/channels/type.ts
generated
vendored
Normal file
46
frontend/node_modules/khroma/src/channels/type.ts
generated
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
|
||||
/* IMPORT */
|
||||
|
||||
import {TYPE} from '~/constants';
|
||||
|
||||
/* MAIN */
|
||||
|
||||
class Type {
|
||||
|
||||
/* VARIABLES */
|
||||
|
||||
type: number = TYPE.ALL;
|
||||
|
||||
/* API */
|
||||
|
||||
get (): number {
|
||||
|
||||
return this.type;
|
||||
|
||||
}
|
||||
|
||||
set ( type: number ): void {
|
||||
|
||||
if ( this.type && this.type !== type ) throw new Error ( 'Cannot change both RGB and HSL channels at the same time' );
|
||||
|
||||
this.type = type;
|
||||
|
||||
}
|
||||
|
||||
reset (): void {
|
||||
|
||||
this.type = TYPE.ALL;
|
||||
|
||||
}
|
||||
|
||||
is ( type: number ): boolean {
|
||||
|
||||
return this.type === type;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* EXPORT */
|
||||
|
||||
export default Type;
|
||||
82
frontend/node_modules/khroma/src/color/hsl.ts
generated
vendored
Normal file
82
frontend/node_modules/khroma/src/color/hsl.ts
generated
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
|
||||
/* IMPORT */
|
||||
|
||||
import _ from '~/utils';
|
||||
import ChannelsReusable from '~/channels/reusable';
|
||||
import type {Channels} from '~/types';
|
||||
|
||||
/* MAIN */
|
||||
|
||||
const HSL = {
|
||||
|
||||
/* VARIABLES */
|
||||
|
||||
re: /^hsla?\(\s*?(-?(?:\d+(?:\.\d+)?|(?:\.\d+))(?:e-?\d+)?(?:deg|grad|rad|turn)?)\s*?(?:,|\s)\s*?(-?(?:\d+(?:\.\d+)?|(?:\.\d+))(?:e-?\d+)?%)\s*?(?:,|\s)\s*?(-?(?:\d+(?:\.\d+)?|(?:\.\d+))(?:e-?\d+)?%)(?:\s*?(?:,|\/)\s*?\+?(-?(?:\d+(?:\.\d+)?|(?:\.\d+))(?:e-?\d+)?(%)?))?\s*?\)$/i,
|
||||
hueRe: /^(.+?)(deg|grad|rad|turn)$/i,
|
||||
|
||||
/* HELPERS */
|
||||
|
||||
_hue2deg: ( hue: string ): number => {
|
||||
|
||||
const match = hue.match ( HSL.hueRe );
|
||||
|
||||
if ( match ) {
|
||||
|
||||
const [, number, unit] = match;
|
||||
|
||||
switch ( unit ) {
|
||||
case 'grad': return _.channel.clamp.h ( parseFloat ( number ) * .9 );
|
||||
case 'rad': return _.channel.clamp.h ( parseFloat ( number ) * 180 / Math.PI );
|
||||
case 'turn': return _.channel.clamp.h ( parseFloat ( number ) * 360 );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return _.channel.clamp.h ( parseFloat ( hue ) );
|
||||
|
||||
},
|
||||
|
||||
/* API */
|
||||
|
||||
parse: ( color: string ): Channels | void => {
|
||||
|
||||
const charCode = color.charCodeAt ( 0 );
|
||||
|
||||
if ( charCode !== 104 && charCode !== 72 ) return; // 'h'/'H'
|
||||
|
||||
const match = color.match ( HSL.re );
|
||||
|
||||
if ( !match ) return;
|
||||
|
||||
const [, h, s, l, a, isAlphaPercentage] = match;
|
||||
|
||||
return ChannelsReusable.set ({
|
||||
h: HSL._hue2deg ( h ),
|
||||
s: _.channel.clamp.s ( parseFloat ( s ) ),
|
||||
l: _.channel.clamp.l ( parseFloat ( l ) ),
|
||||
a: a ? _.channel.clamp.a ( isAlphaPercentage ? parseFloat ( a ) / 100 : parseFloat ( a ) ) : 1
|
||||
}, color );
|
||||
|
||||
},
|
||||
|
||||
stringify: ( channels: Channels ): string => {
|
||||
|
||||
const {h, s, l, a} = channels;
|
||||
|
||||
if ( a < 1 ) { // HSLA
|
||||
|
||||
return `hsla(${_.lang.round ( h )}, ${_.lang.round ( s )}%, ${_.lang.round ( l )}%, ${a})`;
|
||||
|
||||
} else { // HSL
|
||||
|
||||
return `hsl(${_.lang.round ( h )}, ${_.lang.round ( s )}%, ${_.lang.round ( l )}%)`;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/* EXPORT */
|
||||
|
||||
export default HSL;
|
||||
67
frontend/node_modules/khroma/src/color/index.ts
generated
vendored
Normal file
67
frontend/node_modules/khroma/src/color/index.ts
generated
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
|
||||
/* IMPORT */
|
||||
|
||||
import _ from '~/utils';
|
||||
import Hex from '~/color/hex';
|
||||
import HSL from '~/color/hsl';
|
||||
import Keyword from '~/color/keyword';
|
||||
import RGB from '~/color/rgb';
|
||||
import {TYPE} from '~/constants';
|
||||
import type {Channels} from '~/types';
|
||||
|
||||
/* MAIN */
|
||||
|
||||
const Color = {
|
||||
|
||||
/* VARIABLES */
|
||||
|
||||
format: {
|
||||
keyword: Keyword,
|
||||
hex: Hex,
|
||||
rgb: RGB,
|
||||
rgba: RGB,
|
||||
hsl: HSL,
|
||||
hsla: HSL
|
||||
},
|
||||
|
||||
/* API */
|
||||
|
||||
parse: ( color: string | Channels ): Channels => {
|
||||
|
||||
if ( typeof color !== 'string' ) return color;
|
||||
|
||||
const channels = Hex.parse ( color ) || RGB.parse ( color ) || HSL.parse ( color ) || Keyword.parse ( color ); // Color providers ordered with performance in mind
|
||||
|
||||
if ( channels ) return channels;
|
||||
|
||||
throw new Error ( `Unsupported color format: "${color}"` );
|
||||
|
||||
},
|
||||
|
||||
stringify: ( channels: Channels ): string => {
|
||||
|
||||
// SASS returns a keyword if possible, but we avoid doing that as it's slower and doesn't really add any value
|
||||
|
||||
if ( !channels.changed && channels.color ) return channels.color;
|
||||
|
||||
if ( channels.type.is ( TYPE.HSL ) || channels.data.r === undefined ) {
|
||||
|
||||
return HSL.stringify ( channels );
|
||||
|
||||
} else if ( channels.a < 1 || !Number.isInteger ( channels.r ) || !Number.isInteger ( channels.g ) || !Number.isInteger ( channels.b ) ) {
|
||||
|
||||
return RGB.stringify ( channels );
|
||||
|
||||
} else {
|
||||
|
||||
return Hex.stringify ( channels );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/* EXPORT */
|
||||
|
||||
export default Color;
|
||||
24
frontend/node_modules/khroma/src/methods/adjust_channel.ts
generated
vendored
Normal file
24
frontend/node_modules/khroma/src/methods/adjust_channel.ts
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
|
||||
/* IMPORT */
|
||||
|
||||
import _ from '~/utils';
|
||||
import Color from '~/color';
|
||||
import type {CHANNEL, Channels} from '~/types';
|
||||
|
||||
/* MAIN */
|
||||
|
||||
const adjustChannel = ( color: string | Channels, channel: CHANNEL, amount: number ): string => {
|
||||
|
||||
const channels = Color.parse ( color );
|
||||
const amountCurrent = channels[channel];
|
||||
const amountNext = _.channel.clamp[channel]( amountCurrent + amount );
|
||||
|
||||
if ( amountCurrent !== amountNext ) channels[channel] = amountNext;
|
||||
|
||||
return Color.stringify ( channels );
|
||||
|
||||
};
|
||||
|
||||
/* EXPORT */
|
||||
|
||||
export default adjustChannel;
|
||||
17
frontend/node_modules/khroma/src/methods/blue.ts
generated
vendored
Normal file
17
frontend/node_modules/khroma/src/methods/blue.ts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
|
||||
/* IMPORT */
|
||||
|
||||
import channel from '~/methods/channel';
|
||||
import type {Channels} from '~/types';
|
||||
|
||||
/* MAIN */
|
||||
|
||||
const blue = ( color: string | Channels ): number => {
|
||||
|
||||
return channel ( color, 'b' );
|
||||
|
||||
};
|
||||
|
||||
/* EXPORT */
|
||||
|
||||
export default blue;
|
||||
17
frontend/node_modules/khroma/src/methods/desaturate.ts
generated
vendored
Normal file
17
frontend/node_modules/khroma/src/methods/desaturate.ts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
|
||||
/* IMPORT */
|
||||
|
||||
import adjustChannel from '~/methods/adjust_channel';
|
||||
import type {Channels} from '~/types';
|
||||
|
||||
/* MAIN */
|
||||
|
||||
const desaturate = ( color: string | Channels, amount: number ): string => {
|
||||
|
||||
return adjustChannel ( color, 's', -amount );
|
||||
|
||||
};
|
||||
|
||||
/* EXPORT */
|
||||
|
||||
export default desaturate;
|
||||
17
frontend/node_modules/khroma/src/methods/grayscale.ts
generated
vendored
Normal file
17
frontend/node_modules/khroma/src/methods/grayscale.ts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
|
||||
/* IMPORT */
|
||||
|
||||
import change from '~/methods/change';
|
||||
import type {Channels} from '~/types';
|
||||
|
||||
/* MAIN */
|
||||
|
||||
const grayscale = ( color: string | Channels ): string => {
|
||||
|
||||
return change ( color, { s: 0 } );
|
||||
|
||||
};
|
||||
|
||||
/* EXPORT */
|
||||
|
||||
export default grayscale;
|
||||
17
frontend/node_modules/khroma/src/methods/green.ts
generated
vendored
Normal file
17
frontend/node_modules/khroma/src/methods/green.ts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
|
||||
/* IMPORT */
|
||||
|
||||
import channel from '~/methods/channel';
|
||||
import type {Channels} from '~/types';
|
||||
|
||||
/* MAIN */
|
||||
|
||||
const green = ( color: string | Channels ): number => {
|
||||
|
||||
return channel ( color, 'g' );
|
||||
|
||||
};
|
||||
|
||||
/* EXPORT */
|
||||
|
||||
export default green;
|
||||
25
frontend/node_modules/khroma/src/methods/hsla.ts
generated
vendored
Normal file
25
frontend/node_modules/khroma/src/methods/hsla.ts
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
|
||||
/* IMPORT */
|
||||
|
||||
import _ from '~/utils';
|
||||
import ChannelsReusable from '~/channels/reusable';
|
||||
import Color from '~/color';
|
||||
|
||||
/* MAIN */
|
||||
|
||||
const hsla = ( h: number, s: number, l: number, a: number = 1 ): string => {
|
||||
|
||||
const channels = ChannelsReusable.set ({
|
||||
h: _.channel.clamp.h ( h ),
|
||||
s: _.channel.clamp.s ( s ),
|
||||
l: _.channel.clamp.l ( l ),
|
||||
a: _.channel.clamp.a ( a )
|
||||
});
|
||||
|
||||
return Color.stringify ( channels );
|
||||
|
||||
};
|
||||
|
||||
/* EXPORT */
|
||||
|
||||
export default hsla;
|
||||
17
frontend/node_modules/khroma/src/methods/hue.ts
generated
vendored
Normal file
17
frontend/node_modules/khroma/src/methods/hue.ts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
|
||||
/* IMPORT */
|
||||
|
||||
import channel from '~/methods/channel';
|
||||
import type {Channels} from '~/types';
|
||||
|
||||
/* MAIN */
|
||||
|
||||
const hue = ( color: string | Channels ): number => {
|
||||
|
||||
return channel ( color, 'h' );
|
||||
|
||||
};
|
||||
|
||||
/* EXPORT */
|
||||
|
||||
export default hue;
|
||||
17
frontend/node_modules/khroma/src/methods/is_dark.ts
generated
vendored
Normal file
17
frontend/node_modules/khroma/src/methods/is_dark.ts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
|
||||
/* IMPORT */
|
||||
|
||||
import isLight from '~/methods/is_light';
|
||||
import type {Channels} from '~/types';
|
||||
|
||||
/* MAIN */
|
||||
|
||||
const isDark = ( color: string | Channels ): boolean => {
|
||||
|
||||
return !isLight ( color );
|
||||
|
||||
};
|
||||
|
||||
/* EXPORT */
|
||||
|
||||
export default isDark;
|
||||
17
frontend/node_modules/khroma/src/methods/lightness.ts
generated
vendored
Normal file
17
frontend/node_modules/khroma/src/methods/lightness.ts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
|
||||
/* IMPORT */
|
||||
|
||||
import channel from '~/methods/channel';
|
||||
import type {Channels} from '~/types';
|
||||
|
||||
/* MAIN */
|
||||
|
||||
const lightness = ( color: string | Channels ): number => {
|
||||
|
||||
return channel ( color, 'l' );
|
||||
|
||||
};
|
||||
|
||||
/* EXPORT */
|
||||
|
||||
export default lightness;
|
||||
17
frontend/node_modules/khroma/src/methods/opacify.ts
generated
vendored
Normal file
17
frontend/node_modules/khroma/src/methods/opacify.ts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
|
||||
/* IMPORT */
|
||||
|
||||
import adjustChannel from '~/methods/adjust_channel';
|
||||
import type {Channels} from '~/types';
|
||||
|
||||
/* MAIN */
|
||||
|
||||
const opacify = ( color: string | Channels, amount: number ): string => {
|
||||
|
||||
return adjustChannel ( color, 'a', amount );
|
||||
|
||||
};
|
||||
|
||||
/* EXPORT */
|
||||
|
||||
export default opacify;
|
||||
36
frontend/node_modules/khroma/src/methods/rgba.ts
generated
vendored
Normal file
36
frontend/node_modules/khroma/src/methods/rgba.ts
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
|
||||
/* IMPORT */
|
||||
|
||||
import _ from '~/utils';
|
||||
import ChannelsReusable from '~/channels/reusable';
|
||||
import Color from '~/color';
|
||||
import change from '~/methods/change';
|
||||
import type {Channels} from '~/types';
|
||||
|
||||
/* TYPES */
|
||||
|
||||
type IRgba = {
|
||||
( color: string | Channels, opacity: number ): string,
|
||||
( r: number, g: number, b: number, a?: number ): string
|
||||
};
|
||||
|
||||
/* MAIN */
|
||||
|
||||
const rgba: IRgba = ( r: string | Channels | number, g: number, b: number = 0, a: number = 1 ): string => { //TSC: `b` shouldn't have a default value
|
||||
|
||||
if ( typeof r !== 'number' ) return change ( r, { a: g } );
|
||||
|
||||
const channels = ChannelsReusable.set ({
|
||||
r: _.channel.clamp.r ( r ),
|
||||
g: _.channel.clamp.g ( g ),
|
||||
b: _.channel.clamp.b ( b ),
|
||||
a: _.channel.clamp.a ( a )
|
||||
});
|
||||
|
||||
return Color.stringify ( channels );
|
||||
|
||||
};
|
||||
|
||||
/* EXPORT */
|
||||
|
||||
export default rgba;
|
||||
17
frontend/node_modules/khroma/src/methods/saturation.ts
generated
vendored
Normal file
17
frontend/node_modules/khroma/src/methods/saturation.ts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
|
||||
/* IMPORT */
|
||||
|
||||
import channel from '~/methods/channel';
|
||||
import type {Channels} from '~/types';
|
||||
|
||||
/* MAIN */
|
||||
|
||||
const saturation = ( color: string | Channels ): number => {
|
||||
|
||||
return channel ( color, 's' );
|
||||
|
||||
};
|
||||
|
||||
/* EXPORT */
|
||||
|
||||
export default saturation;
|
||||
29
frontend/node_modules/khroma/src/methods/scale.ts
generated
vendored
Normal file
29
frontend/node_modules/khroma/src/methods/scale.ts
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
|
||||
/* IMPORT */
|
||||
|
||||
import _ from '~/utils';
|
||||
import Color from '~/color';
|
||||
import adjust from '~/methods/adjust';
|
||||
import type {CHANNELS, Channels} from '~/types';
|
||||
|
||||
/* MAIN */
|
||||
|
||||
const scale = ( color: string | Channels, channels: Partial<CHANNELS> ): string => {
|
||||
|
||||
const ch = Color.parse ( color );
|
||||
const adjustments: Partial<CHANNELS> = {};
|
||||
const delta = ( amount: number, weight: number, max: number ) => weight > 0 ? ( max - amount ) * weight / 100 : amount * weight / 100;
|
||||
|
||||
for ( const c in channels ) {
|
||||
|
||||
adjustments[c] = delta ( ch[c], channels[c], _.channel.max[c] );
|
||||
|
||||
}
|
||||
|
||||
return adjust ( color, adjustments );
|
||||
|
||||
};
|
||||
|
||||
/* EXPORT */
|
||||
|
||||
export default scale;
|
||||
17
frontend/node_modules/khroma/src/methods/transparentize.ts
generated
vendored
Normal file
17
frontend/node_modules/khroma/src/methods/transparentize.ts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
|
||||
/* IMPORT */
|
||||
|
||||
import adjustChannel from '~/methods/adjust_channel';
|
||||
import type {Channels} from '~/types';
|
||||
|
||||
/* MAIN */
|
||||
|
||||
const transparentize = ( color: string | Channels, amount: number ): string => {
|
||||
|
||||
return adjustChannel ( color, 'a', -amount );
|
||||
|
||||
};
|
||||
|
||||
/* EXPORT */
|
||||
|
||||
export default transparentize;
|
||||
20
frontend/node_modules/khroma/src/utils/unit.ts
generated
vendored
Normal file
20
frontend/node_modules/khroma/src/utils/unit.ts
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
|
||||
/* MAIN */
|
||||
|
||||
const Unit = {
|
||||
|
||||
/* API */
|
||||
|
||||
dec2hex: ( dec: number ): string => {
|
||||
|
||||
const hex = Math.round ( dec ).toString ( 16 );
|
||||
|
||||
return hex.length > 1 ? hex : `0${hex}`;
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/* EXPORT */
|
||||
|
||||
export default Unit;
|
||||
421
frontend/node_modules/khroma/tasks/benchmark.js
generated
vendored
Normal file
421
frontend/node_modules/khroma/tasks/benchmark.js
generated
vendored
Normal file
@@ -0,0 +1,421 @@
|
||||
|
||||
/* IMPORT */
|
||||
|
||||
import benchmark from 'benchloop';
|
||||
import Color from '../dist/color/index.js';
|
||||
import {hex, rgb, rgba, hsl, hsla, channel, red, green, blue, alpha, hue, saturation, lightness, darken, lighten, opacify, transparentize, saturate, desaturate, grayscale, invert, complement, scale, adjust, change, mix, contrast, luminance, isDark, isLight, isTransparent, toKeyword, toHex, toRgba, toHsla} from '../dist/index.js';
|
||||
|
||||
/* MAIN */
|
||||
|
||||
benchmark.config ({
|
||||
iterations: 10_000
|
||||
});
|
||||
|
||||
benchmark.group ( 'parse', () => {
|
||||
|
||||
benchmark ({
|
||||
name: 'keyword',
|
||||
fn: () => {
|
||||
Color.parse ( 'blue' );
|
||||
}
|
||||
});
|
||||
|
||||
benchmark.group ( 'hex', () => {
|
||||
|
||||
benchmark ({
|
||||
name: 'rgb',
|
||||
fn: () => {
|
||||
Color.parse ( '#fc0' );
|
||||
}
|
||||
});
|
||||
|
||||
benchmark ({
|
||||
name: 'rgba',
|
||||
fn: () => {
|
||||
Color.parse ( '#fc08' );
|
||||
}
|
||||
});
|
||||
|
||||
benchmark ({
|
||||
name: 'rrggbb',
|
||||
fn: () => {
|
||||
Color.parse ( '#ffcc00' );
|
||||
}
|
||||
});
|
||||
|
||||
benchmark ({
|
||||
name: 'rrggbbaa',
|
||||
fn: () => {
|
||||
Color.parse ( '#ffcc0088' );
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
benchmark.group ( 'rgb', () => {
|
||||
|
||||
benchmark ({
|
||||
name: 'rgb',
|
||||
fn: () => {
|
||||
Color.parse ( 'rgb(255, 204, 0)' );
|
||||
}
|
||||
});
|
||||
|
||||
benchmark ({
|
||||
name: 'rgba',
|
||||
fn: () => {
|
||||
Color.parse ( 'rgb(255, 204, 0, .5)' );
|
||||
}
|
||||
});
|
||||
|
||||
benchmark ({
|
||||
name: 'rgba:percentage',
|
||||
fn: () => {
|
||||
Color.parse ( 'rgb(100%, 80%, 0%, .5)' );
|
||||
}
|
||||
});
|
||||
|
||||
benchmark ({
|
||||
name: 'rgba:scientific',
|
||||
fn: () => {
|
||||
Color.parse ( 'rgba(1e2, .5e1, .5e0, +.25e2%)' );
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
benchmark.group ( 'hsl', () => {
|
||||
|
||||
benchmark ({
|
||||
name: 'hsl',
|
||||
fn: () => {
|
||||
Color.parse ( 'hsl(150, 50%, 50%)' );
|
||||
}
|
||||
});
|
||||
|
||||
benchmark ({
|
||||
name: 'hsla',
|
||||
fn: () => {
|
||||
Color.parse ( 'hsla(150, 50%, 50%, .5)' );
|
||||
}
|
||||
});
|
||||
|
||||
benchmark ({
|
||||
name: 'hsla:deg',
|
||||
fn: () => {
|
||||
Color.parse ( 'hsla(0deg, 50%, 50%, .5)' );
|
||||
}
|
||||
});
|
||||
|
||||
benchmark ({
|
||||
name: 'hsla:scientific',
|
||||
fn: () => {
|
||||
Color.parse ( 'hsla(1e2, 2e1%, .5e2%, +.25e2%)' );
|
||||
}
|
||||
});
|
||||
|
||||
benchmark ({
|
||||
name: 'hsla:grad',
|
||||
fn: () => {
|
||||
Color.parse ( 'hsla(0grad, 50%, 50%, .5)' );
|
||||
}
|
||||
});
|
||||
|
||||
benchmark ({
|
||||
name: 'hsla:rad',
|
||||
fn: () => {
|
||||
Color.parse ( 'hsla(3.14rad, 50%, 50%, .5)' );
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
benchmark ({
|
||||
name: 'hsla:turn',
|
||||
fn: () => {
|
||||
Color.parse ( 'hsla(1turn, 50%, 50%, .5)' );
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
benchmark.group ( 'stringify', () => {
|
||||
|
||||
const channels = Color.parse ( '#ff00ff' );
|
||||
|
||||
benchmark ({
|
||||
name: 'keyword',
|
||||
fn: () => {
|
||||
toKeyword ( channels );
|
||||
}
|
||||
});
|
||||
|
||||
benchmark ({
|
||||
name: 'hex',
|
||||
fn: () => {
|
||||
toHex ( channels );
|
||||
}
|
||||
});
|
||||
|
||||
benchmark ({
|
||||
name: 'rgba',
|
||||
fn: () => {
|
||||
toRgba ( channels );
|
||||
}
|
||||
});
|
||||
|
||||
benchmark ({
|
||||
name: 'hsla',
|
||||
fn: () => {
|
||||
toHsla ( channels );
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
benchmark.group ( 'create', () => {
|
||||
|
||||
benchmark ({
|
||||
name: 'hex',
|
||||
fn: () => {
|
||||
hex ( 255, 204, 0 );
|
||||
}
|
||||
});
|
||||
|
||||
benchmark ({
|
||||
name: 'rgb',
|
||||
fn: () => {
|
||||
rgb ( 255, 204, 0 );
|
||||
}
|
||||
});
|
||||
|
||||
benchmark ({
|
||||
name: 'rgba',
|
||||
fn: () => {
|
||||
rgba ( 255, 204, 0, 136 );
|
||||
}
|
||||
});
|
||||
|
||||
benchmark ({
|
||||
name: 'hsl',
|
||||
fn: () => {
|
||||
hsl ( 150, 50, 50 );
|
||||
}
|
||||
});
|
||||
|
||||
benchmark ({
|
||||
name: 'hsla',
|
||||
fn: () => {
|
||||
hsla ( 150, 50, 50, .5 );
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
benchmark.group ( 'get.channel', () => {
|
||||
|
||||
benchmark ({
|
||||
name: 'channel',
|
||||
fn: () => {
|
||||
channel ( '#ffcc00', 'r' );
|
||||
}
|
||||
});
|
||||
|
||||
benchmark ({
|
||||
name: 'red',
|
||||
fn: () => {
|
||||
red ( '#ffcc00' );
|
||||
}
|
||||
});
|
||||
|
||||
benchmark ({
|
||||
name: 'green',
|
||||
fn: () => {
|
||||
green ( '#ffcc00' );
|
||||
}
|
||||
});
|
||||
|
||||
benchmark ({
|
||||
name: 'blue',
|
||||
fn: () => {
|
||||
blue ( '#ffcc00' );
|
||||
}
|
||||
});
|
||||
|
||||
benchmark ({
|
||||
name: 'hue',
|
||||
fn: () => {
|
||||
hue ( '#ffcc00' );
|
||||
}
|
||||
});
|
||||
|
||||
benchmark ({
|
||||
name: 'saturation',
|
||||
fn: () => {
|
||||
saturation ( '#ffcc00' );
|
||||
}
|
||||
});
|
||||
|
||||
benchmark ({
|
||||
name: 'lightness',
|
||||
fn: () => {
|
||||
lightness ( '#ffcc00' );
|
||||
}
|
||||
});
|
||||
|
||||
benchmark ({
|
||||
name: 'alpha',
|
||||
fn: () => {
|
||||
alpha ( '#ffcc00' );
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
benchmark.group ( 'get.more', () => {
|
||||
|
||||
benchmark ({
|
||||
name: 'contrast',
|
||||
fn: () => {
|
||||
contrast ( '#000000', '#ffffff' );
|
||||
}
|
||||
});
|
||||
|
||||
benchmark ({
|
||||
name: 'luminance',
|
||||
fn: () => {
|
||||
luminance ( '#ffcc00' );
|
||||
}
|
||||
});
|
||||
|
||||
benchmark ({
|
||||
name: 'isDark',
|
||||
fn: () => {
|
||||
isDark ( '#ffcc00' );
|
||||
}
|
||||
});
|
||||
|
||||
benchmark ({
|
||||
name: 'isLight',
|
||||
fn: () => {
|
||||
isLight ( '#ffcc00' );
|
||||
}
|
||||
});
|
||||
|
||||
benchmark ({
|
||||
name: 'isTransparent',
|
||||
fn: () => {
|
||||
isTransparent ( '#ffcc00' );
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
benchmark.group ( 'edit.channel', () => {
|
||||
|
||||
benchmark ({
|
||||
name: 'saturate',
|
||||
fn: () => {
|
||||
saturate ( '#ffcc00', 50 );
|
||||
}
|
||||
});
|
||||
|
||||
benchmark ({
|
||||
name: 'desaturate',
|
||||
fn: () => {
|
||||
desaturate ( '#ffcc00', 50 );
|
||||
}
|
||||
});
|
||||
|
||||
benchmark ({
|
||||
name: 'lighten',
|
||||
fn: () => {
|
||||
lighten ( '#ffcc00', 50 );
|
||||
}
|
||||
});
|
||||
|
||||
benchmark ({
|
||||
name: 'darken',
|
||||
fn: () => {
|
||||
darken ( '#ffcc00', 50 );
|
||||
}
|
||||
});
|
||||
|
||||
benchmark ({
|
||||
name: 'opacify',
|
||||
fn: () => {
|
||||
opacify ( '#ffcc00', .5 );
|
||||
}
|
||||
});
|
||||
|
||||
benchmark ({
|
||||
name: 'transparentize',
|
||||
fn: () => {
|
||||
transparentize ( '#ffcc00', .5 );
|
||||
}
|
||||
});
|
||||
|
||||
benchmark ({
|
||||
name: 'rgba',
|
||||
fn: () => {
|
||||
rgba ( '#ffcc00', .5 );
|
||||
}
|
||||
});
|
||||
|
||||
benchmark ({
|
||||
name: 'complement',
|
||||
fn: () => {
|
||||
complement ( '#ffcc00' );
|
||||
}
|
||||
});
|
||||
|
||||
benchmark ({
|
||||
name: 'grayscale',
|
||||
fn: () => {
|
||||
grayscale ( '#ffcc00' );
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
benchmark.group ( 'edit.more', () => {
|
||||
|
||||
benchmark ({
|
||||
name: 'adjust',
|
||||
fn: () => {
|
||||
adjust ( '#ffcc00', { a: -.5 } );
|
||||
}
|
||||
});
|
||||
|
||||
benchmark ({
|
||||
name: 'change',
|
||||
fn: () => {
|
||||
change ( '#ffcc00', { a: .5 } );
|
||||
}
|
||||
});
|
||||
|
||||
benchmark ({
|
||||
name: 'invert',
|
||||
fn: () => {
|
||||
invert ( '#ffcc00', 50 );
|
||||
}
|
||||
});
|
||||
|
||||
benchmark ({
|
||||
name: 'mix',
|
||||
fn: () => {
|
||||
mix ( '#ffcc00', '#000000', 50 );
|
||||
}
|
||||
});
|
||||
|
||||
benchmark ({
|
||||
name: 'scale',
|
||||
fn: () => {
|
||||
scale ( '#ffcc00', { r: 50, g: 50, b: 50 } );
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
benchmark.summary ();
|
||||
66
frontend/node_modules/khroma/test/color/hex.js
generated
vendored
Normal file
66
frontend/node_modules/khroma/test/color/hex.js
generated
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
|
||||
/* IMPORT */
|
||||
|
||||
import {describe} from 'fava';
|
||||
import Color from '../../dist/color/index.js';
|
||||
|
||||
/* MAIN */
|
||||
|
||||
describe ( 'Hex', it => {
|
||||
|
||||
it ( 'parses hex colors', t => {
|
||||
|
||||
const tests = [
|
||||
/* RGB */
|
||||
['#000', '#000000'],
|
||||
['#fff', '#ffffff'],
|
||||
['#a2b', '#aa22bb'],
|
||||
['#a2B', '#aa22bb'],
|
||||
/* RGBA */
|
||||
['#0000', '#00000000'],
|
||||
['#fffF', '#ffffff'],
|
||||
['#fff8', '#ffffff88'],
|
||||
['#a2bf', '#aa22bb'],
|
||||
['#a2Bf', '#aa22bb'],
|
||||
/* RRGGBB */
|
||||
['#000000', '#000000'],
|
||||
['#FFFFFF', '#ffffff'],
|
||||
['#ffffff', '#ffffff'],
|
||||
['#ae12b4', '#ae12b4'],
|
||||
['#Ae12B4', '#ae12b4'],
|
||||
/* RRGGBBAA */
|
||||
['#000000ff', '#000000'],
|
||||
['#00000000', '#00000000'],
|
||||
['#ffffffa8', '#ffffffa8'],
|
||||
['#ffffffA8', '#ffffffa8']
|
||||
];
|
||||
|
||||
tests.forEach ( ([ input, output ]) => {
|
||||
t.is ( Color.format.hex.stringify ( Color.parse ( input ) ), output );
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
it ( 'throws with unsupported colors', t => {
|
||||
|
||||
const colors = [
|
||||
'#',
|
||||
'#0',
|
||||
'#00',
|
||||
'#ggg',
|
||||
'#zzz',
|
||||
'fff',
|
||||
'#0 0 0',
|
||||
'# 000',
|
||||
'#aabbc',
|
||||
'#aabbccd',
|
||||
'#aabbccdde'
|
||||
];
|
||||
|
||||
colors.forEach ( color => {
|
||||
t.throws ( () => Color.parse ( color ), /unsupported/i );
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
73
frontend/node_modules/khroma/test/color/rgb.js
generated
vendored
Normal file
73
frontend/node_modules/khroma/test/color/rgb.js
generated
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
|
||||
/* IMPORT */
|
||||
|
||||
import {describe} from 'fava';
|
||||
import Color from '../../dist/color/index.js';
|
||||
|
||||
/* MAIN */
|
||||
|
||||
describe ( 'RGB', it => {
|
||||
|
||||
it ( 'parses RGB colors', t => {
|
||||
|
||||
const tests = [
|
||||
/* DECIAML 0~255 */
|
||||
['rgb(1, 20, 255)', 'rgb(1, 20, 255)'],
|
||||
['rgb(1.99, 20.5, 255)', 'rgb(1.99, 20.5, 255)'],
|
||||
['rgb(300, 255, -100)', 'rgb(255, 255, 0)'],
|
||||
/* PERCENTAGE 0~100 */
|
||||
['rgb(10%, 20%, 30%)', 'rgb(25.5, 51, 76.5)'],
|
||||
['rgb(10.5%, 20.7%, 30%)', 'rgb(26.775, 52.785, 76.5)'],
|
||||
['rgb(100% 200% -30%)', 'rgb(255, 255, 0)'],
|
||||
/* WITH COMMAS AND WEIRD SPACES */
|
||||
['rgb( 1 , 20 , 255 )', 'rgb(1, 20, 255)'],
|
||||
['rgb(1,20,255)', 'rgb(1, 20, 255)'],
|
||||
['rgb( 1,20,255 )', 'rgb(1, 20, 255)'],
|
||||
/* WITHOUT COMMAS */
|
||||
['rgb(10% 20% 30%)', 'rgb(25.5, 51, 76.5)'],
|
||||
['rgb(1 20 255)', 'rgb(1, 20, 255)'],
|
||||
['rgb( 1 20 255 )', 'rgb(1, 20, 255)'],
|
||||
/* MIXED UNITS */
|
||||
['rgb(10% 20 30%)', 'rgb(25.5, 20, 76.5)'],
|
||||
['rgb(1 25.5 25.5)', 'rgb(1, 25.5, 25.5)'],
|
||||
/* WEIRD CASING */
|
||||
['RGB(1, 20, 255)', 'rgb(1, 20, 255)'],
|
||||
['rGb(1, 20, 255)', 'rgb(1, 20, 255)']
|
||||
];
|
||||
|
||||
tests.forEach ( ([ input, output ]) => {
|
||||
t.is ( Color.format.rgb.stringify ( Color.parse ( input ) ), output );
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
it ( 'throws with unsupported colors', t => {
|
||||
|
||||
const colors = [
|
||||
'rgb()',
|
||||
'rgb(1, 2, 3, 4, 5)',
|
||||
'rgb(1/2/3)',
|
||||
'rgb(1,, 20, 255)',
|
||||
'rgb(1%,, 20%, 255%)',
|
||||
'rgb(1%, 255%)',
|
||||
'rgb(1%, 10%%, 255%)',
|
||||
'rgb(1%, %10%, 255%)',
|
||||
'rgb(1)',
|
||||
'rgb(1, 20, 255',
|
||||
'rgb 1, 20, 255',
|
||||
'rgb 1, 20, 255)',
|
||||
'rgb(1, a, 255)',
|
||||
'rgb (1, 2, 255)',
|
||||
'rgb(1,2,3..5)',
|
||||
'rgb(1, 2, 3.4.5)',
|
||||
'rgbQ(1, 2, 255)',
|
||||
'r g b(1, 2, 255)'
|
||||
];
|
||||
|
||||
colors.forEach ( color => {
|
||||
t.throws ( () => Color.parse ( color ), /unsupported/i );
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
78
frontend/node_modules/khroma/test/color/rgba.js
generated
vendored
Normal file
78
frontend/node_modules/khroma/test/color/rgba.js
generated
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
|
||||
/* IMPORT */
|
||||
|
||||
import {describe} from 'fava';
|
||||
import Color from '../../dist/color/index.js';
|
||||
|
||||
/* MAIN */
|
||||
|
||||
describe ( 'RGBA', it => {
|
||||
|
||||
it ( 'parses RGBA colors', t => {
|
||||
|
||||
const tests = [
|
||||
/* FRACTION 0~1 */
|
||||
['rgba(0, 0, 0, 0)', 'rgba(0, 0, 0, 0)'],
|
||||
['rgba(0, 0, 0)', 'rgb(0, 0, 0)'],
|
||||
['rgba(0, 0, 0, 10)', 'rgb(0, 0, 0)'],
|
||||
['rgba(0, 0, 0, -10)', 'rgba(0, 0, 0, 0)'],
|
||||
['rgba(0, 0, 0, 0.5)', 'rgba(0, 0, 0, 0.5)'],
|
||||
['rgba(0, 0, 0, .5)', 'rgba(0, 0, 0, 0.5)'],
|
||||
['rgba(0, 0, 0, 0.5 )', 'rgba(0, 0, 0, 0.5)'],
|
||||
/* PERCENTAGE 0~100 */
|
||||
['rgba(0, 0, 0, 0%)', 'rgba(0, 0, 0, 0)'],
|
||||
['rgba(0, 0, 0, 100%)', 'rgb(0, 0, 0)'],
|
||||
['rgba(0, 0, 0, 110%)', 'rgb(0, 0, 0)'],
|
||||
['rgba(0, 0, 0, -110%)', 'rgba(0, 0, 0, 0)'],
|
||||
['rgba(0, 0, 0, 50%)', 'rgba(0, 0, 0, 0.5)'],
|
||||
['rgba(0, 0, 0, 50.5%)', 'rgba(0, 0, 0, 0.505)'],
|
||||
/* WITH COMMAS AND WEIRD SPACES */
|
||||
['rgba( 1 , 20 , 255, 0.5 )', 'rgba(1, 20, 255, 0.5)'],
|
||||
['rgba(1,20,255,50%)', 'rgba(1, 20, 255, 0.5)'],
|
||||
['rgba( 1,20,255,0.5 )', 'rgba(1, 20, 255, 0.5)'],
|
||||
/* WITH SLASH */
|
||||
['rgba(51 170 51 / 0.4)', 'rgba(51, 170, 51, 0.4)'],
|
||||
['rgba(51 170 51/0.4)', 'rgba(51, 170, 51, 0.4)'],
|
||||
['rgba(51 170 51 / 40%)', 'rgba(51, 170, 51, 0.4)'],
|
||||
['rgba(51, 170, 51 / 40%)', 'rgba(51, 170, 51, 0.4)'],
|
||||
['rgba(51,170,51/40%)', 'rgba(51, 170, 51, 0.4)'],
|
||||
/* SCIENTIFIC NOTATION */
|
||||
['rgba(1e2, .5e1, .5e0, +.25e2%)', 'rgba(100, 5, 0.5, 0.25)'],
|
||||
['rgba(1e2, .5e1, .5e0, +.25e1%)', 'rgba(100, 5, 0.5, 0.025)'],
|
||||
['rgba(1e2, .5e1, .5e0, +.25e0%)', 'rgba(100, 5, 0.5, 0.0025)'],
|
||||
['rgba(1e2, .5e1, .5e0, .25e0)', 'rgba(100, 5, 0.5, 0.25)'],
|
||||
['rgba(1e2, .5e1, .5e0, .25e1)', 'rgb(100, 5, 0.5)'],
|
||||
/* MIXED UNITS */
|
||||
['rgba(1, 10%, .5e0, +.25e2%)', 'rgba(1, 25.5, 0.5, 0.25)'],
|
||||
/* WEIRD CASING */
|
||||
['RGBA(1, 20, 255, 0.5)', 'rgba(1, 20, 255, 0.5)'],
|
||||
['rgbA(1, 20, 255, 0.5)', 'rgba(1, 20, 255, 0.5)']
|
||||
];
|
||||
|
||||
tests.forEach ( ([ input, output ]) => {
|
||||
t.is ( Color.format.rgba.stringify ( Color.parse ( input ) ), output );
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
it ( 'throws with unsupported colors', t => {
|
||||
|
||||
const colors = [
|
||||
'rgba()',
|
||||
'rgba(51 170 51 0.4)',
|
||||
'rgba(1, 2, 3, 4, 5)',
|
||||
'rgba(0, 0, 0, 0..5)',
|
||||
'rgba(0, 0, 0, 0.5.)',
|
||||
'rgba(0, 0, 0, 0%%)',
|
||||
'rgba(51 170 51 // 0.4)',
|
||||
'rgba(1ee2, .5e1, .5e0, +.25e2%)',
|
||||
'rgba(1f2, .5e1, .5e0, +.25e2%)'
|
||||
];
|
||||
|
||||
colors.forEach ( color => {
|
||||
t.throws ( () => Color.parse ( color ), /unsupported/i );
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
89
frontend/node_modules/khroma/test/methods/adjust.js
generated
vendored
Normal file
89
frontend/node_modules/khroma/test/methods/adjust.js
generated
vendored
Normal file
@@ -0,0 +1,89 @@
|
||||
|
||||
/* IMPORT */
|
||||
|
||||
import {describe} from 'fava';
|
||||
import {adjust} from '../../dist/index.js';
|
||||
import Color from '../../dist/color/index.js';
|
||||
|
||||
/* MAIN */
|
||||
|
||||
describe ( 'adjust', it => {
|
||||
|
||||
it ( 'increases or decreases the value of any RGB channel of the color', t => {
|
||||
|
||||
const tests = [
|
||||
[['rgb(0, 0, 0)', { r: 100 }], 'rgb(100, 0, 0)'],
|
||||
[['rgb(0, 0, 0)', { g: 100 }], 'rgb(0, 100, 0)'],
|
||||
[['rgb(0, 0, 0)', { b: 100 }], 'rgb(0, 0, 100)'],
|
||||
[['rgb(0, 0, 0)', { r: 100, g: 100 }], 'rgb(100, 100, 0)'],
|
||||
[['rgb(0, 0, 0)', { r: 100, g: 100, b: 100 }], 'rgb(100, 100, 100)'],
|
||||
[['rgb(255, 255, 255)', { r: -100 }], 'rgb(155, 255, 255)'],
|
||||
[['rgb(255, 255, 255)', { g: -100 }], 'rgb(255, 155, 255)'],
|
||||
[['rgb(255, 255, 255)', { b: -100 }], 'rgb(255, 255, 155)'],
|
||||
[['rgb(200, 0, 0)', { r: 100 }], 'rgb(255, 0, 0)'],
|
||||
[['rgb(100, 0, 0)', { r: -200 }], 'rgb(0, 0, 0)']
|
||||
];
|
||||
|
||||
tests.forEach ( ([ args, output ]) => {
|
||||
t.is ( Color.format.rgb.stringify ( Color.parse ( adjust ( ...args ) ) ), output );
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
it ( 'increases or decreases the value of any HSL channel of the color', t => {
|
||||
|
||||
const tests = [
|
||||
[['hsl(0, 50%, 50%)', { h: 100 }], 'hsl(100, 50%, 50%)'],
|
||||
[['hsl(0, 50%, 50%)', { s: 25 }], 'hsl(0, 75%, 50%)'],
|
||||
[['hsl(0, 50%, 50%)', { l: 25 }], 'hsl(0, 50%, 75%)'],
|
||||
[['hsl(0, 50%, 50%)', { h: 100, s: 25 }], 'hsl(100, 75%, 50%)'],
|
||||
[['hsl(0, 50%, 50%)', { h: 100, s: 25, l: 25 }], 'hsl(100, 75%, 75%)'],
|
||||
[['hsl(100, 50%, 50%)', { h: -100 }], 'hsl(0, 50%, 50%)'],
|
||||
[['hsl(0, 50%, 50%)', { s: -25 }], 'hsl(0, 25%, 50%)'],
|
||||
[['hsl(0, 50%, 50%)', { l: -25 }], 'hsl(0, 50%, 25%)'],
|
||||
[['hsl(300, 50%, 50%)', { h: 100 }], 'hsl(40, 50%, 50%)'],
|
||||
[['hsl(0, 50%, 50%)', { h: -100 }], 'hsl(-100, 50%, 50%)'],
|
||||
[['hsl(0, 100%, 50%)', { s: 25 }], 'hsl(0, 100%, 50%)'],
|
||||
[['hsl(0, 0%, 50%)', { s: -25 }], 'hsl(0, 0%, 50%)'],
|
||||
[['hsla(0, 0%, 50%, .5)', { s: -25 }], 'hsla(0, 0%, 50%, 0.5)']
|
||||
];
|
||||
|
||||
tests.forEach ( ([ args, output ]) => {
|
||||
t.is ( Color.format.hsl.stringify ( Color.parse ( adjust ( ...args ) ) ), output );
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
it ( 'increases or decreases the value of the alpha channel of the color', t => {
|
||||
|
||||
const tests = [
|
||||
[['rgba(0, 0, 0, 0)', { a: 0.5 }], 'rgba(0, 0, 0, 0.5)'],
|
||||
[['hsla(0, 0%, 0%, 0)', { a: 0.5 }], 'hsla(0, 0%, 0%, 0.5)'],
|
||||
[['rgba(0, 0, 0, 0)', { a: 1 }], '#000000'],
|
||||
[['rgba(0, 0, 0, 1)', { a: -0.5 }], 'rgba(0, 0, 0, 0.5)'],
|
||||
[['rgba(0, 0, 0, 1)', { a: -1 }], 'rgba(0, 0, 0, 0)'],
|
||||
[['rgba(0, 0, 0, 0.5)', { a: 1 }], '#000000'],
|
||||
[['rgba(0, 0, 0, 0.5)', { a: -1 }], 'rgba(0, 0, 0, 0)']
|
||||
];
|
||||
|
||||
tests.forEach ( ([ args, output ]) => {
|
||||
t.is ( adjust ( ...args ), output );
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
it ( 'throws when setting RGB and HSL channels at the same time', t => {
|
||||
|
||||
const tests = [
|
||||
['#000', { r: 10, h: 10 }],
|
||||
['#000', { g: 10, l: 10 }],
|
||||
['#000', { b: 10, s: 10 }]
|
||||
];
|
||||
|
||||
tests.forEach ( args => {
|
||||
t.throws ( () => adjust ( ...args ), /cannot.*at the same time/i );
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
25
frontend/node_modules/khroma/test/methods/complement.js
generated
vendored
Normal file
25
frontend/node_modules/khroma/test/methods/complement.js
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
|
||||
/* IMPORT */
|
||||
|
||||
import {describe} from 'fava';
|
||||
import {complement} from '../../dist/index.js';
|
||||
|
||||
/* MAIN */
|
||||
|
||||
describe ( 'complement', it => {
|
||||
|
||||
it ( 'gets the complement of the color', t => {
|
||||
|
||||
const tests = [
|
||||
['#6b717f', 'hsl(42, 8.547008547%, 45.8823529412%)'],
|
||||
['#d2e1dd', 'hsl(344, 20%, 85.2941176471%)'],
|
||||
['#036', 'hsl(30, 100%, 20%)']
|
||||
];
|
||||
|
||||
tests.forEach ( ([ color, output ]) => {
|
||||
t.is ( complement ( color ), output );
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
28
frontend/node_modules/khroma/test/methods/contrast.js
generated
vendored
Normal file
28
frontend/node_modules/khroma/test/methods/contrast.js
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
|
||||
/* IMPORT */
|
||||
|
||||
import {describe} from 'fava';
|
||||
import {contrast} from '../../dist/index.js';
|
||||
|
||||
/* MAIN */
|
||||
|
||||
describe ( 'contrast', it => {
|
||||
|
||||
it ( 'gets the contrast ratio between two colors', t => {
|
||||
|
||||
const tests = [
|
||||
['#000000', '#000000', 1],
|
||||
['#ffffff', '#ffffff', 1],
|
||||
['#000000', '#ffffff', 10],
|
||||
['#ffffff', '#000000', 10],
|
||||
['#888888', '#ffffff', 4.0617165366],
|
||||
['#ffffff', '#888888', 4.0617165366]
|
||||
];
|
||||
|
||||
tests.forEach ( ([ color1, color2, output ]) => {
|
||||
t.is ( contrast ( color1, color2 ), output );
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
27
frontend/node_modules/khroma/test/methods/darken.js
generated
vendored
Normal file
27
frontend/node_modules/khroma/test/methods/darken.js
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
|
||||
/* IMPORT */
|
||||
|
||||
import {describe} from 'fava';
|
||||
import {darken} from '../../dist/index.js';
|
||||
|
||||
/* MAIN */
|
||||
|
||||
describe ( 'darken', it => {
|
||||
|
||||
it ( 'decreases the lightness channel of the color', t => {
|
||||
|
||||
const tests = [
|
||||
[['hsl(0, 0%, 100%)', 0], 'hsl(0, 0%, 100%)'],
|
||||
[['hsl(0, 0%, 100%)', 50], 'hsl(0, 0%, 50%)'],
|
||||
[['hsl(0, 0%, 100%)', 75], 'hsl(0, 0%, 25%)'],
|
||||
[['hsl(0, 0%, 100%)', 100], 'hsl(0, 0%, 0%)'],
|
||||
[['hsl(0, 0%, 50%)', 100], 'hsl(0, 0%, 0%)']
|
||||
];
|
||||
|
||||
tests.forEach ( ([ args, output ]) => {
|
||||
t.is ( darken ( ...args ), output );
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
28
frontend/node_modules/khroma/test/methods/desaturate.js
generated
vendored
Normal file
28
frontend/node_modules/khroma/test/methods/desaturate.js
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
|
||||
/* IMPORT */
|
||||
|
||||
import {describe} from 'fava';
|
||||
import {desaturate} from '../../dist/index.js';
|
||||
|
||||
/* MAIN */
|
||||
|
||||
describe ( 'desaturate', it => {
|
||||
|
||||
it ( 'decreases the saturation channel of the color', t => {
|
||||
|
||||
const tests = [
|
||||
[['hsl(0, 100%, 50%)', 0], 'hsl(0, 100%, 50%)'],
|
||||
[['hsl(0, 100%, 50%)', 50], 'hsl(0, 50%, 50%)'],
|
||||
[['hsl(0, 100%, 50%)', 75], 'hsl(0, 25%, 50%)'],
|
||||
[['hsl(0, 100%, 50%)', 100], 'hsl(0, 0%, 50%)'],
|
||||
[['hsl(0, 50%, 50%)', 100], 'hsl(0, 0%, 50%)'],
|
||||
[['hsl(0, 0%, 50%)', 100], 'hsl(0, 0%, 50%)']
|
||||
];
|
||||
|
||||
tests.forEach ( ([ args, output ]) => {
|
||||
t.is ( desaturate ( ...args ), output );
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
25
frontend/node_modules/khroma/test/methods/grayscale.js
generated
vendored
Normal file
25
frontend/node_modules/khroma/test/methods/grayscale.js
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
|
||||
/* IMPORT */
|
||||
|
||||
import {describe} from 'fava';
|
||||
import {grayscale} from '../../dist/index.js';
|
||||
|
||||
/* MAIN */
|
||||
|
||||
describe ( 'grayscale', it => {
|
||||
|
||||
it ( 'gets the grayscale version of the color', t => {
|
||||
|
||||
const tests = [
|
||||
['#6b717f', 'hsl(222, 0%, 45.8823529412%)'],
|
||||
['#d2e1dd', 'hsl(164, 0%, 85.2941176471%)'],
|
||||
['#036', 'hsl(210, 0%, 20%)']
|
||||
];
|
||||
|
||||
tests.forEach ( ([ color, output ]) => {
|
||||
t.is ( grayscale ( color ), output );
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
41
frontend/node_modules/khroma/test/methods/hex.js
generated
vendored
Normal file
41
frontend/node_modules/khroma/test/methods/hex.js
generated
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
|
||||
/* IMPORT */
|
||||
|
||||
import {describe} from 'fava';
|
||||
import {hex} from '../../dist/index.js';
|
||||
|
||||
/* MAIN */
|
||||
|
||||
describe ( 'hex', it => {
|
||||
|
||||
it ( 'creates a new color given its rgba channels', t => {
|
||||
|
||||
const tests = [
|
||||
[[0, 0, 0, 0], 'rgba(0, 0, 0, 0)'],
|
||||
[[255, 255, 255, 0.5], 'rgba(255, 255, 255, 0.5)'],
|
||||
[[0, 0, 0, 1], '#000000'],
|
||||
[[128, 128, 128, 1], '#808080'],
|
||||
[[-1, -1, -1, -1], 'rgba(0, 0, 0, 0)'],
|
||||
[[1000, 1000, 1000, 1000], '#ffffff']
|
||||
];
|
||||
|
||||
tests.forEach ( ([ args, output ]) => {
|
||||
t.is ( hex ( ...args ), output );
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
it ( 'allows ommiting the alpha channel', t => {
|
||||
|
||||
const tests = [
|
||||
[[0, 0, 0], '#000000'],
|
||||
[[255, 255, 255], '#ffffff']
|
||||
];
|
||||
|
||||
tests.forEach ( ([ args, output ]) => {
|
||||
t.is ( hex ( ...args ), output );
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
28
frontend/node_modules/khroma/test/methods/is_light.js
generated
vendored
Normal file
28
frontend/node_modules/khroma/test/methods/is_light.js
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
|
||||
/* IMPORT */
|
||||
|
||||
import {describe} from 'fava';
|
||||
import {isLight} from '../../dist/index.js';
|
||||
|
||||
/* MAIN */
|
||||
|
||||
describe ( 'isLight', it => {
|
||||
|
||||
it ( 'checks if the provided color is a light color', t => {
|
||||
|
||||
const tests = [
|
||||
['#000000', false],
|
||||
['#8a8a8a', false],
|
||||
['#bbbbbb', false],
|
||||
['#ffcc00', true],
|
||||
['#e0e0e0', true],
|
||||
['#ffffff', true]
|
||||
];
|
||||
|
||||
tests.forEach ( ([ color, output ]) => {
|
||||
t.is ( isLight ( color ), output );
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
33
frontend/node_modules/khroma/test/methods/is_transparent.js
generated
vendored
Normal file
33
frontend/node_modules/khroma/test/methods/is_transparent.js
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
|
||||
/* IMPORT */
|
||||
|
||||
import {describe} from 'fava';
|
||||
import {isTransparent} from '../../dist/index.js';
|
||||
|
||||
/* MAIN */
|
||||
|
||||
describe ( 'isTransparent', it => {
|
||||
|
||||
it ( 'checks if the provided color is a transparent color', t => {
|
||||
|
||||
const tests = [
|
||||
['transparent', true],
|
||||
['#00000000', true],
|
||||
['#ffffff00', true],
|
||||
['black', false],
|
||||
['#00000001', false],
|
||||
['#ffffffff', false],
|
||||
['#8a8a8a', false],
|
||||
['#bbbbbb', false],
|
||||
['#ffcc00', false],
|
||||
['#e0e0e0', false],
|
||||
['#ffffff', false]
|
||||
];
|
||||
|
||||
tests.forEach ( ([ color, output ]) => {
|
||||
t.is ( isTransparent ( color ), output );
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
28
frontend/node_modules/khroma/test/methods/lighten.js
generated
vendored
Normal file
28
frontend/node_modules/khroma/test/methods/lighten.js
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
|
||||
/* IMPORT */
|
||||
|
||||
import {describe} from 'fava';
|
||||
import {lighten} from '../../dist/index.js';
|
||||
|
||||
/* MAIN */
|
||||
|
||||
describe ( 'lighten', it => {
|
||||
|
||||
it ( 'increases the lightness channel of the color', t => {
|
||||
|
||||
const tests = [
|
||||
[['hsl(0, 0%, 0%)', 0], 'hsl(0, 0%, 0%)'],
|
||||
[['hsl(0, 0%, 0%)', 50], 'hsl(0, 0%, 50%)'],
|
||||
[['hsl(0, 0%, 0%)', 75], 'hsl(0, 0%, 75%)'],
|
||||
[['hsl(0, 0%, 0%)', 100], 'hsl(0, 0%, 100%)'],
|
||||
[['hsl(0, 0%, 50%)', 100], 'hsl(0, 0%, 100%)'],
|
||||
[['hsl(0, 0%, 100%)', 100], 'hsl(0, 0%, 100%)']
|
||||
];
|
||||
|
||||
tests.forEach ( ([ args, output ]) => {
|
||||
t.is ( lighten ( ...args ), output );
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
26
frontend/node_modules/khroma/test/methods/mix.js
generated
vendored
Normal file
26
frontend/node_modules/khroma/test/methods/mix.js
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
|
||||
/* IMPORT */
|
||||
|
||||
import {describe} from 'fava';
|
||||
import {mix} from '../../dist/index.js';
|
||||
|
||||
/* MAIN */
|
||||
|
||||
describe ( 'mix', it => {
|
||||
|
||||
it ( 'mixes two colors together', t => {
|
||||
|
||||
const tests = [
|
||||
[['#036', '#d2e1dd'], 'rgb(105, 138, 161.5)'],
|
||||
[['#036', '#d2e1dd', 75 ], 'rgb(52.5, 94.5, 131.75)'],
|
||||
[['#036', '#d2e1dd', 25 ], 'rgb(157.5, 181.5, 191.25)'],
|
||||
[['rgba(242, 236, 228, 0.5)', '#6b717f'], 'rgba(140.75, 143.75, 152.25, 0.75)']
|
||||
];
|
||||
|
||||
tests.forEach ( ([ args, output ]) => {
|
||||
t.is ( mix ( ...args ), output );
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
25
frontend/node_modules/khroma/test/methods/opacify.js
generated
vendored
Normal file
25
frontend/node_modules/khroma/test/methods/opacify.js
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
|
||||
/* IMPORT */
|
||||
|
||||
import {describe} from 'fava';
|
||||
import {opacify} from '../../dist/index.js';
|
||||
|
||||
/* MAIN */
|
||||
|
||||
describe ( 'opacify', it => {
|
||||
|
||||
it ( 'increases the opacity channel of the color', t => {
|
||||
|
||||
const tests = [
|
||||
[['#000000', 1], '#000000'],
|
||||
[['rgba(0, 0, 0, 0.5)', 0.5], '#000000'],
|
||||
[['rgba(0, 0, 0, 0.5)', 0.1], 'rgba(0, 0, 0, 0.6)']
|
||||
];
|
||||
|
||||
tests.forEach ( ([ args, output ]) => {
|
||||
t.is ( opacify ( ...args ), output );
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
28
frontend/node_modules/khroma/test/methods/saturate.js
generated
vendored
Normal file
28
frontend/node_modules/khroma/test/methods/saturate.js
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
|
||||
/* IMPORT */
|
||||
|
||||
import {describe} from 'fava';
|
||||
import {saturate} from '../../dist/index.js';
|
||||
|
||||
/* MAIN */
|
||||
|
||||
describe ( 'saturate', it => {
|
||||
|
||||
it ( 'increases the saturation channel of the color', t => {
|
||||
|
||||
const tests = [
|
||||
[['hsl(0, 0%, 50%)', 0], 'hsl(0, 0%, 50%)'],
|
||||
[['hsl(0, 0%, 50%)', 50], 'hsl(0, 50%, 50%)'],
|
||||
[['hsl(0, 0%, 50%)', 75], 'hsl(0, 75%, 50%)'],
|
||||
[['hsl(0, 0%, 50%)', 100], 'hsl(0, 100%, 50%)'],
|
||||
[['hsl(0, 50%, 50%)', 100], 'hsl(0, 100%, 50%)'],
|
||||
[['hsl(0, 100%, 50%)', 100], 'hsl(0, 100%, 50%)']
|
||||
];
|
||||
|
||||
tests.forEach ( ([ args, output ]) => {
|
||||
t.is ( saturate ( ...args ), output );
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
26
frontend/node_modules/khroma/test/methods/transparentize.js
generated
vendored
Normal file
26
frontend/node_modules/khroma/test/methods/transparentize.js
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
|
||||
/* IMPORT */
|
||||
|
||||
import {describe} from 'fava';
|
||||
import {transparentize} from '../../dist/index.js';
|
||||
|
||||
/* MAIN */
|
||||
|
||||
describe ( 'transparentize', it => {
|
||||
|
||||
it ( 'decreases the opacity channel of the color', t => {
|
||||
|
||||
const tests = [
|
||||
[['#000000', 1], 'rgba(0, 0, 0, 0)'],
|
||||
[['rgba(0, 0, 0, 0.5)', 0.5], 'rgba(0, 0, 0, 0)'],
|
||||
[['rgba(0, 0, 0, 0.5)', 1], 'rgba(0, 0, 0, 0)'],
|
||||
[['rgba(0, 0, 0, 0.5)', 0.1], 'rgba(0, 0, 0, 0.4)']
|
||||
];
|
||||
|
||||
tests.forEach ( ([ args, output ]) => {
|
||||
t.is ( transparentize ( ...args ), output );
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user