@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sRGB_to_linear.d.ts","sourceRoot":"","sources":["../../../../../src/core/color/sRGB/sRGB_to_linear.js"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,kDAHW,MAAM,GACL,MAAM,GAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"sRGB_to_linear.d.ts","sourceRoot":"","sources":["../../../../../src/core/color/sRGB/sRGB_to_linear.js"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,kDAHW,MAAM,GACL,MAAM,GAAC,MAAM,CAQxB;AAED;;;;;;GAMG;AACH,uCALW,MAAM,EAAE,iBACR,MAAM,SACN,MAAM,EAAE,gBACR,MAAM,QAchB"}
|
|
@@ -4,7 +4,11 @@
|
|
|
4
4
|
* @return {number|number}
|
|
5
5
|
*/
|
|
6
6
|
export function convert_channel_sRGB_to_linear(c) {
|
|
7
|
-
|
|
7
|
+
if (c < 0.04045) {
|
|
8
|
+
return c * 0.0773993808;
|
|
9
|
+
} else {
|
|
10
|
+
return Math.pow(c * 0.9478672986 + 0.0521327014, 2.4);
|
|
11
|
+
}
|
|
8
12
|
}
|
|
9
13
|
|
|
10
14
|
/**
|
|
@@ -14,8 +18,16 @@ export function convert_channel_sRGB_to_linear(c) {
|
|
|
14
18
|
* @param {number[]} input
|
|
15
19
|
* @param {number} input_offset
|
|
16
20
|
*/
|
|
17
|
-
export function sRGB_to_linear(
|
|
18
|
-
output
|
|
19
|
-
|
|
20
|
-
|
|
21
|
+
export function sRGB_to_linear(
|
|
22
|
+
output, output_offset,
|
|
23
|
+
input, input_offset
|
|
24
|
+
) {
|
|
25
|
+
|
|
26
|
+
const sR = input[input_offset];
|
|
27
|
+
const sG = input[input_offset + 1];
|
|
28
|
+
const sB = input[input_offset + 2];
|
|
29
|
+
|
|
30
|
+
output[output_offset] = convert_channel_sRGB_to_linear(sR);
|
|
31
|
+
output[output_offset + 1] = convert_channel_sRGB_to_linear(sG);
|
|
32
|
+
output[output_offset + 2] = convert_channel_sRGB_to_linear(sB);
|
|
21
33
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rgb_to_xyz.d.ts","sourceRoot":"","sources":["../../../../../src/core/color/xyz/rgb_to_xyz.js"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"rgb_to_xyz.d.ts","sourceRoot":"","sources":["../../../../../src/core/color/xyz/rgb_to_xyz.js"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,yDASC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* Convert to CIE XYZ color model
|
|
2
3
|
* Assumes linear RGB space
|
|
3
4
|
* @param {vec3} out
|
|
4
5
|
* @param {vec3} input
|
|
@@ -9,7 +10,7 @@ export function rgb_to_xyz(out, input) {
|
|
|
9
10
|
const y = input[1];
|
|
10
11
|
const z = input[2];
|
|
11
12
|
|
|
12
|
-
out[0] = 0.
|
|
13
|
-
out[1] = 0.
|
|
14
|
-
out[2] = 0.
|
|
13
|
+
out[0] = 0.41239079926595948129 * x + 0.35758433938387796373 * y + 0.18048078840183428751 * z;
|
|
14
|
+
out[1] = 0.21263900587151035754 * x + 0.71516867876775592746 * y + 0.07219231536073371500 * z;
|
|
15
|
+
out[2] = 0.01933081871559185069 * x + 0.11919477979462598791 * y + 0.95053215224966058086 * z;
|
|
15
16
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* CIE color model to linear RGB
|
|
3
3
|
* @param {vec3} out
|
|
4
4
|
* @param {vec3} input
|
|
5
5
|
*/
|
|
@@ -8,7 +8,7 @@ export function xyz_to_rgb(out, input) {
|
|
|
8
8
|
const y = input[1];
|
|
9
9
|
const z = input[2];
|
|
10
10
|
|
|
11
|
-
out[0] = 3.
|
|
12
|
-
out[1] = (-0.
|
|
13
|
-
out[2] = 0.
|
|
11
|
+
out[0] = 3.24096994190452134377 * x - 1.53738317757009345794 * y - 0.49861076029300328366 * z;
|
|
12
|
+
out[1] = (-0.96924363628087982613) * x + 1.87596750150772066772 * y + 0.04155505740717561247 * z;
|
|
13
|
+
out[2] = 0.05563007969699360846 * x - 0.20397695888897656435 * y + 1.05697151424287856072 * z;
|
|
14
14
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Signal.d.ts","sourceRoot":"","sources":["../../../../../src/core/events/signal/Signal.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Signal.d.ts","sourceRoot":"","sources":["../../../../../src/core/events/signal/Signal.js"],"names":[],"mappings":"AAqlBA;;;;;;GAMG;AACH,yDALW,aAAa,EAAE,+BAGb,MAAM,CAoBlB;AAED;;;;;;GAMG;AACH,mEALW,aAAa,EAAE,0BAGb,MAAM,CAclB;AAiDD;;;;GAIG;AACH,2CAHW,aAAa,EAAE,sBA8BzB;AAjsBD;;;;GAIG;AACH;IACI;;;OAGG;IACH,iBAAc;IAEd;;;;OAIG;IACH,cAAU;IAWV;;;OAGG;IACH,yBAEC;IAfD;;;OAGG;IACH,sBAEC;IAYD;;;;OAIG;IACH,cAHW,MAAM;;KAAY,GAChB,IAAI,CAIhB;IAED;;;;OAIG;IACH,gBAHW,MAAM;;KAAY,GAChB,IAAI,CAIhB;IAED;;;;OAIG;IACH,gBAHW,MAAM;;KAAY,SAClB,OAAO,QAQjB;IAED;;;;OAIG;IACH,cAHW,MAAM;;KAAY,GAChB,OAAO,CAInB;IAGD;;;;;OAKG;IACH,4CAFa,OAAO,CAQnB;IAED,aAEC;IAED,eAEC;IAED;;;OAGG;IACH,eAFa,OAAO,CAInB;IAED;;;;OAIG;IACH,yCAQC;IAED;;;;OAIG;IACH,sCAYC;IAED;;;;;OAKG;IACH,oCAFa,OAAO,CAUnB;IAED;;;;OAIG;IACH,kBAGC;IAED;;;OAGG;IACH,+BAQC;IAED;;;OAGG;IACH,cA4CC;IAED;;;;OAIG;IACH,sBA6CC;IAED;;;;OAIG;IACH,4BA4CC;IAED;;;;;OAKG;IACH,oCA4CC;IAED;;;;;;OAMG;IACH,4CA4CC;IAED;;;;;;;;OAQG;IACH,4DA4CC;IAED;;;;;;;;;;OAUG;IACH,4EA4CC;IAED;;;;OAIG;IACH,aAHW,MAAM,GACJ,MAAM,CAalB;IAIL;;;OAGG;IACH,mBAFU,OAAO,CAEQ;CAPxB;;8BAnkBiD,oBAAoB"}
|
|
@@ -6,11 +6,12 @@
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
import { assert } from "../../assert.js";
|
|
9
|
-
import { SignalHandler, SignalHandlerFlags } from "./SignalHandler.js";
|
|
10
9
|
import { SignalFlags } from "./SignalFlags.js";
|
|
10
|
+
import { SignalHandler, SignalHandlerFlags } from "./SignalHandler.js";
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Common dispatch stack
|
|
14
|
+
* @readonly
|
|
14
15
|
* @type {SignalHandler[]}
|
|
15
16
|
*/
|
|
16
17
|
const dispatch_stack = [];
|
|
@@ -23,42 +24,17 @@ let dispatch_stack_top = 0;
|
|
|
23
24
|
*/
|
|
24
25
|
export class Signal {
|
|
25
26
|
/**
|
|
26
|
-
*
|
|
27
|
-
* @
|
|
27
|
+
* @private
|
|
28
|
+
* @type {SignalHandler[]}
|
|
28
29
|
*/
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* @private
|
|
32
|
-
* @type {SignalHandler[]}
|
|
33
|
-
*/
|
|
34
|
-
this.handlers = [];
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Internal flag bitmask
|
|
38
|
-
* @private
|
|
39
|
-
* @type {number}
|
|
40
|
-
*/
|
|
41
|
-
this.flags = 0;
|
|
42
|
-
}
|
|
30
|
+
handlers = [];
|
|
43
31
|
|
|
44
32
|
/**
|
|
45
|
-
*
|
|
46
|
-
* @
|
|
33
|
+
* Internal flag bitmask
|
|
34
|
+
* @private
|
|
35
|
+
* @type {number}
|
|
47
36
|
*/
|
|
48
|
-
|
|
49
|
-
console.warn('deprecated, use .isDispatching instead');
|
|
50
|
-
return this.getFlag(SignalFlags.Dispatching);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* @deprecated
|
|
55
|
-
* @param {boolean} v
|
|
56
|
-
*/
|
|
57
|
-
set dispatching(v) {
|
|
58
|
-
console.warn('deprecated, flag should not be written to from outside of the signal');
|
|
59
|
-
this.writeFlag(SignalFlags.Dispatching, v);
|
|
60
|
-
}
|
|
61
|
-
|
|
37
|
+
flags = 0;
|
|
62
38
|
|
|
63
39
|
/**
|
|
64
40
|
*
|
|
@@ -120,14 +96,15 @@ export class Signal {
|
|
|
120
96
|
|
|
121
97
|
|
|
122
98
|
/**
|
|
123
|
-
*
|
|
124
|
-
* @param {function}
|
|
99
|
+
* Checks if a given signal handler is present or not
|
|
100
|
+
* @param {function} handler
|
|
101
|
+
* @param {*} [thisArg] if not present, will not be considered
|
|
125
102
|
* @returns {boolean}
|
|
126
103
|
*/
|
|
127
|
-
contains(
|
|
104
|
+
contains(handler, thisArg) {
|
|
128
105
|
const handlers = this.handlers;
|
|
129
106
|
|
|
130
|
-
const i = findSignalHandlerIndexByHandle(handlers,
|
|
107
|
+
const i = findSignalHandlerIndexByHandle(handlers, handler, thisArg);
|
|
131
108
|
|
|
132
109
|
return i !== -1;
|
|
133
110
|
}
|
|
@@ -149,7 +126,7 @@ export class Signal {
|
|
|
149
126
|
}
|
|
150
127
|
|
|
151
128
|
/**
|
|
152
|
-
*
|
|
129
|
+
* Handler will only be run once, it will be removed automatically after the first execution
|
|
153
130
|
* @param {function} h
|
|
154
131
|
* @param {*} [context]
|
|
155
132
|
*/
|
|
@@ -199,7 +176,10 @@ export class Signal {
|
|
|
199
176
|
}
|
|
200
177
|
|
|
201
178
|
/**
|
|
202
|
-
* Remove all handlers
|
|
179
|
+
* Remove all handlers.
|
|
180
|
+
* Please note that this will remove even all handlers, irrespective of where they were added from.
|
|
181
|
+
* 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
|
|
182
|
+
* NOTE: Consider removeAll to be unsafe
|
|
203
183
|
*/
|
|
204
184
|
removeAll() {
|
|
205
185
|
const handlers = this.handlers;
|
|
@@ -207,6 +187,7 @@ export class Signal {
|
|
|
207
187
|
}
|
|
208
188
|
|
|
209
189
|
/**
|
|
190
|
+
* NOTE: because of polymorphic call-site nature of this method, it's always better for performance to use monomorphic methods like `send0`, `send1` etc.
|
|
210
191
|
* @param {...*} args
|
|
211
192
|
*/
|
|
212
193
|
dispatch(...args) {
|
|
@@ -215,13 +196,8 @@ export class Signal {
|
|
|
215
196
|
return;
|
|
216
197
|
}
|
|
217
198
|
|
|
218
|
-
//mark dispatch process
|
|
219
|
-
this.setFlag(SignalFlags.Dispatching);
|
|
220
|
-
|
|
221
199
|
dispatchViaProxy(this.handlers, args);
|
|
222
200
|
|
|
223
|
-
//mark end of dispatch process
|
|
224
|
-
this.clearFlag(SignalFlags.Dispatching);
|
|
225
201
|
}
|
|
226
202
|
|
|
227
203
|
/**
|
|
@@ -594,14 +570,6 @@ export class Signal {
|
|
|
594
570
|
dispatch_stack_top = stack_pointer;
|
|
595
571
|
}
|
|
596
572
|
|
|
597
|
-
/**
|
|
598
|
-
* @deprecated do not use
|
|
599
|
-
* @returns {boolean}
|
|
600
|
-
*/
|
|
601
|
-
isDispatching() {
|
|
602
|
-
return this.getFlag(SignalFlags.Dispatching);
|
|
603
|
-
}
|
|
604
|
-
|
|
605
573
|
/**
|
|
606
574
|
*
|
|
607
575
|
* @param {Signal} other
|
|
@@ -632,7 +600,7 @@ Signal.prototype.isSignal = true;
|
|
|
632
600
|
*
|
|
633
601
|
* @param {SignalHandler[]} handlers
|
|
634
602
|
* @param {function} f
|
|
635
|
-
* @param thisArg
|
|
603
|
+
* @param {*} [thisArg]
|
|
636
604
|
* @returns {number} index of the handler, or -1 if not found
|
|
637
605
|
*/
|
|
638
606
|
export function findSignalHandlerIndexByHandle(handlers, f, thisArg) {
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
*
|
|
3
|
-
* @param {number[]} input
|
|
4
|
-
* @param {number[]} output
|
|
5
|
-
*/
|
|
6
|
-
export function rgb2hsluv(input: number[], output: number[]): void;
|
|
7
|
-
/**
|
|
8
|
-
*
|
|
9
|
-
* @param {number[]} input
|
|
10
|
-
* @param {number[]} output
|
|
11
|
-
*/
|
|
12
|
-
export function hsluv2rgb(input: number[], output: number[]): void;
|
|
13
|
-
//# sourceMappingURL=HSLuv.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"HSLuv.d.ts","sourceRoot":"","sources":["../../../../../src/core/color/hsluv/HSLuv.js"],"names":[],"mappings":"AAkKA;;;;GAIG;AACH,iCAHW,MAAM,EAAE,UACR,MAAM,EAAE,QAOlB;AAED;;;;GAIG;AACH,iCAHW,MAAM,EAAE,UACR,MAAM,EAAE,QAOlB"}
|
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @see https://github.com/hsluv/hsluv-c/blob/master/src/hsluv.c
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
const temp_0 = new Float32Array(3);
|
|
6
|
-
const temp_1 = new Float32Array(3);
|
|
7
|
-
/* for RGB */
|
|
8
|
-
const m = new Float32Array([
|
|
9
|
-
3.24096994190452134377, -1.53738317757009345794, -0.49861076029300328366,
|
|
10
|
-
-0.96924363628087982613, 1.87596750150772066772, 0.04155505740717561247,
|
|
11
|
-
0.05563007969699360846, -0.20397695888897656435, 1.05697151424287856072
|
|
12
|
-
]);
|
|
13
|
-
|
|
14
|
-
/* for XYZ */
|
|
15
|
-
const m_inv = new Float32Array([
|
|
16
|
-
0.41239079926595948129, 0.35758433938387796373, 0.18048078840183428751,
|
|
17
|
-
0.21263900587151035754, 0.71516867876775592746, 0.07219231536073371500,
|
|
18
|
-
0.01933081871559185069, 0.11919477979462598791, 0.95053215224966058086
|
|
19
|
-
]);
|
|
20
|
-
|
|
21
|
-
function dot_product(t1, offset_1, t2, offset_2) {
|
|
22
|
-
return t1[offset_1] * t2[offset_2] + t1[offset_1 + 1] * t2[offset_2 + 1] + t1[offset_1 + 2] * t2[offset_2 + 2];
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/* Used for rgb conversions */
|
|
26
|
-
|
|
27
|
-
function from_linear(c) {
|
|
28
|
-
if (c <= 0.0031308)
|
|
29
|
-
return 12.92 * c;
|
|
30
|
-
else
|
|
31
|
-
return 1.055 * Math.pow(c, 1.0 / 2.4) - 0.055;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
function to_linear(c) {
|
|
35
|
-
if (c > 0.04045)
|
|
36
|
-
return Math.pow((c + 0.055) / 1.055, 2.4);
|
|
37
|
-
else
|
|
38
|
-
return c / 12.92;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const ref_u = 0.19783000664283680764;
|
|
42
|
-
const ref_v = 0.46831999493879100370;
|
|
43
|
-
|
|
44
|
-
const kappa = 903.29629629629629629630;
|
|
45
|
-
const epsilon = 0.00885645167903563082;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
*
|
|
50
|
-
* @param {number} theta
|
|
51
|
-
* @param {number[]|Float32Array} line
|
|
52
|
-
* @param {number} line_address
|
|
53
|
-
* @return {number}
|
|
54
|
-
*/
|
|
55
|
-
function ray_length_until_intersect(theta, line, line_address) {
|
|
56
|
-
return line[line_address + 1] / (Math.sin(theta) - line[line_address] * Math.cos(theta));
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function get_bounds( l, bounds)
|
|
60
|
-
{
|
|
61
|
-
const tl = l + 16.0;
|
|
62
|
-
const sub1 = (tl * tl * tl) / 1560896.0;
|
|
63
|
-
const sub2 = (sub1 > epsilon ? sub1 : (l / kappa));
|
|
64
|
-
let channel;
|
|
65
|
-
let t;
|
|
66
|
-
|
|
67
|
-
for(channel = 0; channel < 3; channel++) {
|
|
68
|
-
const ch3 = channel*3;
|
|
69
|
-
let m1 = m[ch3];
|
|
70
|
-
let m2 = m[ch3+1];
|
|
71
|
-
let m3 = m[ch3+2];
|
|
72
|
-
|
|
73
|
-
for (t = 0; t < 2; t++) {
|
|
74
|
-
const top1 = (284517.0 * m1 - 94839.0 * m3) * sub2;
|
|
75
|
-
const top2 = (838422.0 * m3 + 769860.0 * m2 + 731718.0 * m1) * l * sub2 - 769860.0 * t * l;
|
|
76
|
-
const bottom = (632260.0 * m3 - 126452.0 * m2) * sub2 + 126452.0 * t;
|
|
77
|
-
|
|
78
|
-
const bounds_index = channel * 2 + t;
|
|
79
|
-
const bounds_address = bounds_index*2;
|
|
80
|
-
|
|
81
|
-
bounds[bounds_address] = top1 / bottom;
|
|
82
|
-
bounds[bounds_address] = top2 / bottom;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
function max_chroma_for_lh(l, h) {
|
|
88
|
-
let min_len = Infinity;
|
|
89
|
-
const hrad = h * 0.01745329251994329577; /* (2 * pi / 360) */
|
|
90
|
-
const bounds = new Float32Array(12);
|
|
91
|
-
let i;
|
|
92
|
-
|
|
93
|
-
get_bounds(l, bounds);
|
|
94
|
-
|
|
95
|
-
for (i = 0; i < 6; i++) {
|
|
96
|
-
const len = ray_length_until_intersect(hrad, bounds, i * 2);
|
|
97
|
-
|
|
98
|
-
if (len >= 0 && len < min_len)
|
|
99
|
-
min_len = len;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
return min_len;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
function hsluv2lch(input, output) {
|
|
106
|
-
let h = input[0];
|
|
107
|
-
const s = input[1];
|
|
108
|
-
const l = input[2];
|
|
109
|
-
let c;
|
|
110
|
-
|
|
111
|
-
/* White and black: disambiguate chroma */
|
|
112
|
-
if (l > 99.9999999 || l < 0.00000001)
|
|
113
|
-
c = 0.0;
|
|
114
|
-
else
|
|
115
|
-
c = max_chroma_for_lh(l, h) / 100.0 * s;
|
|
116
|
-
|
|
117
|
-
/* Grays: disambiguate hue */
|
|
118
|
-
if (s < 0.00000001)
|
|
119
|
-
h = 0.0;
|
|
120
|
-
|
|
121
|
-
output[0] = l;
|
|
122
|
-
output[1] = c;
|
|
123
|
-
output[2] = h;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
function lch2luv(input, output) {
|
|
127
|
-
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
function luv2xyz(input, output) {
|
|
131
|
-
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
function xyz2rgb(input, output) {
|
|
135
|
-
const r = from_linear(dot_product(m, 0, input, 0));
|
|
136
|
-
|
|
137
|
-
const g = from_linear(dot_product(m, 3, input, 0));
|
|
138
|
-
|
|
139
|
-
const b = from_linear(dot_product(m, 6, input, 0));
|
|
140
|
-
|
|
141
|
-
output[0] = r;
|
|
142
|
-
output[1] = g;
|
|
143
|
-
output[2] = b;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
function rgb2xyz(input, output) {
|
|
147
|
-
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
function xyz2luv(input, output) {
|
|
151
|
-
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
function luv2lch(input, output) {
|
|
155
|
-
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
function lch2hsluv(input, output) {
|
|
159
|
-
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
/**
|
|
164
|
-
*
|
|
165
|
-
* @param {number[]} input
|
|
166
|
-
* @param {number[]} output
|
|
167
|
-
*/
|
|
168
|
-
export function rgb2hsluv(input, output) {
|
|
169
|
-
rgb2xyz(input, temp_0);
|
|
170
|
-
xyz2luv(temp_0, temp_1);
|
|
171
|
-
luv2lch(temp_1, temp_0);
|
|
172
|
-
lch2hsluv(temp_0, output);
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
/**
|
|
176
|
-
*
|
|
177
|
-
* @param {number[]} input
|
|
178
|
-
* @param {number[]} output
|
|
179
|
-
*/
|
|
180
|
-
export function hsluv2rgb(input, output) {
|
|
181
|
-
hsluv2lch(input, temp_0);
|
|
182
|
-
lch2luv(temp_0, temp_1);
|
|
183
|
-
luv2xyz(temp_1, temp_0);
|
|
184
|
-
xyz2rgb(temp_0, output);
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
|