@dxyl/utils 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.es.js +8985 -0
- package/dist/index.umd.js +28 -0
- package/lib/glslang/glslang.d.ts +14 -0
- package/lib/glslang/glslang.js +113 -0
- package/lib/glslang/glslang.wasm +0 -0
- package/lib/twgsl/twgsl.js +53 -0
- package/lib/twgsl/twgsl.wasm +0 -0
- package/package.json +27 -34
- package/readme.md +0 -0
- package/types/Color.d.ts +69 -0
- package/types/Options.d.ts +70 -0
- package/types/antv-util/color/arr2rgb.d.ts +12 -0
- package/types/antv-util/color/gradient.d.ts +6 -0
- package/types/antv-util/color/index.d.ts +4 -0
- package/types/antv-util/color/rgb2arr.d.ts +6 -0
- package/types/antv-util/color/tocssgradient.d.ts +1 -0
- package/types/antv-util/color/torgb.d.ts +6 -0
- package/types/antv-util/helper/index.d.ts +2 -0
- package/types/antv-util/helper/mod.d.ts +1 -0
- package/types/antv-util/helper/to-radian.d.ts +1 -0
- package/types/antv-util/index.d.ts +3 -0
- package/types/antv-util/matrix/index.d.ts +27 -0
- package/types/antv-util/path/convert/path-2-absolute.d.ts +2 -0
- package/types/antv-util/path/convert/path-2-curve.d.ts +2 -0
- package/types/antv-util/path/convert/path-2-string.d.ts +6 -0
- package/types/antv-util/path/index.d.ts +17 -0
- package/types/antv-util/path/parser/finalize-segment.d.ts +5 -0
- package/types/antv-util/path/parser/is-arc-command.d.ts +4 -0
- package/types/antv-util/path/parser/is-digit-start.d.ts +6 -0
- package/types/antv-util/path/parser/is-path-command.d.ts +4 -0
- package/types/antv-util/path/parser/is-space.d.ts +4 -0
- package/types/antv-util/path/parser/params-count.d.ts +13 -0
- package/types/antv-util/path/parser/params-parser.d.ts +10 -0
- package/types/antv-util/path/parser/parse-path-string.d.ts +6 -0
- package/types/antv-util/path/parser/path-parser.d.ts +16 -0
- package/types/antv-util/path/parser/scan-flag.d.ts +6 -0
- package/types/antv-util/path/parser/scan-param.d.ts +6 -0
- package/types/antv-util/path/parser/scan-segment.d.ts +6 -0
- package/types/antv-util/path/parser/skip-spaces.d.ts +7 -0
- package/types/antv-util/path/process/arc-2-cubic.d.ts +7 -0
- package/types/antv-util/path/process/clone-path.d.ts +2 -0
- package/types/antv-util/path/process/fix-arc.d.ts +2 -0
- package/types/antv-util/path/process/line-2-cubic.d.ts +1 -0
- package/types/antv-util/path/process/normalize-path.d.ts +8 -0
- package/types/antv-util/path/process/normalize-segment.d.ts +6 -0
- package/types/antv-util/path/process/quad-2-cubic.d.ts +1 -0
- package/types/antv-util/path/process/reverse-curve.d.ts +2 -0
- package/types/antv-util/path/process/round-path.d.ts +6 -0
- package/types/antv-util/path/process/segment-2-cubic.d.ts +2 -0
- package/types/antv-util/path/types.d.ts +122 -0
- package/types/antv-util/path/util/distance-square-root.d.ts +1 -0
- package/types/antv-util/path/util/equalize-segments.d.ts +2 -0
- package/types/antv-util/path/util/get-draw-direction.d.ts +2 -0
- package/types/antv-util/path/util/get-path-area.d.ts +8 -0
- package/types/antv-util/path/util/get-path-bbox-total-length.d.ts +5 -0
- package/types/antv-util/path/util/get-path-bbox.d.ts +5 -0
- package/types/antv-util/path/util/get-point-at-length.d.ts +5 -0
- package/types/antv-util/path/util/get-properties-at-length.d.ts +6 -0
- package/types/antv-util/path/util/get-properties-at-point.d.ts +7 -0
- package/types/antv-util/path/util/get-rotated-curve.d.ts +2 -0
- package/types/antv-util/path/util/get-total-length.d.ts +8 -0
- package/types/antv-util/path/util/is-absolute-array.d.ts +6 -0
- package/types/antv-util/path/util/is-curve-array.d.ts +9 -0
- package/types/antv-util/path/util/is-normalized-array.d.ts +7 -0
- package/types/antv-util/path/util/is-path-array.d.ts +5 -0
- package/types/antv-util/path/util/is-point-in-stroke.d.ts +5 -0
- package/types/antv-util/path/util/mid-point.d.ts +1 -0
- package/types/antv-util/path/util/path-length-factory.d.ts +7 -0
- package/types/antv-util/path/util/rotate-vector.d.ts +4 -0
- package/types/antv-util/path/util/segment-arc-factory.d.ts +6 -0
- package/types/antv-util/path/util/segment-cubic-factory.d.ts +6 -0
- package/types/antv-util/path/util/segment-line-factory.d.ts +6 -0
- package/types/antv-util/path/util/segment-quad-factory.d.ts +6 -0
- package/types/callbacks.d.ts +30 -0
- package/types/color/colord/src/colorModels/cmyk.d.ts +23 -0
- package/types/color/colord/src/colorModels/cmykString.d.ts +7 -0
- package/types/color/colord/src/colorModels/hex.d.ts +5 -0
- package/types/color/colord/src/colorModels/hsl.d.ts +8 -0
- package/types/color/colord/src/colorModels/hslString.d.ts +7 -0
- package/types/color/colord/src/colorModels/hsv.d.ts +6 -0
- package/types/color/colord/src/colorModels/hwb.d.ts +6 -0
- package/types/color/colord/src/colorModels/hwbString.d.ts +7 -0
- package/types/color/colord/src/colorModels/lab.d.ts +18 -0
- package/types/color/colord/src/colorModels/lch.d.ts +19 -0
- package/types/color/colord/src/colorModels/lchString.d.ts +7 -0
- package/types/color/colord/src/colorModels/rgb.d.ts +13 -0
- package/types/color/colord/src/colorModels/rgbString.d.ts +7 -0
- package/types/color/colord/src/colorModels/xyz.d.ts +30 -0
- package/types/color/colord/src/colord.d.ts +103 -0
- package/types/color/colord/src/constants.d.ts +10 -0
- package/types/color/colord/src/extend.d.ts +4 -0
- package/types/color/colord/src/get/getBrightness.d.ts +7 -0
- package/types/color/colord/src/get/getContrast.d.ts +6 -0
- package/types/color/colord/src/get/getLuminance.d.ts +6 -0
- package/types/color/colord/src/get/getPerceivedDifference.d.ts +24 -0
- package/types/color/colord/src/helpers.d.ts +20 -0
- package/types/color/colord/src/index.d.ts +5 -0
- package/types/color/colord/src/manipulate/changeAlpha.d.ts +2 -0
- package/types/color/colord/src/manipulate/invert.d.ts +2 -0
- package/types/color/colord/src/manipulate/lighten.d.ts +2 -0
- package/types/color/colord/src/manipulate/mix.d.ts +2 -0
- package/types/color/colord/src/manipulate/saturate.d.ts +2 -0
- package/types/color/colord/src/parse.d.ts +8 -0
- package/types/color/colord/src/plugins/a11y.d.ts +38 -0
- package/types/color/colord/src/plugins/cmyk.d.ts +24 -0
- package/types/color/colord/src/plugins/harmonies.d.ts +16 -0
- package/types/color/colord/src/plugins/hwb.d.ts +23 -0
- package/types/color/colord/src/plugins/lab.d.ts +23 -0
- package/types/color/colord/src/plugins/lch.d.ts +24 -0
- package/types/color/colord/src/plugins/minify.d.ts +20 -0
- package/types/color/colord/src/plugins/mix.d.ts +27 -0
- package/types/color/colord/src/plugins/names.d.ts +19 -0
- package/types/color/colord/src/plugins/xyz.d.ts +14 -0
- package/types/color/colord/src/random.d.ts +2 -0
- package/types/color/colord/src/types.d.ts +67 -0
- package/types/data/immer.d.ts +262 -0
- package/types/data/immutable.d.ts +5127 -0
- package/types/data/mobx.d.ts +154 -0
- package/types/data/reactivity.d.ts +755 -0
- package/types/data/signals.d.ts +144 -0
- package/types/deepmerge.d.ts +16 -0
- package/types/events/eventTarget.d.ts +93 -0
- package/types/events/event_emiter.d.ts +43 -0
- package/types/events/eventemitter3.d.ts +135 -0
- package/types/events/mitt.d.ts +21 -0
- package/types/fast-deep-equal.d.ts +1 -0
- package/types/index.d.ts +20 -0
- package/types/ismobilejs.d.ts +46 -0
- package/types/lodash/augment.d.ts +2 -0
- package/types/lodash/cache.d.ts +14 -0
- package/types/lodash/clamp.d.ts +2 -0
- package/types/lodash/clear-animation-frame.d.ts +1 -0
- package/types/lodash/clone.d.ts +2 -0
- package/types/lodash/contains.d.ts +2 -0
- package/types/lodash/debounce.d.ts +2 -0
- package/types/lodash/deep-mix.d.ts +2 -0
- package/types/lodash/difference.d.ts +11 -0
- package/types/lodash/each.d.ts +2 -0
- package/types/lodash/ends-with.d.ts +3 -0
- package/types/lodash/every.d.ts +7 -0
- package/types/lodash/extend.d.ts +2 -0
- package/types/lodash/filter.d.ts +2 -0
- package/types/lodash/find-index.d.ts +2 -0
- package/types/lodash/find.d.ts +3 -0
- package/types/lodash/first-value.d.ts +2 -0
- package/types/lodash/fixed-base.d.ts +2 -0
- package/types/lodash/flatten-deep.d.ts +12 -0
- package/types/lodash/flatten.d.ts +11 -0
- package/types/lodash/for-in.d.ts +2 -0
- package/types/lodash/get-range.d.ts +6 -0
- package/types/lodash/get-type.d.ts +2 -0
- package/types/lodash/get-wrap-behavior.d.ts +9 -0
- package/types/lodash/get.d.ts +8 -0
- package/types/lodash/group-by.d.ts +6 -0
- package/types/lodash/group-to-map.d.ts +8 -0
- package/types/lodash/group.d.ts +2 -0
- package/types/lodash/has-key.d.ts +2 -0
- package/types/lodash/has-value.d.ts +2 -0
- package/types/lodash/has.d.ts +2 -0
- package/types/lodash/head.d.ts +1 -0
- package/types/lodash/identity.d.ts +2 -0
- package/types/lodash/index-of.d.ts +2 -0
- package/types/lodash/index.d.ts +108 -0
- package/types/lodash/is-arguments.d.ts +2 -0
- package/types/lodash/is-array-like.d.ts +2 -0
- package/types/lodash/is-array.d.ts +2 -0
- package/types/lodash/is-boolean.d.ts +2 -0
- package/types/lodash/is-date.d.ts +2 -0
- package/types/lodash/is-decimal.d.ts +2 -0
- package/types/lodash/is-element.d.ts +6 -0
- package/types/lodash/is-empty.d.ts +2 -0
- package/types/lodash/is-equal-with.d.ts +24 -0
- package/types/lodash/is-equal.d.ts +2 -0
- package/types/lodash/is-error.d.ts +2 -0
- package/types/lodash/is-even.d.ts +2 -0
- package/types/lodash/is-finite.d.ts +1 -0
- package/types/lodash/is-function.d.ts +2 -0
- package/types/lodash/is-integer.d.ts +2 -0
- package/types/lodash/is-match.d.ts +2 -0
- package/types/lodash/is-negative.d.ts +2 -0
- package/types/lodash/is-nil.d.ts +2 -0
- package/types/lodash/is-null.d.ts +2 -0
- package/types/lodash/is-number-equal.d.ts +1 -0
- package/types/lodash/is-number.d.ts +2 -0
- package/types/lodash/is-object-like.d.ts +2 -0
- package/types/lodash/is-object.d.ts +2 -0
- package/types/lodash/is-odd.d.ts +2 -0
- package/types/lodash/is-plain-object.d.ts +2 -0
- package/types/lodash/is-positive.d.ts +2 -0
- package/types/lodash/is-prototype.d.ts +2 -0
- package/types/lodash/is-reg-exp.d.ts +2 -0
- package/types/lodash/is-segment-equal.d.ts +2 -0
- package/types/lodash/is-string.d.ts +2 -0
- package/types/lodash/is-type.d.ts +2 -0
- package/types/lodash/is-undefined.d.ts +2 -0
- package/types/lodash/keys.d.ts +2 -0
- package/types/lodash/last.d.ts +1 -0
- package/types/lodash/lower-case.d.ts +2 -0
- package/types/lodash/lower-first.d.ts +2 -0
- package/types/lodash/map-values.d.ts +6 -0
- package/types/lodash/map.d.ts +2 -0
- package/types/lodash/max-by.d.ts +16 -0
- package/types/lodash/max.d.ts +19 -0
- package/types/lodash/memoize.d.ts +11 -0
- package/types/lodash/merge.d.ts +7 -0
- package/types/lodash/min-by.d.ts +16 -0
- package/types/lodash/min.d.ts +19 -0
- package/types/lodash/mix.d.ts +1 -0
- package/types/lodash/mod.d.ts +2 -0
- package/types/lodash/noop.d.ts +2 -0
- package/types/lodash/number2color.d.ts +2 -0
- package/types/lodash/omit.d.ts +3 -0
- package/types/lodash/parse-radius.d.ts +9 -0
- package/types/lodash/pick.d.ts +16 -0
- package/types/lodash/pull-at.d.ts +2 -0
- package/types/lodash/pull.d.ts +2 -0
- package/types/lodash/reduce.d.ts +3 -0
- package/types/lodash/remove.d.ts +2 -0
- package/types/lodash/request-animation-frame.d.ts +1 -0
- package/types/lodash/set.d.ts +8 -0
- package/types/lodash/size.d.ts +1 -0
- package/types/lodash/some.d.ts +7 -0
- package/types/lodash/sort-by.d.ts +7 -0
- package/types/lodash/starts-with.d.ts +3 -0
- package/types/lodash/substitute.d.ts +5 -0
- package/types/lodash/throttle.d.ts +6 -0
- package/types/lodash/to-array.d.ts +2 -0
- package/types/lodash/to-degree.d.ts +2 -0
- package/types/lodash/to-integer.d.ts +1 -0
- package/types/lodash/to-radian.d.ts +2 -0
- package/types/lodash/to-string.d.ts +2 -0
- package/types/lodash/types/index.d.ts +3 -0
- package/types/lodash/union.d.ts +2 -0
- package/types/lodash/uniq.d.ts +1 -0
- package/types/lodash/unique-id.d.ts +2 -0
- package/types/lodash/upper-case.d.ts +2 -0
- package/types/lodash/upper-first.d.ts +2 -0
- package/types/lodash/values-of-key.d.ts +2 -0
- package/types/lodash/values.d.ts +2 -0
- package/types/lodash/wrap-behavior.d.ts +9 -0
- package/types/parse-svg-path.d.ts +19 -0
- package/types/priority_queue.d.ts +41 -0
- package/types/radash/array.d.ts +209 -0
- package/types/radash/async.d.ts +99 -0
- package/types/radash/curry.d.ts +113 -0
- package/types/radash/index.d.ts +10 -0
- package/types/radash/number.d.ts +27 -0
- package/types/radash/object.d.ts +112 -0
- package/types/radash/random.d.ts +11 -0
- package/types/radash/series.d.ts +13 -0
- package/types/radash/string.d.ts +71 -0
- package/types/radash/typed.d.ts +26 -0
- package/types/stats.module.d.ts +3 -0
- package/README.md +0 -1
- package/dist/cjs/index.js +0 -19
- package/dist/umd/index.js +0 -23
- package/esm/extend.js +0 -3
- package/esm/index.js +0 -3
- package/lib/extend.js +0 -6
- package/lib/index.js +0 -6
- package/src/extend.ts +0 -6
- package/src/index.ts +0 -6
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { RgbaColor } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Parses a valid HSL[A] CSS color function/string
|
|
4
|
+
* https://www.w3.org/TR/css-color-4/#the-hsl-notation
|
|
5
|
+
*/
|
|
6
|
+
export declare const parseHslaString: (input: string) => RgbaColor | null;
|
|
7
|
+
export declare const rgbaToHslaString: (rgba: RgbaColor) => string;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { InputObject, RgbaColor, HsvaColor } from '../types';
|
|
2
|
+
export declare const clampHsva: (hsva: HsvaColor) => HsvaColor;
|
|
3
|
+
export declare const roundHsva: (hsva: HsvaColor) => HsvaColor;
|
|
4
|
+
export declare const parseHsva: ({ h, s, v, a }: InputObject) => RgbaColor | null;
|
|
5
|
+
export declare const rgbaToHsva: ({ r, g, b, a }: RgbaColor) => HsvaColor;
|
|
6
|
+
export declare const hsvaToRgba: ({ h, s, v, a }: HsvaColor) => RgbaColor;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { RgbaColor, HwbaColor, InputObject } from '../types';
|
|
2
|
+
export declare const clampHwba: (hwba: HwbaColor) => HwbaColor;
|
|
3
|
+
export declare const roundHwba: (hwba: HwbaColor) => HwbaColor;
|
|
4
|
+
export declare const rgbaToHwba: (rgba: RgbaColor) => HwbaColor;
|
|
5
|
+
export declare const hwbaToRgba: (hwba: HwbaColor) => RgbaColor;
|
|
6
|
+
export declare const parseHwba: ({ h, w, b, a }: InputObject) => RgbaColor | null;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { RgbaColor } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Parses a valid HWB[A] CSS color function/string
|
|
4
|
+
* https://www.w3.org/TR/css-color-4/#the-hwb-notation
|
|
5
|
+
*/
|
|
6
|
+
export declare const parseHwbaString: (input: string) => RgbaColor | null;
|
|
7
|
+
export declare const rgbaToHwbaString: (rgba: RgbaColor) => string;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { RgbaColor, LabaColor, InputObject } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Clamps LAB axis values as defined in CSS Color Level 4 specs.
|
|
4
|
+
* https://www.w3.org/TR/css-color-4/#specifying-lab-lch
|
|
5
|
+
*/
|
|
6
|
+
export declare const clampLaba: (laba: LabaColor) => LabaColor;
|
|
7
|
+
export declare const roundLaba: (laba: LabaColor) => LabaColor;
|
|
8
|
+
export declare const parseLaba: ({ l, a, b, alpha }: InputObject) => RgbaColor | null;
|
|
9
|
+
/**
|
|
10
|
+
* Performs RGB → CIEXYZ → LAB color conversion
|
|
11
|
+
* https://www.w3.org/TR/css-color-4/#color-conversion-code
|
|
12
|
+
*/
|
|
13
|
+
export declare const rgbaToLaba: (rgba: RgbaColor) => LabaColor;
|
|
14
|
+
/**
|
|
15
|
+
* Performs LAB → CIEXYZ → RGB color conversion
|
|
16
|
+
* https://www.w3.org/TR/css-color-4/#color-conversion-code
|
|
17
|
+
*/
|
|
18
|
+
export declare const labaToRgba: (laba: LabaColor) => RgbaColor;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { RgbaColor, InputObject, LchaColor } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Limits LCH axis values.
|
|
4
|
+
* https://www.w3.org/TR/css-color-4/#specifying-lab-lch
|
|
5
|
+
* https://lea.verou.me/2020/04/lch-colors-in-css-what-why-and-how/#how-does-lch-work
|
|
6
|
+
*/
|
|
7
|
+
export declare const clampLcha: (laba: LchaColor) => LchaColor;
|
|
8
|
+
export declare const roundLcha: (laba: LchaColor) => LchaColor;
|
|
9
|
+
export declare const parseLcha: ({ l, c, h, a }: InputObject) => RgbaColor | null;
|
|
10
|
+
/**
|
|
11
|
+
* Performs RGB → CIEXYZ → CIELAB → CIELCH color conversion
|
|
12
|
+
* https://www.w3.org/TR/css-color-4/#color-conversion-code
|
|
13
|
+
*/
|
|
14
|
+
export declare const rgbaToLcha: (rgba: RgbaColor) => LchaColor;
|
|
15
|
+
/**
|
|
16
|
+
* Performs CIELCH → CIELAB → CIEXYZ → RGB color conversion
|
|
17
|
+
* https://www.w3.org/TR/css-color-4/#color-conversion-code
|
|
18
|
+
*/
|
|
19
|
+
export declare const lchaToRgba: (lcha: LchaColor) => RgbaColor;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { RgbaColor } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Parses a valid LCH CSS color function/string
|
|
4
|
+
* https://www.w3.org/TR/css-color-4/#specifying-lab-lch
|
|
5
|
+
*/
|
|
6
|
+
export declare const parseLchaString: (input: string) => RgbaColor | null;
|
|
7
|
+
export declare const rgbaToLchaString: (rgba: RgbaColor) => string;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { InputObject, RgbaColor } from '../types';
|
|
2
|
+
export declare const clampRgba: (rgba: RgbaColor) => RgbaColor;
|
|
3
|
+
export declare const roundRgba: (rgba: RgbaColor) => RgbaColor;
|
|
4
|
+
export declare const parseRgba: ({ r, g, b, a }: InputObject) => RgbaColor | null;
|
|
5
|
+
/**
|
|
6
|
+
* Converts an RGB channel [0-255] to its linear light (un-companded) form [0-1].
|
|
7
|
+
* Linearized RGB values are widely used for color space conversions and contrast calculations
|
|
8
|
+
*/
|
|
9
|
+
export declare const linearizeRgbChannel: (value: number) => number;
|
|
10
|
+
/**
|
|
11
|
+
* Converts an linear-light sRGB channel [0-1] back to its gamma corrected form [0-255]
|
|
12
|
+
*/
|
|
13
|
+
export declare const unlinearizeRgbChannel: (ratio: number) => number;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { RgbaColor } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Parses a valid RGB[A] CSS color function/string
|
|
4
|
+
* https://www.w3.org/TR/css-color-4/#rgb-functions
|
|
5
|
+
*/
|
|
6
|
+
export declare const parseRgbaString: (input: string) => RgbaColor | null;
|
|
7
|
+
export declare const rgbaToRgbaString: (rgba: RgbaColor) => string;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { InputObject, RgbaColor, XyzColor, XyzaColor } from '../types';
|
|
2
|
+
export declare const D50: {
|
|
3
|
+
x: number;
|
|
4
|
+
y: number;
|
|
5
|
+
z: number;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Limits XYZ axis values assuming XYZ is relative to D50.
|
|
9
|
+
*/
|
|
10
|
+
export declare const clampXyza: (xyza: XyzaColor) => XyzaColor;
|
|
11
|
+
export declare const roundXyza: (xyza: XyzaColor) => XyzaColor;
|
|
12
|
+
export declare const parseXyza: ({ x, y, z, a }: InputObject) => RgbaColor | null;
|
|
13
|
+
/**
|
|
14
|
+
* Performs Bradford chromatic adaptation from D65 to D50
|
|
15
|
+
*/
|
|
16
|
+
export declare const adaptXyzaToD50: (xyza: XyzaColor) => XyzaColor;
|
|
17
|
+
/**
|
|
18
|
+
* Performs Bradford chromatic adaptation from D50 to D65
|
|
19
|
+
*/
|
|
20
|
+
export declare const adaptXyzToD65: (xyza: XyzColor) => XyzColor;
|
|
21
|
+
/**
|
|
22
|
+
* Converts an CIE XYZ color (D50) to RGBA color space (D65)
|
|
23
|
+
* https://www.w3.org/TR/css-color-4/#color-conversion-code
|
|
24
|
+
*/
|
|
25
|
+
export declare const xyzaToRgba: (sourceXyza: XyzaColor) => RgbaColor;
|
|
26
|
+
/**
|
|
27
|
+
* Converts an RGB color (D65) to CIE XYZ (D50)
|
|
28
|
+
* https://image-engineering.de/library/technotes/958-how-to-convert-between-srgb-and-ciexyz
|
|
29
|
+
*/
|
|
30
|
+
export declare const rgbaToXyza: (rgba: RgbaColor) => XyzaColor;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { AnyColor, RgbaColor, HslaColor, HsvaColor } from './types';
|
|
2
|
+
export declare class Colord {
|
|
3
|
+
private readonly parsed;
|
|
4
|
+
readonly rgba: RgbaColor;
|
|
5
|
+
constructor(input: AnyColor);
|
|
6
|
+
/**
|
|
7
|
+
* Returns a boolean indicating whether or not an input has been parsed successfully.
|
|
8
|
+
* Note: If parsing is unsuccessful, Colord defaults to black (does not throws an error).
|
|
9
|
+
*/
|
|
10
|
+
isValid(): boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Returns the brightness of a color (from 0 to 1).
|
|
13
|
+
* The calculation logic is modified from WCAG.
|
|
14
|
+
* https://www.w3.org/TR/AERT/#color-contrast
|
|
15
|
+
*/
|
|
16
|
+
brightness(): number;
|
|
17
|
+
/**
|
|
18
|
+
* Same as calling `brightness() < 0.5`.
|
|
19
|
+
*/
|
|
20
|
+
isDark(): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Same as calling `brightness() >= 0.5`.
|
|
23
|
+
* */
|
|
24
|
+
isLight(): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Returns the hexadecimal representation of a color.
|
|
27
|
+
* When the alpha channel value of the color is less than 1,
|
|
28
|
+
* it outputs #rrggbbaa format instead of #rrggbb.
|
|
29
|
+
*/
|
|
30
|
+
toHex(): string;
|
|
31
|
+
/**
|
|
32
|
+
* Converts a color to RGB color space and returns an object.
|
|
33
|
+
* Always includes an alpha value from 0 to 1.
|
|
34
|
+
*/
|
|
35
|
+
toRgb(): RgbaColor;
|
|
36
|
+
/**
|
|
37
|
+
* Converts a color to RGB color space and returns a string representation.
|
|
38
|
+
* Outputs an alpha value only if it is less than 1.
|
|
39
|
+
*/
|
|
40
|
+
toRgbString(): string;
|
|
41
|
+
/**
|
|
42
|
+
* Converts a color to HSL color space and returns an object.
|
|
43
|
+
* Always includes an alpha value from 0 to 1.
|
|
44
|
+
*/
|
|
45
|
+
toHsl(): HslaColor;
|
|
46
|
+
/**
|
|
47
|
+
* Converts a color to HSL color space and returns a string representation.
|
|
48
|
+
* Always includes an alpha value from 0 to 1.
|
|
49
|
+
*/
|
|
50
|
+
toHslString(): string;
|
|
51
|
+
/**
|
|
52
|
+
* Converts a color to HSV color space and returns an object.
|
|
53
|
+
* Always includes an alpha value from 0 to 1.
|
|
54
|
+
*/
|
|
55
|
+
toHsv(): HsvaColor;
|
|
56
|
+
/**
|
|
57
|
+
* Creates a new instance containing an inverted (opposite) version of the color.
|
|
58
|
+
*/
|
|
59
|
+
invert(): Colord;
|
|
60
|
+
/**
|
|
61
|
+
* Increases the HSL saturation of a color by the given amount.
|
|
62
|
+
*/
|
|
63
|
+
saturate(amount?: number): Colord;
|
|
64
|
+
/**
|
|
65
|
+
* Decreases the HSL saturation of a color by the given amount.
|
|
66
|
+
*/
|
|
67
|
+
desaturate(amount?: number): Colord;
|
|
68
|
+
/**
|
|
69
|
+
* Makes a gray color with the same lightness as a source color.
|
|
70
|
+
*/
|
|
71
|
+
grayscale(): Colord;
|
|
72
|
+
/**
|
|
73
|
+
* Increases the HSL lightness of a color by the given amount.
|
|
74
|
+
*/
|
|
75
|
+
lighten(amount?: number): Colord;
|
|
76
|
+
/**
|
|
77
|
+
* Increases the HSL lightness of a color by the given amount.
|
|
78
|
+
*/
|
|
79
|
+
darken(amount?: number): Colord;
|
|
80
|
+
/**
|
|
81
|
+
* Changes the HSL hue of a color by the given amount.
|
|
82
|
+
*/
|
|
83
|
+
rotate(amount?: number): Colord;
|
|
84
|
+
/**
|
|
85
|
+
* Allows to get or change an alpha channel value.
|
|
86
|
+
*/
|
|
87
|
+
alpha(): number;
|
|
88
|
+
alpha(value: number): Colord;
|
|
89
|
+
/**
|
|
90
|
+
* Allows to get or change a hue value.
|
|
91
|
+
*/
|
|
92
|
+
hue(): number;
|
|
93
|
+
hue(value: number): Colord;
|
|
94
|
+
/**
|
|
95
|
+
* Determines whether two values are the same color.
|
|
96
|
+
*/
|
|
97
|
+
isEqual(color: AnyColor | Colord): boolean;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Parses the given input color and creates a new `Colord` instance.
|
|
101
|
+
* See accepted input formats: https://github.com/omgovich/colord#color-parsing
|
|
102
|
+
*/
|
|
103
|
+
export declare const colord: (input: AnyColor | Colord) => Colord;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* We used to work with 2 digits after the decimal point, but it wasn't accurate enough,
|
|
3
|
+
* so the library produced colors that were perceived differently.
|
|
4
|
+
*/
|
|
5
|
+
export declare const ALPHA_PRECISION = 3;
|
|
6
|
+
/**
|
|
7
|
+
* Valid CSS <angle> units.
|
|
8
|
+
* https://developer.mozilla.org/en-US/docs/Web/CSS/angle
|
|
9
|
+
*/
|
|
10
|
+
export declare const ANGLE_UNITS: Record<string, number>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { LabaColor } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Calculates the perceived color difference according to [Delta E2000](https://en.wikipedia.org/wiki/Color_difference#CIEDE2000).
|
|
4
|
+
*
|
|
5
|
+
* ΔE - (Delta E, dE) The measure of change in visual perception of two given colors.
|
|
6
|
+
*
|
|
7
|
+
* Delta E is a metric for understanding how the human eye perceives color difference.
|
|
8
|
+
* The term delta comes from mathematics, meaning change in a variable or function.
|
|
9
|
+
* The suffix E references the German word Empfindung, which broadly means sensation.
|
|
10
|
+
*
|
|
11
|
+
* On a typical scale, the Delta E value will range from 0 to 100.
|
|
12
|
+
*
|
|
13
|
+
* | Delta E | Perception |
|
|
14
|
+
* |---------|----------------------------------------|
|
|
15
|
+
* | <= 1.0 | Not perceptible by human eyes |
|
|
16
|
+
* | 1 - 2 | Perceptible through close observation |
|
|
17
|
+
* | 2 - 10 | Perceptible at a glance |
|
|
18
|
+
* | 11 - 49 | Colors are more similar than opposite |
|
|
19
|
+
* | 100 | Colors are exact opposite |
|
|
20
|
+
*
|
|
21
|
+
* [Source](http://www.brucelindbloom.com/index.html?Eqn_DeltaE_CIE2000.html)
|
|
22
|
+
* [Read about Delta E](https://zschuessler.github.io/DeltaE/learn/#toc-delta-e-2000)
|
|
23
|
+
*/
|
|
24
|
+
export declare function getDeltaE00(color1: LabaColor, color2: LabaColor): number;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export declare const isPresent: (value: unknown) => boolean;
|
|
2
|
+
export declare const round: (number: number, digits?: number, base?: number) => number;
|
|
3
|
+
export declare const floor: (number: number, digits?: number, base?: number) => number;
|
|
4
|
+
/**
|
|
5
|
+
* Clamps a value between an upper and lower bound.
|
|
6
|
+
* We use ternary operators because it makes the minified code
|
|
7
|
+
* is 2 times shorter then `Math.min(Math.max(a,b),c)`
|
|
8
|
+
* NaN is clamped to the lower bound
|
|
9
|
+
*/
|
|
10
|
+
export declare const clamp: (number: number, min?: number, max?: number) => number;
|
|
11
|
+
/**
|
|
12
|
+
* Processes and clamps a degree (angle) value properly.
|
|
13
|
+
* Any `NaN` or `Infinity` will be converted to `0`.
|
|
14
|
+
* Examples: -1 => 359, 361 => 1
|
|
15
|
+
*/
|
|
16
|
+
export declare const clampHue: (degrees: number) => number;
|
|
17
|
+
/**
|
|
18
|
+
* Converts a hue value to degrees from 0 to 360 inclusive.
|
|
19
|
+
*/
|
|
20
|
+
export declare const parseHue: (value: string, unit?: string) => number;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { colord, Colord } from './colord';
|
|
2
|
+
export { extend, Plugin } from './extend';
|
|
3
|
+
export { getFormat } from './parse';
|
|
4
|
+
export { random } from './random';
|
|
5
|
+
export { HslColor, HslaColor, HsvColor, HsvaColor, HwbColor, HwbaColor, LabColor, LabaColor, LchColor, LchaColor, RgbColor, RgbaColor, XyzColor, XyzaColor, AnyColor, } from './types';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Parsers, ParseResult, Input, Format } from './types';
|
|
2
|
+
export declare const parsers: Parsers;
|
|
3
|
+
/** Tries to convert an incoming value into RGBA color by going through all color model parsers */
|
|
4
|
+
export declare const parse: (input: Input) => ParseResult | [null, undefined];
|
|
5
|
+
/**
|
|
6
|
+
* Returns a color model name for the input passed to the function.
|
|
7
|
+
*/
|
|
8
|
+
export declare const getFormat: (input: Input) => Format | undefined;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { AnyColor } from '../types';
|
|
2
|
+
import { Plugin } from '../extend';
|
|
3
|
+
interface ReadabilityOptions {
|
|
4
|
+
level?: "AA" | "AAA";
|
|
5
|
+
size?: "normal" | "large";
|
|
6
|
+
}
|
|
7
|
+
declare module "../colord" {
|
|
8
|
+
interface Colord {
|
|
9
|
+
/**
|
|
10
|
+
* Returns the relative luminance of a color,
|
|
11
|
+
* normalized to 0 for darkest black and 1 for lightest white.
|
|
12
|
+
* https://www.w3.org/TR/WCAG20/#relativeluminancedef
|
|
13
|
+
* https://developer.mozilla.org/en-US/docs/Web/Accessibility/Understanding_Colors_and_Luminance
|
|
14
|
+
*/
|
|
15
|
+
luminance(): number;
|
|
16
|
+
/**
|
|
17
|
+
* Calculates a contrast ratio for a color pair.
|
|
18
|
+
* This luminance difference is expressed as a ratio ranging
|
|
19
|
+
* from 1 (e.g. white on white) to 21 (e.g., black on a white).
|
|
20
|
+
* WCAG requires a ratio of at least 4.5 for normal text and 3 for large text.
|
|
21
|
+
* https://www.w3.org/TR/UNDERSTANDING-WCAG20/visual-audio-contrast-contrast.html
|
|
22
|
+
* https://webaim.org/articles/contrast/
|
|
23
|
+
*/
|
|
24
|
+
contrast(color2?: AnyColor | Colord): number;
|
|
25
|
+
/**
|
|
26
|
+
* Checks that a background and text color pair conforms to WCAG 2.0 requirements.
|
|
27
|
+
* https://www.w3.org/TR/UNDERSTANDING-WCAG20/visual-audio-contrast-contrast.html
|
|
28
|
+
*/
|
|
29
|
+
isReadable(color2?: AnyColor | Colord, options?: ReadabilityOptions): boolean;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* A plugin adding accessibility and color contrast utilities.
|
|
34
|
+
* Follows Web Content Accessibility Guidelines 2.0.
|
|
35
|
+
* https://www.w3.org/TR/WCAG20/
|
|
36
|
+
*/
|
|
37
|
+
declare const a11yPlugin: Plugin;
|
|
38
|
+
export default a11yPlugin;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { CmykaColor } from '../types';
|
|
2
|
+
import { Plugin } from '../extend';
|
|
3
|
+
declare module "../colord" {
|
|
4
|
+
interface Colord {
|
|
5
|
+
/**
|
|
6
|
+
* Converts a color to CMYK color space and returns an object.
|
|
7
|
+
* https://drafts.csswg.org/css-color/#cmyk-colors
|
|
8
|
+
* https://lea.verou.me/2009/03/cmyk-colors-in-css-useful-or-useless/
|
|
9
|
+
*/
|
|
10
|
+
toCmyk(): CmykaColor;
|
|
11
|
+
/**
|
|
12
|
+
* Converts a color to CMYK color space and returns a string.
|
|
13
|
+
* https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/device-cmyk()
|
|
14
|
+
*/
|
|
15
|
+
toCmykString(): string;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* A plugin adding support for CMYK color space.
|
|
20
|
+
* https://lea.verou.me/2009/03/cmyk-colors-in-css-useful-or-useless/
|
|
21
|
+
* https://en.wikipedia.org/wiki/CMYK_color_model
|
|
22
|
+
*/
|
|
23
|
+
declare const cmykPlugin: Plugin;
|
|
24
|
+
export default cmykPlugin;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Plugin } from '../extend';
|
|
2
|
+
export type HarmonyType = "analogous" | "complementary" | "double-split-complementary" | "rectangle" | "split-complementary" | "tetradic" | "triadic";
|
|
3
|
+
declare module "../colord" {
|
|
4
|
+
interface Colord {
|
|
5
|
+
/**
|
|
6
|
+
* Returns an array of harmony colors as `Colord` instances.
|
|
7
|
+
*/
|
|
8
|
+
harmonies(type?: HarmonyType): Colord[];
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* A plugin adding functionality to generate harmony colors.
|
|
13
|
+
* https://en.wikipedia.org/wiki/Harmony_(color)
|
|
14
|
+
*/
|
|
15
|
+
declare const harmoniesPlugin: Plugin;
|
|
16
|
+
export default harmoniesPlugin;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { HwbaColor } from '../types';
|
|
2
|
+
import { Plugin } from '../extend';
|
|
3
|
+
declare module "../colord" {
|
|
4
|
+
interface Colord {
|
|
5
|
+
/**
|
|
6
|
+
* Converts a color to HWB (Hue-Whiteness-Blackness) color space and returns an object.
|
|
7
|
+
* https://en.wikipedia.org/wiki/HWB_color_model
|
|
8
|
+
*/
|
|
9
|
+
toHwb(): HwbaColor;
|
|
10
|
+
/**
|
|
11
|
+
* Converts a color to HWB (Hue-Whiteness-Blackness) color space and returns a string.
|
|
12
|
+
* https://www.w3.org/TR/css-color-4/#the-hwb-notation
|
|
13
|
+
*/
|
|
14
|
+
toHwbString(): string;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* A plugin adding support for HWB (Hue-Whiteness-Blackness) color model.
|
|
19
|
+
* https://en.wikipedia.org/wiki/HWB_color_model
|
|
20
|
+
* https://www.w3.org/TR/css-color-4/#the-hwb-notation
|
|
21
|
+
*/
|
|
22
|
+
declare const hwbPlugin: Plugin;
|
|
23
|
+
export default hwbPlugin;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { LabaColor, AnyColor } from '../types';
|
|
2
|
+
import { Plugin } from '../extend';
|
|
3
|
+
declare module "../colord" {
|
|
4
|
+
interface Colord {
|
|
5
|
+
/**
|
|
6
|
+
* Converts a color to CIELAB color space and returns an object.
|
|
7
|
+
* The object always includes `alpha` value [0, 1].
|
|
8
|
+
*/
|
|
9
|
+
toLab(): LabaColor;
|
|
10
|
+
/**
|
|
11
|
+
* Calculates the perceived color difference for two colors according to
|
|
12
|
+
* [Delta E2000](https://en.wikipedia.org/wiki/Color_difference#CIEDE2000).
|
|
13
|
+
* Returns a value in [0, 1] range.
|
|
14
|
+
*/
|
|
15
|
+
delta(color?: AnyColor | Colord): number;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* A plugin adding support for CIELAB color space.
|
|
20
|
+
* https://en.wikipedia.org/wiki/CIELAB_color_space
|
|
21
|
+
*/
|
|
22
|
+
declare const labPlugin: Plugin;
|
|
23
|
+
export default labPlugin;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { LchaColor } from '../types';
|
|
2
|
+
import { Plugin } from '../extend';
|
|
3
|
+
declare module "../colord" {
|
|
4
|
+
interface Colord {
|
|
5
|
+
/**
|
|
6
|
+
* Converts a color to CIELCH (Lightness-Chroma-Hue) color space and returns an object.
|
|
7
|
+
* https://lea.verou.me/2020/04/lch-colors-in-css-what-why-and-how/
|
|
8
|
+
* https://en.wikipedia.org/wiki/CIELAB_color_space#Cylindrical_model
|
|
9
|
+
*/
|
|
10
|
+
toLch(): LchaColor;
|
|
11
|
+
/**
|
|
12
|
+
* Converts a color to CIELCH (Lightness-Chroma-Hue) color space and returns a string.
|
|
13
|
+
* https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/lch()
|
|
14
|
+
*/
|
|
15
|
+
toLchString(): string;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* A plugin adding support for CIELCH color space.
|
|
20
|
+
* https://lea.verou.me/2020/04/lch-colors-in-css-what-why-and-how/
|
|
21
|
+
* https://en.wikipedia.org/wiki/CIELAB_color_space#Cylindrical_model
|
|
22
|
+
*/
|
|
23
|
+
declare const lchPlugin: Plugin;
|
|
24
|
+
export default lchPlugin;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Plugin } from '../extend';
|
|
2
|
+
interface MinificationOptions {
|
|
3
|
+
hex?: boolean;
|
|
4
|
+
alphaHex?: boolean;
|
|
5
|
+
rgb?: boolean;
|
|
6
|
+
hsl?: boolean;
|
|
7
|
+
name?: boolean;
|
|
8
|
+
transparent?: boolean;
|
|
9
|
+
}
|
|
10
|
+
declare module "../colord" {
|
|
11
|
+
interface Colord {
|
|
12
|
+
/** Returns the shortest string representation of the color */
|
|
13
|
+
minify(options?: MinificationOptions): string;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* A plugin adding a color minification utilities.
|
|
18
|
+
*/
|
|
19
|
+
declare const minifyPlugin: Plugin;
|
|
20
|
+
export default minifyPlugin;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { AnyColor } from '../types';
|
|
2
|
+
import { Plugin } from '../extend';
|
|
3
|
+
declare module "../colord" {
|
|
4
|
+
interface Colord {
|
|
5
|
+
/**
|
|
6
|
+
* Produces a mixture of two colors through CIE LAB color space and returns a new Colord instance.
|
|
7
|
+
*/
|
|
8
|
+
mix(color2: AnyColor | Colord, ratio?: number): Colord;
|
|
9
|
+
/**
|
|
10
|
+
* Generates a tints palette based on original color.
|
|
11
|
+
*/
|
|
12
|
+
tints(count?: number): Colord[];
|
|
13
|
+
/**
|
|
14
|
+
* Generates a shades palette based on original color.
|
|
15
|
+
*/
|
|
16
|
+
shades(count?: number): Colord[];
|
|
17
|
+
/**
|
|
18
|
+
* Generates a tones palette based on original color.
|
|
19
|
+
*/
|
|
20
|
+
tones(count?: number): Colord[];
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* A plugin adding a color mixing utilities.
|
|
25
|
+
*/
|
|
26
|
+
declare const mixPlugin: Plugin;
|
|
27
|
+
export default mixPlugin;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Plugin } from '../extend';
|
|
2
|
+
interface ConvertOptions {
|
|
3
|
+
closest?: boolean;
|
|
4
|
+
}
|
|
5
|
+
declare module "../colord" {
|
|
6
|
+
interface Colord {
|
|
7
|
+
/** Finds CSS color keyword that matches with the color value */
|
|
8
|
+
toName(options?: ConvertOptions): string | undefined;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Plugin to work with named colors.
|
|
13
|
+
* Adds a parser to read CSS color names and `toName` method.
|
|
14
|
+
* See https://www.w3.org/TR/css-color-4/#named-colors
|
|
15
|
+
* Supports 'transparent' string as defined in
|
|
16
|
+
* https://drafts.csswg.org/css-color/#transparent-color
|
|
17
|
+
*/
|
|
18
|
+
declare const namesPlugin: Plugin;
|
|
19
|
+
export default namesPlugin;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { XyzaColor } from '../types';
|
|
2
|
+
import { Plugin } from '../extend';
|
|
3
|
+
declare module "../colord" {
|
|
4
|
+
interface Colord {
|
|
5
|
+
toXyz(): XyzaColor;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* A plugin adding support for CIE XYZ colorspace.
|
|
10
|
+
* Wikipedia: https://en.wikipedia.org/wiki/CIE_1931_color_space
|
|
11
|
+
* Helpful article: https://www.sttmedia.com/colormodel-xyz
|
|
12
|
+
*/
|
|
13
|
+
declare const xyzPlugin: Plugin;
|
|
14
|
+
export default xyzPlugin;
|