@thi.ng/color 3.2.6 → 4.0.3
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/CHANGELOG.md +162 -230
- package/README.md +31 -15
- package/{ops/alpha.d.ts → alpha.d.ts} +1 -1
- package/{ops/alpha.js → alpha.js} +1 -1
- package/{ops/analog.d.ts → analog.d.ts} +3 -3
- package/{ops/analog.js → analog.js} +10 -10
- package/api/constants.js +18 -73
- package/api/gradients.d.ts +1 -1
- package/api/ranges.d.ts +2 -2
- package/api.d.ts +7 -2
- package/{ops/clamp.d.ts → clamp.d.ts} +1 -1
- package/{ops/clamp.js → clamp.js} +6 -5
- package/{ops/closest-hue.d.ts → closest-hue.d.ts} +1 -1
- package/{ops/closest-hue.js → closest-hue.js} +1 -1
- package/{ops/color-range.d.ts → color-range.d.ts} +2 -2
- package/{ops/color-range.js → color-range.js} +25 -18
- package/color.d.ts +1 -1
- package/color.js +16 -16
- package/convert.d.ts +1 -1
- package/convert.js +4 -4
- package/{ops/cosine-gradients.d.ts → cosine-gradients.d.ts} +2 -2
- package/{ops/cosine-gradients.js → cosine-gradients.js} +13 -5
- package/css/css.d.ts +1 -1
- package/css/css.js +12 -11
- package/css/parse-css.d.ts +1 -1
- package/css/parse-css.js +12 -9
- package/defcolor.d.ts +1 -1
- package/defcolor.js +24 -11
- package/{ops/distance.d.ts → distance.d.ts} +2 -2
- package/{ops/distance.js → distance.js} +7 -5
- package/{ops/gradients.d.ts → gradients.d.ts} +2 -2
- package/{ops/gradients.js → gradients.js} +3 -3
- package/hcy/hcy-rgb.d.ts +1 -1
- package/hcy/hcy-rgb.js +6 -6
- package/hcy/hcy.d.ts +1 -1
- package/hcy/hcy.js +4 -2
- package/hsi/hsi-rgb.d.ts +1 -1
- package/hsi/hsi-rgb.js +2 -2
- package/hsi/hsi.d.ts +1 -1
- package/hsi/hsi.js +4 -2
- package/hsl/hsl-css.d.ts +1 -1
- package/hsl/hsl-css.js +5 -4
- package/hsl/hsl-hsv.d.ts +1 -1
- package/hsl/hsl-hsv.js +1 -1
- package/hsl/hsl-rgb.d.ts +1 -1
- package/hsl/hsl-rgb.js +5 -5
- package/hsl/hsl.d.ts +1 -1
- package/hsl/hsl.js +5 -3
- package/hsv/hsv-css.d.ts +1 -1
- package/hsv/hsv-css.js +2 -2
- package/hsv/hsv-hsl.d.ts +1 -1
- package/hsv/hsv-hsl.js +1 -1
- package/hsv/hsv-rgb.d.ts +1 -1
- package/hsv/hsv-rgb.js +3 -3
- package/hsv/hsv.d.ts +1 -1
- package/hsv/hsv.js +5 -3
- package/index.d.ts +87 -87
- package/index.js +87 -87
- package/int/int-css.js +2 -2
- package/int/int-int.js +1 -1
- package/int/int-rgb.d.ts +1 -1
- package/int/int-rgb.js +2 -2
- package/int/int-srgb.d.ts +1 -1
- package/int/int-srgb.js +2 -2
- package/int/int.d.ts +24 -11
- package/int/int.js +59 -19
- package/internal/ensure.d.ts +5 -0
- package/internal/{ensure-args.js → ensure.js} +4 -1
- package/internal/matrix-ops.d.ts +8 -5
- package/internal/matrix-ops.js +12 -8
- package/internal/scale.d.ts +3 -0
- package/internal/scale.js +2 -0
- package/{ops/invert.d.ts → invert.d.ts} +1 -1
- package/{ops/invert.js → invert.js} +3 -2
- package/is-black.d.ts +3 -0
- package/{ops/is-black.js → is-black.js} +5 -6
- package/is-gray.d.ts +3 -0
- package/{ops/is-gray.js → is-gray.js} +6 -7
- package/is-white.d.ts +3 -0
- package/{ops/is-white.js → is-white.js} +5 -6
- package/lab/lab-css.d.ts +1 -1
- package/lab/lab-css.js +4 -4
- package/lab/lab-lab.d.ts +1 -1
- package/lab/lab-lab.js +3 -3
- package/lab/lab-lch.d.ts +1 -1
- package/lab/lab-lch.js +6 -5
- package/lab/lab-rgb.d.ts +1 -1
- package/lab/lab-rgb.js +2 -2
- package/lab/lab-xyz.d.ts +1 -1
- package/lab/lab-xyz.js +4 -4
- package/lab/lab50.d.ts +1 -1
- package/lab/lab50.js +8 -6
- package/lab/lab65.d.ts +1 -1
- package/lab/lab65.js +8 -6
- package/lch/lch-css.d.ts +1 -1
- package/lch/lch-css.js +5 -4
- package/lch/lch.d.ts +1 -1
- package/lch/lch.js +8 -6
- package/{ops/linear.d.ts → linear.d.ts} +0 -0
- package/{ops/linear.js → linear.js} +0 -0
- package/{ops/luminance-rgb.d.ts → luminance-rgb.d.ts} +1 -1
- package/{ops/luminance-rgb.js → luminance-rgb.js} +2 -2
- package/{ops/luminance.d.ts → luminance.d.ts} +2 -3
- package/{ops/luminance.js → luminance.js} +5 -10
- package/{ops/mix.d.ts → mix.d.ts} +2 -2
- package/{ops/mix.js → mix.js} +7 -6
- package/oklab/oklab-rgb.d.ts +1 -1
- package/oklab/oklab-rgb.js +4 -11
- package/oklab/oklab-xyz.d.ts +1 -1
- package/oklab/oklab-xyz.js +9 -21
- package/oklab/oklab.d.ts +1 -1
- package/oklab/oklab.js +8 -6
- package/package.json +323 -52
- package/rgb/hue-rgb.d.ts +1 -1
- package/rgb/hue-rgb.js +3 -2
- package/rgb/kelvin-rgba.d.ts +1 -1
- package/rgb/kelvin-rgba.js +3 -3
- package/rgb/rgb-css.d.ts +1 -1
- package/rgb/rgb-css.js +2 -2
- package/rgb/rgb-hcv.d.ts +1 -1
- package/rgb/rgb-hcv.js +4 -3
- package/rgb/rgb-hcy.d.ts +1 -1
- package/rgb/rgb-hcy.js +4 -4
- package/rgb/rgb-hsi.d.ts +1 -1
- package/rgb/rgb-hsi.js +4 -3
- package/rgb/rgb-hsl.d.ts +1 -1
- package/rgb/rgb-hsl.js +2 -2
- package/rgb/rgb-hsv.d.ts +1 -1
- package/rgb/rgb-hsv.js +2 -2
- package/rgb/rgb-lab.d.ts +1 -1
- package/rgb/rgb-lab.js +2 -2
- package/rgb/rgb-oklab.d.ts +1 -1
- package/rgb/rgb-oklab.js +6 -13
- package/rgb/rgb-srgb.d.ts +1 -1
- package/rgb/rgb-srgb.js +5 -5
- package/rgb/rgb-xyz.d.ts +1 -1
- package/rgb/rgb-xyz.js +4 -4
- package/rgb/rgb-ycc.d.ts +1 -1
- package/rgb/rgb-ycc.js +5 -4
- package/rgb/rgb.d.ts +1 -1
- package/rgb/rgb.js +15 -14
- package/{ops/sort.d.ts → sort.d.ts} +16 -5
- package/{ops/sort.js → sort.js} +21 -7
- package/srgb/srgb-css.d.ts +1 -1
- package/srgb/srgb-css.js +8 -8
- package/srgb/srgb-int.d.ts +1 -1
- package/srgb/srgb-int.js +4 -4
- package/srgb/srgb-rgb.d.ts +1 -1
- package/srgb/srgb-rgb.js +5 -5
- package/srgb/srgb.d.ts +1 -1
- package/srgb/srgb.js +9 -7
- package/{ops/swatches.d.ts → swatches.d.ts} +1 -1
- package/{ops/swatches.js → swatches.js} +0 -0
- package/{ops/transform.d.ts → transform.d.ts} +1 -1
- package/{ops/transform.js → transform.js} +5 -5
- package/xyy/xyy-xyz.d.ts +1 -1
- package/xyy/xyy-xyz.js +4 -4
- package/xyy/xyy.d.ts +1 -1
- package/xyy/xyy.js +6 -3
- package/xyz/wavelength-xyz.d.ts +1 -1
- package/xyz/wavelength-xyz.js +2 -2
- package/xyz/xyz-lab.d.ts +1 -1
- package/xyz/xyz-lab.js +5 -4
- package/xyz/xyz-oklab.d.ts +1 -1
- package/xyz/xyz-oklab.js +4 -4
- package/xyz/xyz-rgb.d.ts +1 -1
- package/xyz/xyz-rgb.js +3 -3
- package/xyz/xyz-xyy.d.ts +1 -1
- package/xyz/xyz-xyy.js +4 -4
- package/xyz/xyz-xyz.d.ts +1 -1
- package/xyz/xyz-xyz.js +4 -4
- package/xyz/xyz50.d.ts +1 -1
- package/xyz/xyz50.js +10 -8
- package/xyz/xyz65.d.ts +1 -1
- package/xyz/xyz65.js +10 -8
- package/ycc/ycc-rgb.d.ts +1 -1
- package/ycc/ycc-rgb.js +4 -4
- package/ycc/ycc.d.ts +1 -1
- package/ycc/ycc.js +4 -2
- package/internal/ensure-alpha.d.ts +0 -2
- package/internal/ensure-alpha.js +0 -2
- package/internal/ensure-args.d.ts +0 -3
- package/lib/index.js +0 -2236
- package/lib/index.js.map +0 -1
- package/lib/index.umd.js +0 -1
- package/lib/index.umd.js.map +0 -1
- package/ops/is-black.d.ts +0 -3
- package/ops/is-gray.d.ts +0 -3
- package/ops/is-white.d.ts +0 -3
package/css/css.js
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import { isNumber
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
1
|
+
import { isNumber } from "@thi.ng/checks/is-number";
|
|
2
|
+
import { isString } from "@thi.ng/checks/is-string";
|
|
3
|
+
import { convert } from "../convert.js";
|
|
4
|
+
import { hslCss } from "../hsl/hsl-css.js";
|
|
5
|
+
import { hsvCss } from "../hsv/hsv-css.js";
|
|
6
|
+
import { intArgb32Css } from "../int/int-css.js";
|
|
7
|
+
import { intAbgr32Argb32 } from "../int/int-int.js";
|
|
8
|
+
import { lchLab } from "../lab/lab-lch.js";
|
|
9
|
+
import { labRgb, labRgbD65 } from "../lab/lab-rgb.js";
|
|
10
|
+
import { rgbCss } from "../rgb/rgb-css.js";
|
|
11
|
+
import { rgbSrgb } from "../rgb/rgb-srgb.js";
|
|
12
|
+
import { srgbCss } from "../srgb/srgb-css.js";
|
|
12
13
|
/** @internal */
|
|
13
14
|
const CSS_CONVERSIONS = {
|
|
14
15
|
abgr32: (x) => intArgb32Css(intAbgr32Argb32(x[0])),
|
package/css/parse-css.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { IDeref } from "@thi.ng/api";
|
|
2
|
-
import { IParsedColor } from "../api";
|
|
2
|
+
import { IParsedColor } from "../api.js";
|
|
3
3
|
/**
|
|
4
4
|
* Attempts to parse given CSS color into an interim {@link ParsedColor} type
|
|
5
5
|
* with {@link srgb}, {@link hsl}, {@link labD50} or {@link lch} color modes.
|
package/css/parse-css.js
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { illegalArgs
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
1
|
+
import { interleave4_12_24, interleave4_16_32 } from "@thi.ng/binary/splat";
|
|
2
|
+
import { isString } from "@thi.ng/checks/is-string";
|
|
3
|
+
import { assert } from "@thi.ng/errors/assert";
|
|
4
|
+
import { illegalArgs } from "@thi.ng/errors/illegal-arguments";
|
|
5
|
+
import { unsupported } from "@thi.ng/errors/unsupported";
|
|
6
|
+
import { TAU } from "@thi.ng/math/api";
|
|
7
|
+
import { clamp01 } from "@thi.ng/math/interval";
|
|
8
|
+
import { fract } from "@thi.ng/math/prec";
|
|
9
|
+
import { ParsedColor } from "../api.js";
|
|
10
|
+
import { CSS_NAMES } from "../api/names.js";
|
|
11
|
+
import { CSS_SYSTEM_COLORS } from "../api/system.js";
|
|
12
|
+
import { intArgb32Srgb } from "../int/int-srgb.js";
|
|
10
13
|
/**
|
|
11
14
|
* Attempts to parse given CSS color into an interim {@link ParsedColor} type
|
|
12
15
|
* with {@link srgb}, {@link hsl}, {@link labD50} or {@link lch} color modes.
|
package/defcolor.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { IRandom } from "@thi.ng/random";
|
|
2
|
-
import type { ColorFactory, ColorMode, ColorSpec, ReadonlyColor, TypedColor } from "./api";
|
|
2
|
+
import type { ColorFactory, ColorMode, ColorSpec, ReadonlyColor, TypedColor } from "./api.js";
|
|
3
3
|
declare type $DefColor<M extends ColorMode, K extends string> = {
|
|
4
4
|
[k in K]: number;
|
|
5
5
|
} & {
|
package/defcolor.js
CHANGED
|
@@ -1,18 +1,30 @@
|
|
|
1
|
-
import { implementsFunction
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
1
|
+
import { implementsFunction } from "@thi.ng/checks/implements-function";
|
|
2
|
+
import { isArrayLike } from "@thi.ng/checks/is-arraylike";
|
|
3
|
+
import { isNumber } from "@thi.ng/checks/is-number";
|
|
4
|
+
import { isString } from "@thi.ng/checks/is-string";
|
|
5
|
+
import { illegalArgs } from "@thi.ng/errors/illegal-arguments";
|
|
6
|
+
import { EPS } from "@thi.ng/math/api";
|
|
7
|
+
import { vector } from "@thi.ng/strings/vector";
|
|
8
|
+
import { mapStridedBuffer } from "@thi.ng/vectors/buffer";
|
|
9
|
+
import { clamp4 } from "@thi.ng/vectors/clamp";
|
|
10
|
+
import { declareIndices } from "@thi.ng/vectors/compile/accessors";
|
|
11
|
+
import { eqDelta4 } from "@thi.ng/vectors/eqdelta";
|
|
12
|
+
import { stridedValues } from "@thi.ng/vectors/iterator";
|
|
13
|
+
import { randMinMax } from "@thi.ng/vectors/random";
|
|
14
|
+
import { set4 } from "@thi.ng/vectors/set";
|
|
15
|
+
import { convert, defConversions } from "./convert.js";
|
|
16
|
+
import { parseCss } from "./css/parse-css.js";
|
|
17
|
+
import { intArgb32Rgb } from "./int/int-rgb.js";
|
|
18
|
+
import { __ensureArgs } from "./internal/ensure.js";
|
|
10
19
|
export const defColor = (spec) => {
|
|
11
20
|
const channels = spec.channels || {};
|
|
12
21
|
const order = spec.order;
|
|
13
22
|
const numChannels = order.length;
|
|
14
23
|
order.reduce((acc, id) => {
|
|
15
|
-
acc[id] =
|
|
24
|
+
acc[id] = {
|
|
25
|
+
range: [0, 1],
|
|
26
|
+
...channels[id],
|
|
27
|
+
};
|
|
16
28
|
return acc;
|
|
17
29
|
}, channels);
|
|
18
30
|
const min = order.map((id) => channels[id].range[0]);
|
|
@@ -77,6 +89,7 @@ export const defColor = (spec) => {
|
|
|
77
89
|
};
|
|
78
90
|
declareIndices($Color.prototype, order);
|
|
79
91
|
defConversions(spec.mode, spec.from);
|
|
92
|
+
defConversions("rgb", { [spec.mode]: spec.toRgb });
|
|
80
93
|
const fromColor = (src, mode, xs) => {
|
|
81
94
|
const res = new $Color(...xs);
|
|
82
95
|
return mode !== spec.mode
|
|
@@ -95,7 +108,7 @@ export const defColor = (spec) => {
|
|
|
95
108
|
? fromColor(src.deref(), src.mode, xs)
|
|
96
109
|
: isNumber(src)
|
|
97
110
|
? xs.length && xs.every(isNumber)
|
|
98
|
-
? new $Color(...
|
|
111
|
+
? new $Color(...__ensureArgs([src, ...xs]))
|
|
99
112
|
: fromColor(intArgb32Rgb([], src), "rgb", xs)
|
|
100
113
|
: illegalArgs(`can't create a ${spec.mode} color from: ${src}`);
|
|
101
114
|
factory.class = $Color;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ReadonlyVec } from "@thi.ng/vectors";
|
|
2
|
-
import type { ColorDistance } from "
|
|
1
|
+
import { ReadonlyVec } from "@thi.ng/vectors/api";
|
|
2
|
+
import type { ColorDistance } from "./api.js";
|
|
3
3
|
/**
|
|
4
4
|
* Higher order function. Returns {@link ColorDistance} function for given color
|
|
5
5
|
* channel ID.
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { atan2Abs, cossin
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import { atan2Abs, cossin } from "@thi.ng/math/angle";
|
|
2
|
+
import { DEG2RAD, PI, SIXTH_PI, TAU, THIRD_PI } from "@thi.ng/math/api";
|
|
3
|
+
import { ONE3 } from "@thi.ng/vectors/api";
|
|
4
|
+
import { dist3, dist4 } from "@thi.ng/vectors/dist";
|
|
5
|
+
import { labD50 } from "./lab/lab50.js";
|
|
6
|
+
import { labD65 } from "./lab/lab65.js";
|
|
7
|
+
import { luminanceRgb, luminanceSrgb } from "./luminance-rgb.js";
|
|
6
8
|
const { abs, cos, hypot, sin, sqrt } = Math;
|
|
7
9
|
/**
|
|
8
10
|
* Higher order function. Returns {@link ColorDistance} function for given color
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { NumericArray } from "@thi.ng/api";
|
|
2
|
-
import type { TypedColor } from "
|
|
3
|
-
import type { GradientOpts } from "
|
|
2
|
+
import type { TypedColor } from "./api.js";
|
|
3
|
+
import type { GradientOpts } from "./api/gradients.js";
|
|
4
4
|
/**
|
|
5
5
|
* Similar to {@link multiCosineGradient}, but using any number of gradient
|
|
6
6
|
* color stops and isn't limited to RGB, but for arbitrary color types.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { tween } from "@thi.ng/transducers";
|
|
2
|
-
import { setS4 } from "@thi.ng/vectors";
|
|
3
|
-
import { mix as $mix } from "
|
|
1
|
+
import { tween } from "@thi.ng/transducers/tween";
|
|
2
|
+
import { setS4 } from "@thi.ng/vectors/sets";
|
|
3
|
+
import { mix as $mix } from "./mix.js";
|
|
4
4
|
/**
|
|
5
5
|
* Similar to {@link multiCosineGradient}, but using any number of gradient
|
|
6
6
|
* color stops and isn't limited to RGB, but for arbitrary color types.
|
package/hcy/hcy-rgb.d.ts
CHANGED
package/hcy/hcy-rgb.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { clamp01 } from "@thi.ng/math";
|
|
2
|
-
import { setC3 } from "@thi.ng/vectors";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import { clamp01 } from "@thi.ng/math/interval";
|
|
2
|
+
import { setC3 } from "@thi.ng/vectors/setc";
|
|
3
|
+
import { __ensureAlpha } from "../internal/ensure.js";
|
|
4
|
+
import { luminanceRgb } from "../luminance-rgb.js";
|
|
5
|
+
import { hueRgb } from "../rgb/hue-rgb.js";
|
|
6
6
|
export const hcyRgb = (out, src) => {
|
|
7
7
|
const h = src[0];
|
|
8
8
|
let c = src[1];
|
|
9
9
|
const y = src[2];
|
|
10
|
-
const rgb = hueRgb(out || src, h,
|
|
10
|
+
const rgb = hueRgb(out || src, h, __ensureAlpha(src[3]));
|
|
11
11
|
const lum = luminanceRgb(rgb);
|
|
12
12
|
if (y < lum) {
|
|
13
13
|
c *= y / lum;
|
package/hcy/hcy.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { NumericArray } from "@thi.ng/api";
|
|
2
2
|
import type { IRandom } from "@thi.ng/random";
|
|
3
|
-
import type { Color, ColorFactory, ReadonlyColor, TypedColor } from "../api";
|
|
3
|
+
import type { Color, ColorFactory, ReadonlyColor, TypedColor } from "../api.js";
|
|
4
4
|
export declare class HCY implements TypedColor<HCY> {
|
|
5
5
|
buf: NumericArray;
|
|
6
6
|
offset: number;
|
package/hcy/hcy.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { defColor } from "../defcolor";
|
|
2
|
-
import { rgbHcy } from "../rgb/rgb-hcy";
|
|
1
|
+
import { defColor } from "../defcolor.js";
|
|
2
|
+
import { rgbHcy } from "../rgb/rgb-hcy.js";
|
|
3
|
+
import { hcyRgb } from "./hcy-rgb.js";
|
|
3
4
|
export const hcy = defColor({
|
|
4
5
|
mode: "hcy",
|
|
5
6
|
order: ["h", "c", "y", "alpha"],
|
|
6
7
|
from: { rgb: rgbHcy, srgb: rgbHcy },
|
|
8
|
+
toRgb: hcyRgb,
|
|
7
9
|
});
|
package/hsi/hsi-rgb.d.ts
CHANGED
package/hsi/hsi-rgb.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { setC3 } from "@thi.ng/vectors";
|
|
2
|
-
import { clampH } from "../
|
|
1
|
+
import { setC3 } from "@thi.ng/vectors/setc";
|
|
2
|
+
import { clampH } from "../clamp.js";
|
|
3
3
|
// https://en.wikipedia.org/wiki/HSL_and_HSV#From_HSI
|
|
4
4
|
export const hsiRgb = (out, src) => {
|
|
5
5
|
out = clampH(out || src, src);
|
package/hsi/hsi.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { NumericArray } from "@thi.ng/api";
|
|
2
2
|
import type { IRandom } from "@thi.ng/random";
|
|
3
|
-
import type { Color, ColorFactory, ReadonlyColor, TypedColor } from "../api";
|
|
3
|
+
import type { Color, ColorFactory, ReadonlyColor, TypedColor } from "../api.js";
|
|
4
4
|
export declare class HSI implements TypedColor<HSI> {
|
|
5
5
|
buf: NumericArray;
|
|
6
6
|
offset: number;
|
package/hsi/hsi.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { defColor } from "../defcolor";
|
|
2
|
-
import { rgbHsi } from "../rgb/rgb-hsi";
|
|
1
|
+
import { defColor } from "../defcolor.js";
|
|
2
|
+
import { rgbHsi } from "../rgb/rgb-hsi.js";
|
|
3
|
+
import { hsiRgb } from "./hsi-rgb.js";
|
|
3
4
|
export const hsi = defColor({
|
|
4
5
|
mode: "hsi",
|
|
5
6
|
order: ["h", "s", "i", "alpha"],
|
|
6
7
|
from: { rgb: rgbHsi, srgb: rgbHsi },
|
|
8
|
+
toRgb: hsiRgb,
|
|
7
9
|
});
|
package/hsl/hsl-css.d.ts
CHANGED
package/hsl/hsl-css.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { clamp01
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { clamp01 } from "@thi.ng/math/interval";
|
|
2
|
+
import { fract } from "@thi.ng/math/prec";
|
|
3
|
+
import { FF, PC } from "../api/constants.js";
|
|
4
|
+
import { __ensureAlpha } from "../internal/ensure.js";
|
|
4
5
|
export const hslCss = (src) => {
|
|
5
6
|
const h = FF(fract(src[0]) * 360);
|
|
6
7
|
const s = PC(clamp01(src[1]));
|
|
7
8
|
const l = PC(clamp01(src[2]));
|
|
8
|
-
const a =
|
|
9
|
+
const a = __ensureAlpha(src[3]);
|
|
9
10
|
// TODO update to new syntax once CSS Color L4 is more widely supported
|
|
10
11
|
// https://www.w3.org/TR/css-color-4/#serializing-lab-lch
|
|
11
12
|
// https://test.csswg.org/harness/results/css-color-4_dev/grouped/ (test reports)
|
package/hsl/hsl-hsv.d.ts
CHANGED
package/hsl/hsl-hsv.js
CHANGED
package/hsl/hsl-rgb.d.ts
CHANGED
package/hsl/hsl-rgb.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { clamp01 } from "@thi.ng/math";
|
|
2
|
-
import { setC3 } from "@thi.ng/vectors";
|
|
3
|
-
import { hueRgb } from "../rgb/hue-rgb";
|
|
4
|
-
import {
|
|
1
|
+
import { clamp01 } from "@thi.ng/math/interval";
|
|
2
|
+
import { setC3 } from "@thi.ng/vectors/setc";
|
|
3
|
+
import { hueRgb } from "../rgb/hue-rgb.js";
|
|
4
|
+
import { __ensureAlpha } from "../internal/ensure.js";
|
|
5
5
|
export const hslRgb = (out, src) => {
|
|
6
6
|
const s = clamp01(src[1]);
|
|
7
7
|
const l = clamp01(src[2]);
|
|
8
|
-
out = hueRgb(out || src, src[0],
|
|
8
|
+
out = hueRgb(out || src, src[0], __ensureAlpha(src[3]));
|
|
9
9
|
const c = (1 - Math.abs(2 * l - 1)) * s;
|
|
10
10
|
return setC3(out, (out[0] - 0.5) * c + l, (out[1] - 0.5) * c + l, (out[2] - 0.5) * c + l);
|
|
11
11
|
};
|
package/hsl/hsl.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { NumericArray } from "@thi.ng/api";
|
|
2
2
|
import type { IRandom } from "@thi.ng/random";
|
|
3
|
-
import type { Color, ColorFactory, ReadonlyColor, TypedColor } from "../api";
|
|
3
|
+
import type { Color, ColorFactory, ReadonlyColor, TypedColor } from "../api.js";
|
|
4
4
|
export declare class HSL implements TypedColor<HSL> {
|
|
5
5
|
buf: NumericArray;
|
|
6
6
|
offset: number;
|
package/hsl/hsl.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { defColor } from "../defcolor";
|
|
2
|
-
import { hsvHsl } from "../hsv/hsv-hsl";
|
|
3
|
-
import { rgbHsl } from "../rgb/rgb-hsl";
|
|
1
|
+
import { defColor } from "../defcolor.js";
|
|
2
|
+
import { hsvHsl } from "../hsv/hsv-hsl.js";
|
|
3
|
+
import { rgbHsl } from "../rgb/rgb-hsl.js";
|
|
4
|
+
import { hslRgb } from "./hsl-rgb.js";
|
|
4
5
|
export const hsl = defColor({
|
|
5
6
|
mode: "hsl",
|
|
6
7
|
order: ["h", "s", "l", "alpha"],
|
|
7
8
|
from: { rgb: rgbHsl, srgb: rgbHsl, hsv: hsvHsl },
|
|
9
|
+
toRgb: hslRgb,
|
|
8
10
|
});
|
package/hsv/hsv-css.d.ts
CHANGED
package/hsv/hsv-css.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { hslCss } from "../hsl/hsl-css";
|
|
2
|
-
import { hsvHsl } from "./hsv-hsl";
|
|
1
|
+
import { hslCss } from "../hsl/hsl-css.js";
|
|
2
|
+
import { hsvHsl } from "./hsv-hsl.js";
|
|
3
3
|
export const hsvCss = (src) => hslCss(hsvHsl([], src));
|
package/hsv/hsv-hsl.d.ts
CHANGED
package/hsv/hsv-hsl.js
CHANGED
package/hsv/hsv-rgb.d.ts
CHANGED
package/hsv/hsv-rgb.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { setC3 } from "@thi.ng/vectors";
|
|
2
|
-
import { clampH } from "../
|
|
3
|
-
import { hueRgb } from "../rgb/hue-rgb";
|
|
1
|
+
import { setC3 } from "@thi.ng/vectors/setc";
|
|
2
|
+
import { clampH } from "../clamp.js";
|
|
3
|
+
import { hueRgb } from "../rgb/hue-rgb.js";
|
|
4
4
|
export const hsvRgb = (out, src) => {
|
|
5
5
|
out = clampH(out || src, src);
|
|
6
6
|
const s = out[1];
|
package/hsv/hsv.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { NumericArray } from "@thi.ng/api";
|
|
2
2
|
import type { IRandom } from "@thi.ng/random";
|
|
3
|
-
import type { Color, ColorFactory, ReadonlyColor, TypedColor } from "../api";
|
|
3
|
+
import type { Color, ColorFactory, ReadonlyColor, TypedColor } from "../api.js";
|
|
4
4
|
export declare class HSV implements TypedColor<HSV> {
|
|
5
5
|
buf: NumericArray;
|
|
6
6
|
offset: number;
|
package/hsv/hsv.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { defColor } from "../defcolor";
|
|
2
|
-
import { hslHsv } from "../hsl/hsl-hsv";
|
|
3
|
-
import { rgbHsv } from "../rgb/rgb-hsv";
|
|
1
|
+
import { defColor } from "../defcolor.js";
|
|
2
|
+
import { hslHsv } from "../hsl/hsl-hsv.js";
|
|
3
|
+
import { rgbHsv } from "../rgb/rgb-hsv.js";
|
|
4
|
+
import { hsvRgb } from "./hsv-rgb.js";
|
|
4
5
|
export const hsv = defColor({
|
|
5
6
|
mode: "hsv",
|
|
6
7
|
order: ["h", "s", "v", "alpha"],
|
|
7
8
|
from: { rgb: rgbHsv, srgb: rgbHsv, hsl: hslHsv },
|
|
9
|
+
toRgb: hsvRgb,
|
|
8
10
|
});
|
package/index.d.ts
CHANGED
|
@@ -1,88 +1,88 @@
|
|
|
1
|
-
export * from "./api";
|
|
2
|
-
export * from "./api/constants";
|
|
3
|
-
export * from "./api/gradients";
|
|
4
|
-
export * from "./api/names";
|
|
5
|
-
export * from "./api/ranges";
|
|
6
|
-
export * from "./api/system";
|
|
7
|
-
export * from "./color";
|
|
8
|
-
export * from "./convert";
|
|
9
|
-
export * from "./defcolor";
|
|
10
|
-
export * from "./css/css";
|
|
11
|
-
export * from "./css/parse-css";
|
|
12
|
-
export * from "./hcy/hcy-rgb";
|
|
13
|
-
export * from "./hcy/hcy";
|
|
14
|
-
export * from "./hsi/hsi-rgb";
|
|
15
|
-
export * from "./hsi/hsi";
|
|
16
|
-
export * from "./hsl/hsl-css";
|
|
17
|
-
export * from "./hsl/hsl-hsv";
|
|
18
|
-
export * from "./hsl/hsl-rgb";
|
|
19
|
-
export * from "./hsl/hsl";
|
|
20
|
-
export * from "./hsv/hsv-css";
|
|
21
|
-
export * from "./hsv/hsv-hsl";
|
|
22
|
-
export * from "./hsv/hsv-rgb";
|
|
23
|
-
export * from "./hsv/hsv";
|
|
24
|
-
export * from "./int/int-css";
|
|
25
|
-
export * from "./int/int-int";
|
|
26
|
-
export * from "./int/int-rgb";
|
|
27
|
-
export * from "./int/int-srgb";
|
|
28
|
-
export * from "./int/int";
|
|
29
|
-
export * from "./lab/lab-css";
|
|
30
|
-
export * from "./lab/lab-lab";
|
|
31
|
-
export * from "./lab/lab-lch";
|
|
32
|
-
export * from "./lab/lab-rgb";
|
|
33
|
-
export * from "./lab/lab-xyz";
|
|
34
|
-
export * from "./lab/lab50";
|
|
35
|
-
export * from "./lab/lab65";
|
|
36
|
-
export * from "./lch/lch-css";
|
|
37
|
-
export * from "./lch/lch";
|
|
38
|
-
export * from "./oklab/oklab-rgb";
|
|
39
|
-
export * from "./oklab/oklab-xyz";
|
|
40
|
-
export * from "./oklab/oklab";
|
|
41
|
-
export * from "./
|
|
42
|
-
export * from "./
|
|
43
|
-
export * from "./
|
|
44
|
-
export * from "./
|
|
45
|
-
export * from "./
|
|
46
|
-
export * from "./
|
|
47
|
-
export * from "./
|
|
48
|
-
export * from "./
|
|
49
|
-
export * from "./
|
|
50
|
-
export * from "./
|
|
51
|
-
export * from "./
|
|
52
|
-
export * from "./
|
|
53
|
-
export * from "./
|
|
54
|
-
export * from "./
|
|
55
|
-
export * from "./
|
|
56
|
-
export * from "./
|
|
57
|
-
export * from "./
|
|
58
|
-
export * from "./rgb/hue-rgb";
|
|
59
|
-
export * from "./rgb/kelvin-rgba";
|
|
60
|
-
export * from "./rgb/rgb-css";
|
|
61
|
-
export * from "./rgb/rgb-hcv";
|
|
62
|
-
export * from "./rgb/rgb-hcy";
|
|
63
|
-
export * from "./rgb/rgb-hsi";
|
|
64
|
-
export * from "./rgb/rgb-hsl";
|
|
65
|
-
export * from "./rgb/rgb-hsv";
|
|
66
|
-
export * from "./rgb/rgb-lab";
|
|
67
|
-
export * from "./rgb/rgb-oklab";
|
|
68
|
-
export * from "./rgb/rgb-srgb";
|
|
69
|
-
export * from "./rgb/rgb-xyz";
|
|
70
|
-
export * from "./rgb/rgb-ycc";
|
|
71
|
-
export * from "./rgb/rgb";
|
|
72
|
-
export * from "./srgb/srgb-css";
|
|
73
|
-
export * from "./srgb/srgb-int";
|
|
74
|
-
export * from "./srgb/srgb-rgb";
|
|
75
|
-
export * from "./srgb/srgb";
|
|
76
|
-
export * from "./xyy/xyy-xyz";
|
|
77
|
-
export * from "./xyy/xyy";
|
|
78
|
-
export * from "./xyz/wavelength-xyz";
|
|
79
|
-
export * from "./xyz/xyz-lab";
|
|
80
|
-
export * from "./xyz/xyz-oklab";
|
|
81
|
-
export * from "./xyz/xyz-rgb";
|
|
82
|
-
export * from "./xyz/xyz-xyy";
|
|
83
|
-
export * from "./xyz/xyz-xyz";
|
|
84
|
-
export * from "./xyz/xyz50";
|
|
85
|
-
export * from "./xyz/xyz65";
|
|
86
|
-
export * from "./ycc/ycc-rgb";
|
|
87
|
-
export * from "./ycc/ycc";
|
|
1
|
+
export * from "./api.js";
|
|
2
|
+
export * from "./api/constants.js";
|
|
3
|
+
export * from "./api/gradients.js";
|
|
4
|
+
export * from "./api/names.js";
|
|
5
|
+
export * from "./api/ranges.js";
|
|
6
|
+
export * from "./api/system.js";
|
|
7
|
+
export * from "./color.js";
|
|
8
|
+
export * from "./convert.js";
|
|
9
|
+
export * from "./defcolor.js";
|
|
10
|
+
export * from "./css/css.js";
|
|
11
|
+
export * from "./css/parse-css.js";
|
|
12
|
+
export * from "./hcy/hcy-rgb.js";
|
|
13
|
+
export * from "./hcy/hcy.js";
|
|
14
|
+
export * from "./hsi/hsi-rgb.js";
|
|
15
|
+
export * from "./hsi/hsi.js";
|
|
16
|
+
export * from "./hsl/hsl-css.js";
|
|
17
|
+
export * from "./hsl/hsl-hsv.js";
|
|
18
|
+
export * from "./hsl/hsl-rgb.js";
|
|
19
|
+
export * from "./hsl/hsl.js";
|
|
20
|
+
export * from "./hsv/hsv-css.js";
|
|
21
|
+
export * from "./hsv/hsv-hsl.js";
|
|
22
|
+
export * from "./hsv/hsv-rgb.js";
|
|
23
|
+
export * from "./hsv/hsv.js";
|
|
24
|
+
export * from "./int/int-css.js";
|
|
25
|
+
export * from "./int/int-int.js";
|
|
26
|
+
export * from "./int/int-rgb.js";
|
|
27
|
+
export * from "./int/int-srgb.js";
|
|
28
|
+
export * from "./int/int.js";
|
|
29
|
+
export * from "./lab/lab-css.js";
|
|
30
|
+
export * from "./lab/lab-lab.js";
|
|
31
|
+
export * from "./lab/lab-lch.js";
|
|
32
|
+
export * from "./lab/lab-rgb.js";
|
|
33
|
+
export * from "./lab/lab-xyz.js";
|
|
34
|
+
export * from "./lab/lab50.js";
|
|
35
|
+
export * from "./lab/lab65.js";
|
|
36
|
+
export * from "./lch/lch-css.js";
|
|
37
|
+
export * from "./lch/lch.js";
|
|
38
|
+
export * from "./oklab/oklab-rgb.js";
|
|
39
|
+
export * from "./oklab/oklab-xyz.js";
|
|
40
|
+
export * from "./oklab/oklab.js";
|
|
41
|
+
export * from "./alpha.js";
|
|
42
|
+
export * from "./analog.js";
|
|
43
|
+
export * from "./clamp.js";
|
|
44
|
+
export * from "./closest-hue.js";
|
|
45
|
+
export * from "./color-range.js";
|
|
46
|
+
export * from "./cosine-gradients.js";
|
|
47
|
+
export * from "./distance.js";
|
|
48
|
+
export * from "./gradients.js";
|
|
49
|
+
export * from "./invert.js";
|
|
50
|
+
export * from "./is-gray.js";
|
|
51
|
+
export * from "./linear.js";
|
|
52
|
+
export * from "./luminance-rgb.js";
|
|
53
|
+
export * from "./luminance.js";
|
|
54
|
+
export * from "./mix.js";
|
|
55
|
+
export * from "./sort.js";
|
|
56
|
+
export * from "./swatches.js";
|
|
57
|
+
export * from "./transform.js";
|
|
58
|
+
export * from "./rgb/hue-rgb.js";
|
|
59
|
+
export * from "./rgb/kelvin-rgba.js";
|
|
60
|
+
export * from "./rgb/rgb-css.js";
|
|
61
|
+
export * from "./rgb/rgb-hcv.js";
|
|
62
|
+
export * from "./rgb/rgb-hcy.js";
|
|
63
|
+
export * from "./rgb/rgb-hsi.js";
|
|
64
|
+
export * from "./rgb/rgb-hsl.js";
|
|
65
|
+
export * from "./rgb/rgb-hsv.js";
|
|
66
|
+
export * from "./rgb/rgb-lab.js";
|
|
67
|
+
export * from "./rgb/rgb-oklab.js";
|
|
68
|
+
export * from "./rgb/rgb-srgb.js";
|
|
69
|
+
export * from "./rgb/rgb-xyz.js";
|
|
70
|
+
export * from "./rgb/rgb-ycc.js";
|
|
71
|
+
export * from "./rgb/rgb.js";
|
|
72
|
+
export * from "./srgb/srgb-css.js";
|
|
73
|
+
export * from "./srgb/srgb-int.js";
|
|
74
|
+
export * from "./srgb/srgb-rgb.js";
|
|
75
|
+
export * from "./srgb/srgb.js";
|
|
76
|
+
export * from "./xyy/xyy-xyz.js";
|
|
77
|
+
export * from "./xyy/xyy.js";
|
|
78
|
+
export * from "./xyz/wavelength-xyz.js";
|
|
79
|
+
export * from "./xyz/xyz-lab.js";
|
|
80
|
+
export * from "./xyz/xyz-oklab.js";
|
|
81
|
+
export * from "./xyz/xyz-rgb.js";
|
|
82
|
+
export * from "./xyz/xyz-xyy.js";
|
|
83
|
+
export * from "./xyz/xyz-xyz.js";
|
|
84
|
+
export * from "./xyz/xyz50.js";
|
|
85
|
+
export * from "./xyz/xyz65.js";
|
|
86
|
+
export * from "./ycc/ycc-rgb.js";
|
|
87
|
+
export * from "./ycc/ycc.js";
|
|
88
88
|
//# sourceMappingURL=index.d.ts.map
|