@woosh/meep-engine 2.98.0 → 2.98.2
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/build/meep.cjs +59 -72
- package/build/meep.min.js +1 -1
- package/build/meep.module.js +59 -72
- package/package.json +1 -1
- package/src/core/collection/set/compute_set_difference.d.ts.map +1 -1
- package/src/core/collection/set/compute_set_difference.js +8 -0
- package/src/core/collection/set/compute_set_difference.spec.d.ts +2 -0
- package/src/core/collection/set/compute_set_difference.spec.d.ts.map +1 -0
- package/src/core/collection/set/compute_set_difference.spec.js +45 -0
- package/src/core/collection/set/compute_set_intersection.d.ts +1 -0
- package/src/core/collection/set/compute_set_intersection.d.ts.map +1 -1
- package/src/core/collection/set/compute_set_intersection.js +9 -0
- package/src/core/collection/set/compute_set_intersection.spec.d.ts +2 -0
- package/src/core/collection/set/compute_set_intersection.spec.d.ts.map +1 -0
- package/src/core/collection/set/compute_set_intersection.spec.js +45 -0
- package/src/core/collection/set/set_remove.d.ts +2 -0
- package/src/core/collection/set/set_remove.d.ts.map +1 -1
- package/src/core/collection/set/set_remove.js +2 -0
- package/src/core/color/oklab/XYZ.spec.d.ts +2 -0
- package/src/core/color/oklab/XYZ.spec.d.ts.map +1 -0
- package/src/core/color/oklab/XYZ.spec.js +17 -0
- package/src/core/color/oklab/oklab_to_xyz.d.ts +9 -0
- package/src/core/color/oklab/oklab_to_xyz.d.ts.map +1 -0
- package/src/core/color/oklab/oklab_to_xyz.js +32 -0
- package/src/core/color/oklab/oklab_to_xyz.spec.d.ts +2 -0
- package/src/core/color/oklab/oklab_to_xyz.spec.d.ts.map +1 -0
- package/src/core/color/oklab/oklab_to_xyz.spec.js +31 -0
- package/src/core/color/oklab/xyz_to_oklab.d.ts +8 -0
- package/src/core/color/oklab/xyz_to_oklab.d.ts.map +1 -0
- package/src/core/color/oklab/xyz_to_oklab.js +29 -0
- package/src/core/color/oklab/xyz_to_oklab.spec.d.ts +2 -0
- package/src/core/color/oklab/xyz_to_oklab.spec.d.ts.map +1 -0
- package/src/core/color/oklab/xyz_to_oklab.spec.js +31 -0
- package/src/core/color/sRGB/linear_to_sRGB.d.ts.map +1 -1
- package/src/core/color/sRGB/linear_to_sRGB.js +16 -5
- package/src/core/color/sRGB/sRGB_to_linear.d.ts.map +1 -1
- package/src/core/color/sRGB/sRGB_to_linear.js +17 -5
- package/src/core/color/xyz/rgb_to_xyz.d.ts +1 -0
- package/src/core/color/xyz/rgb_to_xyz.d.ts.map +1 -1
- package/src/core/color/xyz/rgb_to_xyz.js +4 -3
- package/src/core/color/xyz/xyz_to_rgb.d.ts +1 -1
- package/src/core/color/xyz/xyz_to_rgb.js +4 -4
- package/src/core/events/signal/Signal.d.ts.map +1 -1
- package/src/core/events/signal/Signal.js +21 -53
- package/src/core/events/signal/SignalFlags.d.ts +0 -1
- package/src/core/events/signal/SignalFlags.js +1 -6
- package/src/core/color/hsluv/HSLuv.d.ts +0 -13
- package/src/core/color/hsluv/HSLuv.d.ts.map +0 -1
- package/src/core/color/hsluv/HSLuv.js +0 -187
package/build/meep.module.js
CHANGED
|
@@ -888,6 +888,13 @@ function m4_multiply(out, a, b) {
|
|
|
888
888
|
out[15] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
|
|
889
889
|
}
|
|
890
890
|
|
|
891
|
+
const SignalFlags = {
|
|
892
|
+
/**
|
|
893
|
+
* If set - signal will not invoke handlers when dispatched
|
|
894
|
+
*/
|
|
895
|
+
Silent: 1
|
|
896
|
+
};
|
|
897
|
+
|
|
891
898
|
/**
|
|
892
899
|
*
|
|
893
900
|
* @enum {number}
|
|
@@ -966,18 +973,6 @@ class SignalHandler {
|
|
|
966
973
|
*/
|
|
967
974
|
SignalHandler.prototype.isSignalHandler = true;
|
|
968
975
|
|
|
969
|
-
const SignalFlags = {
|
|
970
|
-
/**
|
|
971
|
-
* If set - signal will not invoke handlers when dispatched
|
|
972
|
-
*/
|
|
973
|
-
Silent: 1,
|
|
974
|
-
/**
|
|
975
|
-
* Is set at the start of the dispatch and cleared at the end
|
|
976
|
-
* @deprecated
|
|
977
|
-
*/
|
|
978
|
-
Dispatching: 2
|
|
979
|
-
};
|
|
980
|
-
|
|
981
976
|
/**
|
|
982
977
|
*
|
|
983
978
|
* @author Alex Goldring
|
|
@@ -987,6 +982,7 @@ const SignalFlags = {
|
|
|
987
982
|
|
|
988
983
|
/**
|
|
989
984
|
* Common dispatch stack
|
|
985
|
+
* @readonly
|
|
990
986
|
* @type {SignalHandler[]}
|
|
991
987
|
*/
|
|
992
988
|
const dispatch_stack = [];
|
|
@@ -999,40 +995,17 @@ let dispatch_stack_top = 0;
|
|
|
999
995
|
*/
|
|
1000
996
|
class Signal {
|
|
1001
997
|
/**
|
|
1002
|
-
*
|
|
1003
|
-
* @
|
|
1004
|
-
*/
|
|
1005
|
-
constructor() {
|
|
1006
|
-
/**
|
|
1007
|
-
* @private
|
|
1008
|
-
* @type {SignalHandler[]}
|
|
1009
|
-
*/
|
|
1010
|
-
this.handlers = [];
|
|
1011
|
-
|
|
1012
|
-
/**
|
|
1013
|
-
* Internal flag bitmask
|
|
1014
|
-
* @private
|
|
1015
|
-
* @type {number}
|
|
1016
|
-
*/
|
|
1017
|
-
this.flags = 0;
|
|
1018
|
-
}
|
|
1019
|
-
|
|
1020
|
-
/**
|
|
1021
|
-
* @deprecated
|
|
1022
|
-
* @returns {boolean}
|
|
998
|
+
* @private
|
|
999
|
+
* @type {SignalHandler[]}
|
|
1023
1000
|
*/
|
|
1024
|
-
|
|
1025
|
-
return this.getFlag(SignalFlags.Dispatching);
|
|
1026
|
-
}
|
|
1001
|
+
handlers = [];
|
|
1027
1002
|
|
|
1028
1003
|
/**
|
|
1029
|
-
*
|
|
1030
|
-
* @
|
|
1004
|
+
* Internal flag bitmask
|
|
1005
|
+
* @private
|
|
1006
|
+
* @type {number}
|
|
1031
1007
|
*/
|
|
1032
|
-
|
|
1033
|
-
this.writeFlag(SignalFlags.Dispatching, v);
|
|
1034
|
-
}
|
|
1035
|
-
|
|
1008
|
+
flags = 0;
|
|
1036
1009
|
|
|
1037
1010
|
/**
|
|
1038
1011
|
*
|
|
@@ -1094,14 +1067,15 @@ class Signal {
|
|
|
1094
1067
|
|
|
1095
1068
|
|
|
1096
1069
|
/**
|
|
1097
|
-
*
|
|
1098
|
-
* @param {function}
|
|
1070
|
+
* Checks if a given signal handler is present or not
|
|
1071
|
+
* @param {function} handler
|
|
1072
|
+
* @param {*} [thisArg] if not present, will not be considered
|
|
1099
1073
|
* @returns {boolean}
|
|
1100
1074
|
*/
|
|
1101
|
-
contains(
|
|
1075
|
+
contains(handler, thisArg) {
|
|
1102
1076
|
const handlers = this.handlers;
|
|
1103
1077
|
|
|
1104
|
-
const i = findSignalHandlerIndexByHandle(handlers,
|
|
1078
|
+
const i = findSignalHandlerIndexByHandle(handlers, handler, thisArg);
|
|
1105
1079
|
|
|
1106
1080
|
return i !== -1;
|
|
1107
1081
|
}
|
|
@@ -1123,7 +1097,7 @@ class Signal {
|
|
|
1123
1097
|
}
|
|
1124
1098
|
|
|
1125
1099
|
/**
|
|
1126
|
-
*
|
|
1100
|
+
* Handler will only be run once, it will be removed automatically after the first execution
|
|
1127
1101
|
* @param {function} h
|
|
1128
1102
|
* @param {*} [context]
|
|
1129
1103
|
*/
|
|
@@ -1170,7 +1144,9 @@ class Signal {
|
|
|
1170
1144
|
}
|
|
1171
1145
|
|
|
1172
1146
|
/**
|
|
1173
|
-
* Remove all handlers
|
|
1147
|
+
* Remove all handlers.
|
|
1148
|
+
* Please note that this will remove even all handlers, irrespective of where they were added from.
|
|
1149
|
+
* For most use cases, prefer to use {@link remove} method instead, or make use of {@link SignalBinding} if you need to keep track of multiple handlers
|
|
1174
1150
|
*/
|
|
1175
1151
|
removeAll() {
|
|
1176
1152
|
const handlers = this.handlers;
|
|
@@ -1178,6 +1154,7 @@ class Signal {
|
|
|
1178
1154
|
}
|
|
1179
1155
|
|
|
1180
1156
|
/**
|
|
1157
|
+
* NOTE: because of polymorphic call-site nature of this method, it's always better for performance to use monomorphic methods like `send0`, `send1` etc.
|
|
1181
1158
|
* @param {...*} args
|
|
1182
1159
|
*/
|
|
1183
1160
|
dispatch(...args) {
|
|
@@ -1186,13 +1163,8 @@ class Signal {
|
|
|
1186
1163
|
return;
|
|
1187
1164
|
}
|
|
1188
1165
|
|
|
1189
|
-
//mark dispatch process
|
|
1190
|
-
this.setFlag(SignalFlags.Dispatching);
|
|
1191
|
-
|
|
1192
1166
|
dispatchViaProxy(this.handlers, args);
|
|
1193
1167
|
|
|
1194
|
-
//mark end of dispatch process
|
|
1195
|
-
this.clearFlag(SignalFlags.Dispatching);
|
|
1196
1168
|
}
|
|
1197
1169
|
|
|
1198
1170
|
/**
|
|
@@ -1558,14 +1530,6 @@ class Signal {
|
|
|
1558
1530
|
dispatch_stack_top = stack_pointer;
|
|
1559
1531
|
}
|
|
1560
1532
|
|
|
1561
|
-
/**
|
|
1562
|
-
* @deprecated do not use
|
|
1563
|
-
* @returns {boolean}
|
|
1564
|
-
*/
|
|
1565
|
-
isDispatching() {
|
|
1566
|
-
return this.getFlag(SignalFlags.Dispatching);
|
|
1567
|
-
}
|
|
1568
|
-
|
|
1569
1533
|
/**
|
|
1570
1534
|
*
|
|
1571
1535
|
* @param {Signal} other
|
|
@@ -1596,7 +1560,7 @@ Signal.prototype.isSignal = true;
|
|
|
1596
1560
|
*
|
|
1597
1561
|
* @param {SignalHandler[]} handlers
|
|
1598
1562
|
* @param {function} f
|
|
1599
|
-
* @param thisArg
|
|
1563
|
+
* @param {*} [thisArg]
|
|
1600
1564
|
* @returns {number} index of the handler, or -1 if not found
|
|
1601
1565
|
*/
|
|
1602
1566
|
function findSignalHandlerIndexByHandle(handlers, f, thisArg) {
|
|
@@ -53631,7 +53595,11 @@ function rgb2uint24(r, g, b) {
|
|
|
53631
53595
|
}
|
|
53632
53596
|
|
|
53633
53597
|
function convert(c) {
|
|
53634
|
-
|
|
53598
|
+
if (c < 0.0031308) {
|
|
53599
|
+
return c * 12.92;
|
|
53600
|
+
} else {
|
|
53601
|
+
return 1.055 * (Math.pow(c, 0.4166666666666667)) - 0.055;
|
|
53602
|
+
}
|
|
53635
53603
|
}
|
|
53636
53604
|
|
|
53637
53605
|
/**
|
|
@@ -53641,10 +53609,17 @@ function convert(c) {
|
|
|
53641
53609
|
* @param {number[]|ArrayLike<number>} input
|
|
53642
53610
|
* @param {number} input_offset
|
|
53643
53611
|
*/
|
|
53644
|
-
function linear_to_sRGB(
|
|
53645
|
-
output
|
|
53646
|
-
|
|
53647
|
-
|
|
53612
|
+
function linear_to_sRGB(
|
|
53613
|
+
output, output_offset,
|
|
53614
|
+
input, input_offset
|
|
53615
|
+
) {
|
|
53616
|
+
const r = input[input_offset];
|
|
53617
|
+
const g = input[input_offset + 1];
|
|
53618
|
+
const b = input[input_offset + 2];
|
|
53619
|
+
|
|
53620
|
+
output[output_offset] = convert(r);
|
|
53621
|
+
output[output_offset + 1] = convert(g);
|
|
53622
|
+
output[output_offset + 2] = convert(b);
|
|
53648
53623
|
}
|
|
53649
53624
|
|
|
53650
53625
|
/**
|
|
@@ -53653,7 +53628,11 @@ function linear_to_sRGB(output, output_offset, input, input_offset) {
|
|
|
53653
53628
|
* @return {number|number}
|
|
53654
53629
|
*/
|
|
53655
53630
|
function convert_channel_sRGB_to_linear(c) {
|
|
53656
|
-
|
|
53631
|
+
if (c < 0.04045) {
|
|
53632
|
+
return c * 0.0773993808;
|
|
53633
|
+
} else {
|
|
53634
|
+
return Math.pow(c * 0.9478672986 + 0.0521327014, 2.4);
|
|
53635
|
+
}
|
|
53657
53636
|
}
|
|
53658
53637
|
|
|
53659
53638
|
/**
|
|
@@ -53663,10 +53642,18 @@ function convert_channel_sRGB_to_linear(c) {
|
|
|
53663
53642
|
* @param {number[]} input
|
|
53664
53643
|
* @param {number} input_offset
|
|
53665
53644
|
*/
|
|
53666
|
-
function sRGB_to_linear(
|
|
53667
|
-
output
|
|
53668
|
-
|
|
53669
|
-
|
|
53645
|
+
function sRGB_to_linear(
|
|
53646
|
+
output, output_offset,
|
|
53647
|
+
input, input_offset
|
|
53648
|
+
) {
|
|
53649
|
+
|
|
53650
|
+
const sR = input[input_offset];
|
|
53651
|
+
const sG = input[input_offset + 1];
|
|
53652
|
+
const sB = input[input_offset + 2];
|
|
53653
|
+
|
|
53654
|
+
output[output_offset] = convert_channel_sRGB_to_linear(sR);
|
|
53655
|
+
output[output_offset + 1] = convert_channel_sRGB_to_linear(sG);
|
|
53656
|
+
output[output_offset + 2] = convert_channel_sRGB_to_linear(sB);
|
|
53670
53657
|
}
|
|
53671
53658
|
|
|
53672
53659
|
/**
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compute_set_difference.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/set/compute_set_difference.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"compute_set_difference.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/set/compute_set_difference.js"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,0EA+BC"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { assert } from "../../assert.js";
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* @template T
|
|
3
5
|
* @returns Set<T>
|
|
@@ -5,6 +7,12 @@
|
|
|
5
7
|
* @param {Set<T>} b
|
|
6
8
|
*/
|
|
7
9
|
export function compute_set_difference(a, b) {
|
|
10
|
+
assert.defined(a, 'a');
|
|
11
|
+
assert.defined(b, 'b');
|
|
12
|
+
|
|
13
|
+
assert.isInstanceOf(a, Set, 'a');
|
|
14
|
+
assert.isInstanceOf(b, Set, 'b');
|
|
15
|
+
|
|
8
16
|
const result = new Set();
|
|
9
17
|
|
|
10
18
|
const a_array = Array.from(a);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compute_set_difference.spec.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/set/compute_set_difference.spec.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { compute_set_difference } from "./compute_set_difference.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @template T
|
|
5
|
+
* @param {T[]} a
|
|
6
|
+
* @param {T[]} b
|
|
7
|
+
* @return {T[]}
|
|
8
|
+
*/
|
|
9
|
+
function using_arrays(a, b) {
|
|
10
|
+
return Array.from(compute_set_difference(new Set(a), new Set(b))).sort();
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
test("empty sets", () => {
|
|
14
|
+
|
|
15
|
+
expect(using_arrays([], [])).toEqual([]);
|
|
16
|
+
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
test("empty and single element", () => {
|
|
20
|
+
|
|
21
|
+
expect(using_arrays([1], [])).toEqual([1]);
|
|
22
|
+
expect(using_arrays([], [1])).toEqual([1]);
|
|
23
|
+
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
test("no difference", () => {
|
|
27
|
+
|
|
28
|
+
expect(using_arrays([1, 2, 3], [1, 2, 3])).toEqual([]);
|
|
29
|
+
expect(using_arrays([1, 2, 3], [2, 3, 1])).toEqual([]);
|
|
30
|
+
expect(using_arrays([1, 2, 3], [3, 1, 2])).toEqual([]);
|
|
31
|
+
expect(using_arrays([1, 2, 3], [3, 2, 1])).toEqual([]);
|
|
32
|
+
expect(using_arrays([1, 2, 3], [2, 1, 3])).toEqual([]);
|
|
33
|
+
|
|
34
|
+
expect(using_arrays([2, 3, 1], [1, 2, 3])).toEqual([]);
|
|
35
|
+
expect(using_arrays([3, 1, 2], [1, 2, 3])).toEqual([]);
|
|
36
|
+
expect(using_arrays([3, 2, 1], [1, 2, 3])).toEqual([]);
|
|
37
|
+
expect(using_arrays([2, 1, 3], [1, 2, 3])).toEqual([]);
|
|
38
|
+
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
test("partial", () => {
|
|
42
|
+
|
|
43
|
+
expect(using_arrays([1, 2, 3, 7], [11, 1, 2, 3])).toEqual([11, 7]);
|
|
44
|
+
|
|
45
|
+
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compute_set_intersection.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/set/compute_set_intersection.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"compute_set_intersection.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/set/compute_set_intersection.js"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,4EAqBC"}
|
|
@@ -1,10 +1,19 @@
|
|
|
1
|
+
import { assert } from "../../assert.js";
|
|
2
|
+
|
|
1
3
|
/**
|
|
4
|
+
* Returns common elements between two sets
|
|
2
5
|
* @template T
|
|
3
6
|
* @returns Set<T>
|
|
4
7
|
* @param {Set<T>} a
|
|
5
8
|
* @param {Set<T>} b
|
|
6
9
|
*/
|
|
7
10
|
export function compute_set_intersection(a, b) {
|
|
11
|
+
assert.defined(a, 'a');
|
|
12
|
+
assert.defined(b, 'b');
|
|
13
|
+
|
|
14
|
+
assert.isInstanceOf(a, Set, 'a');
|
|
15
|
+
assert.isInstanceOf(b, Set, 'b');
|
|
16
|
+
|
|
8
17
|
const result = new Set();
|
|
9
18
|
|
|
10
19
|
const a_array = Array.from(a);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compute_set_intersection.spec.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/set/compute_set_intersection.spec.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { compute_set_intersection } from "./compute_set_intersection.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @template T
|
|
5
|
+
* @param {T[]} a
|
|
6
|
+
* @param {T[]} b
|
|
7
|
+
* @return {T[]}
|
|
8
|
+
*/
|
|
9
|
+
function using_arrays(a, b) {
|
|
10
|
+
return Array.from(compute_set_intersection(new Set(a), new Set(b))).sort();
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
test("empty sets", () => {
|
|
14
|
+
|
|
15
|
+
expect(using_arrays([], [])).toEqual([]);
|
|
16
|
+
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
test("empty and single element", () => {
|
|
20
|
+
|
|
21
|
+
expect(using_arrays([1], [])).toEqual([]);
|
|
22
|
+
expect(using_arrays([], [1])).toEqual([]);
|
|
23
|
+
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
test("no difference", () => {
|
|
27
|
+
|
|
28
|
+
expect(using_arrays([1, 2, 3], [1, 2, 3])).toEqual([1, 2, 3]);
|
|
29
|
+
expect(using_arrays([1, 2, 3], [2, 3, 1])).toEqual([1, 2, 3]);
|
|
30
|
+
expect(using_arrays([1, 2, 3], [3, 1, 2])).toEqual([1, 2, 3]);
|
|
31
|
+
expect(using_arrays([1, 2, 3], [3, 2, 1])).toEqual([1, 2, 3]);
|
|
32
|
+
expect(using_arrays([1, 2, 3], [2, 1, 3])).toEqual([1, 2, 3]);
|
|
33
|
+
|
|
34
|
+
expect(using_arrays([2, 3, 1], [1, 2, 3])).toEqual([1, 2, 3]);
|
|
35
|
+
expect(using_arrays([3, 1, 2], [1, 2, 3])).toEqual([1, 2, 3]);
|
|
36
|
+
expect(using_arrays([3, 2, 1], [1, 2, 3])).toEqual([1, 2, 3]);
|
|
37
|
+
expect(using_arrays([2, 1, 3], [1, 2, 3])).toEqual([1, 2, 3]);
|
|
38
|
+
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
test("partial", () => {
|
|
42
|
+
|
|
43
|
+
expect(using_arrays([1, 2, 3, 7], [11, 1, 2, 3])).toEqual([1, 2, 3]);
|
|
44
|
+
|
|
45
|
+
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"set_remove.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/set/set_remove.js"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"set_remove.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/set/set_remove.js"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,0DASC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"XYZ.spec.d.ts","sourceRoot":"","sources":["../../../../../src/core/color/oklab/XYZ.spec.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { oklab_to_xyz } from "./oklab_to_xyz.js";
|
|
2
|
+
import { xyz_to_oklab } from "./xyz_to_oklab.js";
|
|
3
|
+
|
|
4
|
+
test("to/from consistency", () => {
|
|
5
|
+
|
|
6
|
+
const out = [];
|
|
7
|
+
|
|
8
|
+
const sample = [0.123, 0.345, 0.457];
|
|
9
|
+
|
|
10
|
+
oklab_to_xyz(sample, out);
|
|
11
|
+
|
|
12
|
+
xyz_to_oklab(out, out);
|
|
13
|
+
|
|
14
|
+
expect(out[0]).toBeCloseTo(sample[0]);
|
|
15
|
+
expect(out[1]).toBeCloseTo(sample[1]);
|
|
16
|
+
expect(out[2]).toBeCloseTo(sample[2]);
|
|
17
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* Converts Oklab color space to CIE XYZ.
|
|
4
|
+
* Oklab as defined by Björn Ottosson
|
|
5
|
+
* @param {number[]} input Oklab
|
|
6
|
+
* @param {number[]} output XYZ
|
|
7
|
+
*/
|
|
8
|
+
export function oklab_to_xyz(input: number[], output: number[]): void;
|
|
9
|
+
//# sourceMappingURL=oklab_to_xyz.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oklab_to_xyz.d.ts","sourceRoot":"","sources":["../../../../../src/core/color/oklab/oklab_to_xyz.js"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,oCAHW,MAAM,EAAE,UACR,MAAM,EAAE,QA0BlB"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* Converts Oklab color space to CIE XYZ.
|
|
4
|
+
* Oklab as defined by Björn Ottosson
|
|
5
|
+
* @param {number[]} input Oklab
|
|
6
|
+
* @param {number[]} output XYZ
|
|
7
|
+
*/
|
|
8
|
+
export function oklab_to_xyz(input, output) {
|
|
9
|
+
const L = input[0];
|
|
10
|
+
const a = input[1];
|
|
11
|
+
const b = input[2];
|
|
12
|
+
|
|
13
|
+
// apply M2 inverse
|
|
14
|
+
|
|
15
|
+
const l_ = 0.99999999845051981432 * L + 0.39633779217376785678 * a + 0.21580375806075880339 * b;
|
|
16
|
+
const m_ = 1.0000000088817607767 * L - 0.1055613423236563494 * a - 0.063854174771705903402 * b;
|
|
17
|
+
const s_ = 1.0000000546724109177 * L - 0.089484182094965759684 * a - 1.2914855378640917399 * b;
|
|
18
|
+
|
|
19
|
+
const l = l_ * l_ * l_;
|
|
20
|
+
const m = m_ * m_ * m_;
|
|
21
|
+
const s = s_ * s_ * s_;
|
|
22
|
+
|
|
23
|
+
// apply M1 inverse
|
|
24
|
+
|
|
25
|
+
const x = 1.227013851103521026 * l - 0.5577999806518222383 * m + 0.28125614896646780758 * s;
|
|
26
|
+
const y = -0.040580178423280593977 * l + 1.1122568696168301049 * m - 0.071676678665601200577 * s;
|
|
27
|
+
const z = -0.076381284505706892869 * l - 0.42148197841801273055 * m + 1.5861632204407947575 * s;
|
|
28
|
+
|
|
29
|
+
output[0] = x;
|
|
30
|
+
output[1] = y;
|
|
31
|
+
output[2] = z;
|
|
32
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oklab_to_xyz.spec.d.ts","sourceRoot":"","sources":["../../../../../src/core/color/oklab/oklab_to_xyz.spec.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { oklab_to_xyz } from "./oklab_to_xyz.js";
|
|
2
|
+
|
|
3
|
+
test("known samples", () => {
|
|
4
|
+
|
|
5
|
+
const out = [];
|
|
6
|
+
|
|
7
|
+
oklab_to_xyz([1, 0, 0], out);
|
|
8
|
+
|
|
9
|
+
expect(out[0]).toBeCloseTo(0.950);
|
|
10
|
+
expect(out[1]).toBeCloseTo(1.000);
|
|
11
|
+
expect(out[2]).toBeCloseTo(1.089);
|
|
12
|
+
|
|
13
|
+
oklab_to_xyz([0.450, 1.236, -0.019], out);
|
|
14
|
+
|
|
15
|
+
expect(out[0]).toBeCloseTo(1);
|
|
16
|
+
expect(out[1]).toBeCloseTo(0);
|
|
17
|
+
expect(out[2]).toBeCloseTo(0);
|
|
18
|
+
|
|
19
|
+
oklab_to_xyz([0.922, -0.671, 0.263], out);
|
|
20
|
+
|
|
21
|
+
expect(out[0]).toBeCloseTo(0);
|
|
22
|
+
expect(out[1]).toBeCloseTo(1);
|
|
23
|
+
expect(out[2]).toBeCloseTo(0);
|
|
24
|
+
|
|
25
|
+
oklab_to_xyz([0.153, -1.415, -0.449], out);
|
|
26
|
+
|
|
27
|
+
expect(out[0]).toBeCloseTo(0);
|
|
28
|
+
expect(out[1]).toBeCloseTo(0);
|
|
29
|
+
expect(out[2]).toBeCloseTo(1);
|
|
30
|
+
|
|
31
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts CIE XYZ color space to Oklab.
|
|
3
|
+
* Oklab as defined by Björn Ottosson
|
|
4
|
+
* @param {number[]} input XYZ
|
|
5
|
+
* @param {number[]} output Lab
|
|
6
|
+
*/
|
|
7
|
+
export function xyz_to_oklab(input: number[], output: number[]): void;
|
|
8
|
+
//# sourceMappingURL=xyz_to_oklab.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"xyz_to_oklab.d.ts","sourceRoot":"","sources":["../../../../../src/core/color/oklab/xyz_to_oklab.js"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,oCAHW,MAAM,EAAE,UACR,MAAM,EAAE,QAwBlB"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts CIE XYZ color space to Oklab.
|
|
3
|
+
* Oklab as defined by Björn Ottosson
|
|
4
|
+
* @param {number[]} input XYZ
|
|
5
|
+
* @param {number[]} output Lab
|
|
6
|
+
*/
|
|
7
|
+
export function xyz_to_oklab(input, output) {
|
|
8
|
+
const x = input[0];
|
|
9
|
+
const y = input[1];
|
|
10
|
+
const z = input[2];
|
|
11
|
+
|
|
12
|
+
// M1 * (X Y Z)
|
|
13
|
+
const l = 0.8189330101 * x + 0.3618667424 * y - 0.1288597137 * z;
|
|
14
|
+
const m = 0.0329845436 * x + 0.9293118715 * y + 0.0361456387 * z;
|
|
15
|
+
const s = 0.0482003018 * x + 0.2643662691 * y + 0.6338517070 * z;
|
|
16
|
+
|
|
17
|
+
const l_ = Math.cbrt(l);
|
|
18
|
+
const m_ = Math.cbrt(m);
|
|
19
|
+
const s_ = Math.cbrt(s);
|
|
20
|
+
|
|
21
|
+
// M2 * (l` m` s`)
|
|
22
|
+
const L = 0.2104542553 * l_ + 0.7936177850 * m_ - 0.0040720468 * s_;
|
|
23
|
+
const a = 1.9779984951 * l_ - 2.4285922050 * m_ + 0.4505937099 * s_;
|
|
24
|
+
const b = 0.0259040371 * l_ + 0.7827717662 * m_ - 0.8086757660 * s_;
|
|
25
|
+
|
|
26
|
+
output[0] = L;
|
|
27
|
+
output[1] = a;
|
|
28
|
+
output[2] = b;
|
|
29
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"xyz_to_oklab.spec.d.ts","sourceRoot":"","sources":["../../../../../src/core/color/oklab/xyz_to_oklab.spec.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { xyz_to_oklab } from "./xyz_to_oklab.js";
|
|
2
|
+
|
|
3
|
+
test("known samples", () => {
|
|
4
|
+
|
|
5
|
+
const out = [];
|
|
6
|
+
|
|
7
|
+
xyz_to_oklab([0.950, 1.000, 1.089], out);
|
|
8
|
+
|
|
9
|
+
expect(out[0]).toBeCloseTo(1);
|
|
10
|
+
expect(out[1]).toBeCloseTo(0);
|
|
11
|
+
expect(out[2]).toBeCloseTo(0);
|
|
12
|
+
|
|
13
|
+
xyz_to_oklab([1, 0, 0], out);
|
|
14
|
+
|
|
15
|
+
expect(out[0]).toBeCloseTo(0.450);
|
|
16
|
+
expect(out[1]).toBeCloseTo(1.236);
|
|
17
|
+
expect(out[2]).toBeCloseTo(-0.019);
|
|
18
|
+
|
|
19
|
+
xyz_to_oklab([0, 1, 0], out);
|
|
20
|
+
|
|
21
|
+
expect(out[0]).toBeCloseTo(0.922);
|
|
22
|
+
expect(out[1]).toBeCloseTo(-0.671);
|
|
23
|
+
expect(out[2]).toBeCloseTo(0.263);
|
|
24
|
+
|
|
25
|
+
xyz_to_oklab([0, 0, 1], out);
|
|
26
|
+
|
|
27
|
+
expect(out[0]).toBeCloseTo(0.153);
|
|
28
|
+
expect(out[1]).toBeCloseTo(-1.415);
|
|
29
|
+
expect(out[2]).toBeCloseTo(-0.449);
|
|
30
|
+
|
|
31
|
+
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"linear_to_sRGB.d.ts","sourceRoot":"","sources":["../../../../../src/core/color/sRGB/linear_to_sRGB.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"linear_to_sRGB.d.ts","sourceRoot":"","sources":["../../../../../src/core/color/sRGB/linear_to_sRGB.js"],"names":[],"mappings":"AAQA;;;;;;GAMG;AACH,uCALW,MAAM,EAAE,GAAC,UAAU,MAAM,CAAC,iBAC1B,MAAM,SACN,MAAM,EAAE,GAAC,UAAU,MAAM,CAAC,gBAC1B,MAAM,QAahB"}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
function convert(c) {
|
|
2
|
-
|
|
2
|
+
if (c < 0.0031308) {
|
|
3
|
+
return c * 12.92;
|
|
4
|
+
} else {
|
|
5
|
+
return 1.055 * (Math.pow(c, 0.4166666666666667)) - 0.055;
|
|
6
|
+
}
|
|
3
7
|
}
|
|
4
8
|
|
|
5
9
|
/**
|
|
@@ -9,8 +13,15 @@ function convert(c) {
|
|
|
9
13
|
* @param {number[]|ArrayLike<number>} input
|
|
10
14
|
* @param {number} input_offset
|
|
11
15
|
*/
|
|
12
|
-
export function linear_to_sRGB(
|
|
13
|
-
output
|
|
14
|
-
|
|
15
|
-
|
|
16
|
+
export function linear_to_sRGB(
|
|
17
|
+
output, output_offset,
|
|
18
|
+
input, input_offset
|
|
19
|
+
) {
|
|
20
|
+
const r = input[input_offset];
|
|
21
|
+
const g = input[input_offset + 1];
|
|
22
|
+
const b = input[input_offset + 2];
|
|
23
|
+
|
|
24
|
+
output[output_offset] = convert(r);
|
|
25
|
+
output[output_offset + 1] = convert(g);
|
|
26
|
+
output[output_offset + 2] = convert(b);
|
|
16
27
|
}
|