@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/index.js
CHANGED
|
@@ -1,87 +1,87 @@
|
|
|
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";
|
package/int/int-css.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { U24 } from "@thi.ng/strings";
|
|
2
|
-
import { FF, INV8BIT } from "../api/constants";
|
|
1
|
+
import { U24 } from "@thi.ng/strings/radix";
|
|
2
|
+
import { FF, INV8BIT } from "../api/constants.js";
|
|
3
3
|
export const intArgb32Css = (src) => {
|
|
4
4
|
const a = src >>> 24;
|
|
5
5
|
return a < 255
|
package/int/int-int.js
CHANGED
package/int/int-rgb.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Color } from "../api";
|
|
1
|
+
import type { Color } from "../api.js";
|
|
2
2
|
export declare const intArgb32Rgb: (out: Color | null, src: number) => import("@thi.ng/vectors").Vec;
|
|
3
3
|
export declare const intRgb24Rgb: (out: Color | null, src: number) => import("@thi.ng/vectors").Vec;
|
|
4
4
|
export declare const intAbgr32Rgb: (out: Color | null, src: number) => import("@thi.ng/vectors").Vec;
|
package/int/int-rgb.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { srgbRgb } from "../srgb/srgb-rgb";
|
|
2
|
-
import { intAbgr32Srgb, intArgb32Srgb, intBgr24Srgb, intRgb24Srgb, } from "./int-srgb";
|
|
1
|
+
import { srgbRgb } from "../srgb/srgb-rgb.js";
|
|
2
|
+
import { intAbgr32Srgb, intArgb32Srgb, intBgr24Srgb, intRgb24Srgb, } from "./int-srgb.js";
|
|
3
3
|
export const intArgb32Rgb = (out, src) => srgbRgb(null, intArgb32Srgb(out, src));
|
|
4
4
|
export const intRgb24Rgb = (out, src) => srgbRgb(null, intRgb24Srgb(out, src));
|
|
5
5
|
export const intAbgr32Rgb = (out, src) => srgbRgb(null, intAbgr32Srgb(out, src));
|
package/int/int-srgb.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Color } from "../api";
|
|
1
|
+
import type { Color } from "../api.js";
|
|
2
2
|
export declare const intArgb32Srgb: (out: Color | null, src: number) => import("@thi.ng/vectors").Vec;
|
|
3
3
|
export declare const intAbgr32Srgb: (out: Color | null, src: number) => import("@thi.ng/vectors").Vec;
|
|
4
4
|
export declare const intRgb24Srgb: (out: Color | null, src: number) => import("@thi.ng/vectors").Vec;
|
package/int/int-srgb.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { setC4 } from "@thi.ng/vectors";
|
|
2
|
-
import { INV8BIT } from "../api/constants";
|
|
1
|
+
import { setC4 } from "@thi.ng/vectors/setc";
|
|
2
|
+
import { INV8BIT } from "../api/constants.js";
|
|
3
3
|
export const intArgb32Srgb = (out, src) => setC4(out || [], ((src >>> 16) & 0xff) * INV8BIT, ((src >>> 8) & 0xff) * INV8BIT, (src & 0xff) * INV8BIT, (src >>> 24) * INV8BIT);
|
|
4
4
|
export const intAbgr32Srgb = (out, src) => setC4(out || [], (src & 0xff) * INV8BIT, ((src >>> 8) & 0xff) * INV8BIT, ((src >>> 16) & 0xff) * INV8BIT, (src >>> 24) * INV8BIT);
|
|
5
5
|
export const intRgb24Srgb = (out, src) => intArgb32Srgb(out, src | 0xff000000);
|
package/int/int.d.ts
CHANGED
|
@@ -1,17 +1,22 @@
|
|
|
1
1
|
import type { ArrayLikeIterable, NumericArray } from "@thi.ng/api";
|
|
2
|
-
import { IRandom } from "@thi.ng/random";
|
|
3
|
-
import type { ColorFactory, ColorMode, ReadonlyColor, TypedColor } from "../api";
|
|
4
|
-
export declare abstract class Int32 {
|
|
2
|
+
import type { IRandom } from "@thi.ng/random";
|
|
3
|
+
import type { ColorFactory, ColorMode, ReadonlyColor, TypedColor } from "../api.js";
|
|
4
|
+
export declare abstract class Int32<T extends TypedColor<T>> implements TypedColor<T> {
|
|
5
5
|
offset: number;
|
|
6
6
|
stride: number;
|
|
7
7
|
buf: NumericArray;
|
|
8
8
|
value: number;
|
|
9
9
|
[id: number]: number;
|
|
10
10
|
constructor(buf?: NumericArray, offset?: number, stride?: number);
|
|
11
|
+
abstract get mode(): ColorMode;
|
|
12
|
+
abstract copy(): T;
|
|
13
|
+
abstract copyView(): T;
|
|
14
|
+
abstract empty(): T;
|
|
15
|
+
eqDelta(o: T, eps?: number): boolean;
|
|
11
16
|
get length(): number;
|
|
12
17
|
get range(): [ReadonlyColor, ReadonlyColor];
|
|
13
18
|
get alpha(): number;
|
|
14
|
-
set alpha(
|
|
19
|
+
set alpha(x: number);
|
|
15
20
|
[Symbol.iterator](): Generator<number, void, unknown>;
|
|
16
21
|
deref(): number[];
|
|
17
22
|
randomize(rnd?: IRandom): this;
|
|
@@ -19,24 +24,32 @@ export declare abstract class Int32 {
|
|
|
19
24
|
set(src: ArrayLikeIterable<number>): this;
|
|
20
25
|
toJSON(): number[];
|
|
21
26
|
}
|
|
22
|
-
export declare class ARGB extends Int32 implements TypedColor<ARGB> {
|
|
23
|
-
argb: number;
|
|
27
|
+
export declare class ARGB extends Int32<ARGB> implements TypedColor<ARGB> {
|
|
24
28
|
[id: number]: number;
|
|
25
29
|
get mode(): ColorMode;
|
|
30
|
+
get r(): number;
|
|
31
|
+
set r(x: number);
|
|
32
|
+
get g(): number;
|
|
33
|
+
set g(x: number);
|
|
34
|
+
get b(): number;
|
|
35
|
+
set b(x: number);
|
|
26
36
|
copy(): ARGB;
|
|
27
37
|
copyView(): ARGB;
|
|
28
38
|
empty(): ARGB;
|
|
29
|
-
eqDelta(o: ARGB, eps?: number): boolean;
|
|
30
39
|
}
|
|
31
|
-
export declare class ABGR extends Int32 implements TypedColor<
|
|
32
|
-
argb: number;
|
|
40
|
+
export declare class ABGR extends Int32<ABGR> implements TypedColor<ABGR> {
|
|
33
41
|
[id: number]: number;
|
|
34
42
|
get mode(): ColorMode;
|
|
43
|
+
get r(): number;
|
|
44
|
+
set r(x: number);
|
|
45
|
+
get g(): number;
|
|
46
|
+
set g(x: number);
|
|
47
|
+
get b(): number;
|
|
48
|
+
set b(x: number);
|
|
35
49
|
copy(): ABGR;
|
|
36
50
|
copyView(): ABGR;
|
|
37
51
|
empty(): ABGR;
|
|
38
|
-
eqDelta(o: ABGR, eps?: number): boolean;
|
|
39
52
|
}
|
|
40
53
|
export declare const argb32: ColorFactory<ARGB>;
|
|
41
|
-
export declare const abgr32: ColorFactory<
|
|
54
|
+
export declare const abgr32: ColorFactory<ABGR>;
|
|
42
55
|
//# sourceMappingURL=int.d.ts.map
|
package/int/int.js
CHANGED
|
@@ -1,18 +1,28 @@
|
|
|
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 { SYSTEM } from "@thi.ng/random/system";
|
|
7
|
+
import { mapStridedBuffer } from "@thi.ng/vectors/buffer";
|
|
8
|
+
import { declareIndex } from "@thi.ng/vectors/compile/accessors";
|
|
9
|
+
import { eqDelta4 } from "@thi.ng/vectors/eqdelta";
|
|
10
|
+
import { parseCss } from "../css/parse-css.js";
|
|
11
|
+
import { __scale8bit } from "../internal/scale.js";
|
|
12
|
+
import { srgb } from "../srgb/srgb.js";
|
|
13
|
+
import { srgbIntAbgr32, srgbIntArgb32 } from "../srgb/srgb-int.js";
|
|
14
|
+
import { intArgb32Srgb } from "./int-srgb.js";
|
|
10
15
|
export class Int32 {
|
|
11
16
|
constructor(buf, offset = 0, stride = 1) {
|
|
12
17
|
this.offset = offset;
|
|
13
18
|
this.stride = stride;
|
|
14
19
|
this.buf = buf || [0];
|
|
15
20
|
}
|
|
21
|
+
eqDelta(o, eps) {
|
|
22
|
+
return eqDelta4(
|
|
23
|
+
// channel order irrelevant here...
|
|
24
|
+
intArgb32Srgb([], this[0]), intArgb32Srgb([], o[0]), eps);
|
|
25
|
+
}
|
|
16
26
|
get length() {
|
|
17
27
|
return 1;
|
|
18
28
|
}
|
|
@@ -22,8 +32,8 @@ export class Int32 {
|
|
|
22
32
|
get alpha() {
|
|
23
33
|
return (this[0] >>> 24) / 255;
|
|
24
34
|
}
|
|
25
|
-
set alpha(
|
|
26
|
-
this[0] = (this[0] & 0xffffff) | (
|
|
35
|
+
set alpha(x) {
|
|
36
|
+
this[0] = (this[0] & 0xffffff) | __scale8bit(x, 24);
|
|
27
37
|
}
|
|
28
38
|
*[Symbol.iterator]() {
|
|
29
39
|
yield this[0];
|
|
@@ -51,6 +61,24 @@ export class ARGB extends Int32 {
|
|
|
51
61
|
get mode() {
|
|
52
62
|
return "argb32";
|
|
53
63
|
}
|
|
64
|
+
get r() {
|
|
65
|
+
return ((this[0] >> 16) & 0xff) / 255;
|
|
66
|
+
}
|
|
67
|
+
set r(x) {
|
|
68
|
+
this[0] = (this[0] & 0xff00ffff) | __scale8bit(x, 16);
|
|
69
|
+
}
|
|
70
|
+
get g() {
|
|
71
|
+
return ((this[0] >> 8) & 0xff) / 255;
|
|
72
|
+
}
|
|
73
|
+
set g(x) {
|
|
74
|
+
this[0] = (this[0] & 0xffff00ff) | __scale8bit(x, 8);
|
|
75
|
+
}
|
|
76
|
+
get b() {
|
|
77
|
+
return (this[0] & 0xff) / 255;
|
|
78
|
+
}
|
|
79
|
+
set b(x) {
|
|
80
|
+
this[0] = (this[0] & 0xffffff00) | __scale8bit(x);
|
|
81
|
+
}
|
|
54
82
|
copy() {
|
|
55
83
|
return new ARGB([this[0]]);
|
|
56
84
|
}
|
|
@@ -60,15 +88,30 @@ export class ARGB extends Int32 {
|
|
|
60
88
|
empty() {
|
|
61
89
|
return new ARGB();
|
|
62
90
|
}
|
|
63
|
-
eqDelta(o, eps = 0) {
|
|
64
|
-
return eqDelta4(intArgb32Srgb([], this[0]), intArgb32Srgb([], o[0]), eps);
|
|
65
|
-
}
|
|
66
91
|
}
|
|
67
92
|
declareIndex(ARGB.prototype, "value", 0);
|
|
68
93
|
export class ABGR extends Int32 {
|
|
69
94
|
get mode() {
|
|
70
95
|
return "abgr32";
|
|
71
96
|
}
|
|
97
|
+
get r() {
|
|
98
|
+
return (this[0] & 0xff) / 255;
|
|
99
|
+
}
|
|
100
|
+
set r(x) {
|
|
101
|
+
this[0] = (this[0] & 0xffffff00) | __scale8bit(x);
|
|
102
|
+
}
|
|
103
|
+
get g() {
|
|
104
|
+
return ((this[0] >> 8) & 0xff) / 255;
|
|
105
|
+
}
|
|
106
|
+
set g(x) {
|
|
107
|
+
this[0] = (this[0] & 0xffff00ff) | __scale8bit(x, 8);
|
|
108
|
+
}
|
|
109
|
+
get b() {
|
|
110
|
+
return ((this[0] >> 16) & 0xff) / 255;
|
|
111
|
+
}
|
|
112
|
+
set b(x) {
|
|
113
|
+
this[0] = (this[0] & 0xff00ffff) | __scale8bit(x, 16);
|
|
114
|
+
}
|
|
72
115
|
copy() {
|
|
73
116
|
return new ABGR([this[0]]);
|
|
74
117
|
}
|
|
@@ -78,14 +121,11 @@ export class ABGR extends Int32 {
|
|
|
78
121
|
empty() {
|
|
79
122
|
return new ABGR();
|
|
80
123
|
}
|
|
81
|
-
eqDelta(o, eps = 0) {
|
|
82
|
-
return eqDelta4(intAbgr32Srgb([], this[0]), intAbgr32Srgb([], o[0]), eps);
|
|
83
|
-
}
|
|
84
124
|
}
|
|
85
125
|
declareIndex(ABGR.prototype, "value", 0);
|
|
86
126
|
const defInt = (ctor, fromSrgb) => {
|
|
87
127
|
const factory = (src, ...xs) => src == null
|
|
88
|
-
? new
|
|
128
|
+
? new ctor()
|
|
89
129
|
: isNumber(src)
|
|
90
130
|
? xs.length && xs.every(isNumber)
|
|
91
131
|
? new ctor([srgbIntArgb32([src, ...xs])])
|
|
@@ -104,7 +144,7 @@ const defInt = (ctor, fromSrgb) => {
|
|
|
104
144
|
factory.random = (rnd = SYSTEM, buf, idx, stride) => (new ctor(buf, idx, stride).set([
|
|
105
145
|
(rnd.int() & 0xffffff) | 0xff000000,
|
|
106
146
|
]));
|
|
107
|
-
factory.mapBuffer = (buf, num = buf.length, start = 0, cstride = 1, estride = 1) => mapStridedBuffer(
|
|
147
|
+
factory.mapBuffer = (buf, num = buf.length, start = 0, cstride = 1, estride = 1) => mapStridedBuffer(ctor, buf, num, start, cstride, estride);
|
|
108
148
|
return factory;
|
|
109
149
|
};
|
|
110
150
|
export const argb32 = defInt(ARGB, srgbIntArgb32);
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import { clamp01 } from "@thi.ng/math/interval";
|
|
1
2
|
/** @internal */
|
|
2
|
-
export const
|
|
3
|
+
export const __ensureAlpha = (x, def = 1) => x != undefined ? clamp01(x) : def;
|
|
4
|
+
/** @internal */
|
|
5
|
+
export const __ensureArgs = (args) => {
|
|
3
6
|
if (typeof args[0] === "number") {
|
|
4
7
|
switch (args.length) {
|
|
5
8
|
case 1:
|
package/internal/matrix-ops.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import { ReadonlyVec } from "@thi.ng/vectors";
|
|
2
|
-
import type { Color, ColorMatrix, ReadonlyColor } from "../api";
|
|
3
|
-
|
|
4
|
-
export declare const
|
|
5
|
-
|
|
1
|
+
import type { ReadonlyVec } from "@thi.ng/vectors";
|
|
2
|
+
import type { Color, ColorMatrix, ReadonlyColor } from "../api.js";
|
|
3
|
+
/** @internal */
|
|
4
|
+
export declare const __mulV33: (out: Color | null, mat: ReadonlyVec, src: ReadonlyColor, clampOut?: boolean) => import("@thi.ng/vectors").Vec;
|
|
5
|
+
/** @internal */
|
|
6
|
+
export declare const __mulV45: (out: Color | null, mat: ColorMatrix, src: ReadonlyColor, clampOut?: boolean) => import("@thi.ng/vectors").Vec;
|
|
7
|
+
/** @internal */
|
|
8
|
+
export declare const __mulM45: (a: ColorMatrix, b: ColorMatrix) => ColorMatrix;
|
|
6
9
|
//# sourceMappingURL=matrix-ops.d.ts.map
|
package/internal/matrix-ops.js
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
|
-
import { clamp01 } from "@thi.ng/math";
|
|
2
|
-
import { dotS3, dotS4
|
|
3
|
-
import {
|
|
4
|
-
|
|
1
|
+
import { clamp01 } from "@thi.ng/math/interval";
|
|
2
|
+
import { dotS3, dotS4 } from "@thi.ng/vectors/dots";
|
|
3
|
+
import { setC4 } from "@thi.ng/vectors/setc";
|
|
4
|
+
import { __ensureAlpha } from "./ensure.js";
|
|
5
|
+
/** @internal */
|
|
6
|
+
export const __mulV33 = (out, mat, src, clampOut = false) => {
|
|
5
7
|
const x = dotS3(mat, src, 0, 0, 3);
|
|
6
8
|
const y = dotS3(mat, src, 1, 0, 3);
|
|
7
9
|
const z = dotS3(mat, src, 2, 0, 3);
|
|
8
|
-
const a =
|
|
10
|
+
const a = __ensureAlpha(src[3]);
|
|
9
11
|
return clampOut
|
|
10
12
|
? setC4(out || src, clamp01(x), clamp01(y), clamp01(z), a)
|
|
11
13
|
: setC4(out || src, x, y, z, a);
|
|
12
14
|
};
|
|
13
|
-
|
|
14
|
-
|
|
15
|
+
/** @internal */
|
|
16
|
+
export const __mulV45 = (out, mat, src, clampOut = true) => {
|
|
17
|
+
out = setC4(out || src, src[0], src[1], src[2], __ensureAlpha(src[3]));
|
|
15
18
|
const x = dotS4(out, mat, 0, 0) + mat[4];
|
|
16
19
|
const y = dotS4(out, mat, 0, 5) + mat[9];
|
|
17
20
|
const z = dotS4(out, mat, 0, 10) + mat[14];
|
|
@@ -20,7 +23,8 @@ export const mulV45 = (out, mat, src, clampOut = true) => {
|
|
|
20
23
|
? setC4(out, clamp01(x), clamp01(y), clamp01(z), clamp01(w))
|
|
21
24
|
: setC4(out, x, y, z, w);
|
|
22
25
|
};
|
|
23
|
-
|
|
26
|
+
/** @internal */
|
|
27
|
+
export const __mulM45 = (a, b) => [
|
|
24
28
|
dotS4(b, a, 0, 0, 1, 5),
|
|
25
29
|
dotS4(b, a, 0, 1, 1, 5),
|
|
26
30
|
dotS4(b, a, 0, 2, 1, 5),
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { ONE3
|
|
2
|
-
import {
|
|
1
|
+
import { ONE3 } from "@thi.ng/vectors/api";
|
|
2
|
+
import { sub3 } from "@thi.ng/vectors/sub";
|
|
3
|
+
import { clamp } from "./clamp.js";
|
|
3
4
|
/**
|
|
4
5
|
* Inverts the RGB channels of an RGBA color.
|
|
5
6
|
*
|
package/is-black.d.ts
ADDED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { DEFAULT, defmulti } from "@thi.ng/defmulti";
|
|
2
|
-
import { EPS } from "
|
|
3
|
-
import { rgb } from "
|
|
1
|
+
import { DEFAULT, defmulti } from "@thi.ng/defmulti/defmulti";
|
|
2
|
+
import { EPS } from "./api/constants.js";
|
|
3
|
+
import { rgb } from "./rgb/rgb.js";
|
|
4
4
|
const isBlackHsv = (x, eps = EPS) => x[2] <= eps;
|
|
5
5
|
const isBlackRgb = (x, eps = EPS) => x[0] <= eps && x[1] <= eps && x[2] <= eps;
|
|
6
6
|
const isBlackLch = (x, eps = EPS) => x[0] <= eps;
|
|
7
|
-
export const isBlack = defmulti((x) => x.mode
|
|
8
|
-
isBlack.addAll({
|
|
7
|
+
export const isBlack = defmulti((x) => x.mode, {}, {
|
|
9
8
|
hcy: isBlackHsv,
|
|
10
9
|
hsi: isBlackHsv,
|
|
11
10
|
hsl: isBlackHsv,
|
|
@@ -15,5 +14,5 @@ isBlack.addAll({
|
|
|
15
14
|
lch: isBlackLch,
|
|
16
15
|
rgb: isBlackRgb,
|
|
17
16
|
ycc: isBlackRgb,
|
|
17
|
+
[DEFAULT]: (x) => isBlackRgb(rgb(x)),
|
|
18
18
|
});
|
|
19
|
-
isBlack.add(DEFAULT, (x) => isBlackRgb(rgb(x)));
|
package/is-gray.d.ts
ADDED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { DEFAULT, defmulti } from "@thi.ng/defmulti";
|
|
2
|
-
import { eqDelta } from "@thi.ng/math";
|
|
3
|
-
import { EPS } from "
|
|
4
|
-
import { rgb } from "
|
|
1
|
+
import { DEFAULT, defmulti } from "@thi.ng/defmulti/defmulti";
|
|
2
|
+
import { eqDelta } from "@thi.ng/math/eqdelta";
|
|
3
|
+
import { EPS } from "./api/constants.js";
|
|
4
|
+
import { rgb } from "./rgb/rgb.js";
|
|
5
5
|
const isGrayHsv = (x, eps = EPS) => x[1] <= eps;
|
|
6
6
|
const isGrayRgb = (x, eps = EPS) => eqDelta(x[0], x[1], eps) && eqDelta(x[0], x[2], eps);
|
|
7
7
|
const isGrayLab = (x, eps = EPS) => eqDelta(x[1], 0, eps) && eqDelta(x[2], 0, eps);
|
|
8
|
-
export const isGray = defmulti((x) => x.mode
|
|
9
|
-
isGray.addAll({
|
|
8
|
+
export const isGray = defmulti((x) => x.mode, {}, {
|
|
10
9
|
hcy: isGrayHsv,
|
|
11
10
|
hsi: isGrayHsv,
|
|
12
11
|
hsl: isGrayHsv,
|
|
@@ -17,5 +16,5 @@ isGray.addAll({
|
|
|
17
16
|
rgb: isGrayRgb,
|
|
18
17
|
srgb: isGrayRgb,
|
|
19
18
|
ycc: isGrayLab,
|
|
19
|
+
[DEFAULT]: (x) => isGrayRgb(rgb(x)),
|
|
20
20
|
});
|
|
21
|
-
isGray.add(DEFAULT, (x) => isGrayRgb(rgb(x)));
|
package/is-white.d.ts
ADDED
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import { DEFAULT, defmulti } from "@thi.ng/defmulti";
|
|
2
|
-
import { EPS } from "
|
|
3
|
-
import { rgb } from "
|
|
1
|
+
import { DEFAULT, defmulti } from "@thi.ng/defmulti/defmulti";
|
|
2
|
+
import { EPS } from "./api/constants.js";
|
|
3
|
+
import { rgb } from "./rgb/rgb.js";
|
|
4
4
|
const isWhiteHsv = (x, eps = EPS) => x[1] <= eps && x[2] >= 1 - eps;
|
|
5
5
|
const isWhiteRgb = (x, eps = EPS) => {
|
|
6
6
|
eps = 1 - eps;
|
|
7
7
|
return x[0] >= eps && x[1] >= eps && x[2] >= eps;
|
|
8
8
|
};
|
|
9
9
|
const isWhiteLch = (x, eps = EPS) => x[1] <= eps && x[0] >= 1 - eps;
|
|
10
|
-
export const isWhite = defmulti((x) => x.mode
|
|
11
|
-
isWhite.addAll({
|
|
10
|
+
export const isWhite = defmulti((x) => x.mode, {}, {
|
|
12
11
|
hcy: (x, eps = EPS) => x[1] <= eps && x[2] >= 1 - eps,
|
|
13
12
|
hsi: isWhiteHsv,
|
|
14
13
|
hsl: isWhiteHsv,
|
|
@@ -18,5 +17,5 @@ isWhite.addAll({
|
|
|
18
17
|
lch: isWhiteLch,
|
|
19
18
|
rgb: isWhiteRgb,
|
|
20
19
|
ycc: isWhiteLch,
|
|
20
|
+
[DEFAULT]: (x) => isWhiteRgb(rgb(x)),
|
|
21
21
|
});
|
|
22
|
-
isWhite.add(DEFAULT, (x) => isWhiteRgb(rgb(x)));
|
package/lab/lab-css.d.ts
CHANGED
package/lab/lab-css.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { clamp0 } from "@thi.ng/math";
|
|
2
|
-
import { FF, PC } from "../api/constants";
|
|
3
|
-
import {
|
|
1
|
+
import { clamp0 } from "@thi.ng/math/interval";
|
|
2
|
+
import { FF, PC } from "../api/constants.js";
|
|
3
|
+
import { __ensureAlpha } from "../internal/ensure.js";
|
|
4
4
|
/**
|
|
5
5
|
* @remarks
|
|
6
6
|
* Only supported in CSS Color Level 4 onwards
|
|
@@ -13,6 +13,6 @@ export const labCss = (src) => {
|
|
|
13
13
|
const l = PC(clamp0(src[0]));
|
|
14
14
|
const a = FF(src[1] * 100);
|
|
15
15
|
const b = FF(src[2] * 100);
|
|
16
|
-
const alpha =
|
|
16
|
+
const alpha = __ensureAlpha(src[3]);
|
|
17
17
|
return `lab(${l} ${a} ${b}` + (alpha < 1 ? `/${FF(alpha)})` : ")");
|
|
18
18
|
};
|