@3dsource/utils 1.0.4 → 1.0.5
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/fesm2022/3dsource-utils.mjs +1793 -0
- package/fesm2022/3dsource-utils.mjs.map +1 -0
- package/index.d.ts +5 -0
- package/{src/lib/color/CMYKtoRGB.ts → lib/color/CMYKtoRGB.d.ts} +1 -11
- package/lib/color/HEXtoRGB.d.ts +5 -0
- package/lib/color/HSVtoRGB.d.ts +21 -0
- package/{src/lib/color/RGBtoCMYK.ts → lib/color/RGBtoCMYK.d.ts} +1 -31
- package/lib/color/RGBtoHEX.d.ts +1 -0
- package/lib/color/RGBtoHSV.d.ts +19 -0
- package/lib/color/hsv.d.ts +1 -0
- package/lib/color/max.d.ts +1 -0
- package/lib/color/min.d.ts +1 -0
- package/lib/color/overlay.d.ts +1 -0
- package/{src/lib/color/rgb.ts → lib/color/rgb.d.ts} +1 -3
- package/lib/color/sub.d.ts +1 -0
- package/lib/color/subtract.d.ts +1 -0
- package/lib/color/sum.d.ts +1 -0
- package/{src/lib/color/toRGB.ts → lib/color/toRGB.d.ts} +1 -7
- package/lib/color/toRGBA.d.ts +1 -0
- package/lib/constants/color-codes.constant.d.ts +9 -0
- package/lib/csv/CSV2Array.d.ts +1 -0
- package/lib/csv/CSV2Records.d.ts +1 -0
- package/lib/csv/ObjectToCSV.d.ts +1 -0
- package/lib/dev/dev3d.d.ts +1 -0
- package/lib/dev/logger.d.ts +11 -0
- package/lib/dev/timeToString.d.ts +5 -0
- package/lib/filenaming/cleanupFileName.d.ts +1 -0
- package/lib/filenaming/makePath.d.ts +1 -0
- package/lib/filenaming/normalizePath.d.ts +1 -0
- package/lib/geom/expandOverRectangle.d.ts +2 -0
- package/lib/geom/fitIntoRectangle.d.ts +2 -0
- package/{src/lib/geom/interfaces/area.interface.ts → lib/geom/interfaces/area.interface.d.ts} +1 -2
- package/{src/lib/geom/interfaces/rect.interface.ts → lib/geom/interfaces/rect.interface.d.ts} +2 -2
- package/lib/geom/interfaces/size.interface.d.ts +4 -0
- package/lib/geom/interfaces//321/201oords.interface.d.ts +4 -0
- package/lib/helpers/BatchLoader.d.ts +47 -0
- package/lib/helpers/KeyboardNumericCode.d.ts +103 -0
- package/lib/helpers/serialize.d.ts +1 -0
- package/lib/helpers/sleep.d.ts +1 -0
- package/lib/helpers/trimLastSlashFromUrl.d.ts +1 -0
- package/lib/image/SaveImage.d.ts +18 -0
- package/lib/image/getCanvasCached.d.ts +4 -0
- package/lib/image/getSnapshot.d.ts +2 -0
- package/lib/image/loadImage.d.ts +1 -0
- package/lib/interfaces/image-output.d.ts +7 -0
- package/{src/lib/interfaces/load-args-tmp.interface.ts → lib/interfaces/load-args-tmp.interface.d.ts} +1 -2
- package/lib/interfaces/load-args.interface.d.ts +15 -0
- package/{src/lib/math/baseSortedIndex.ts → lib/math/baseSortedIndex.d.ts} +1 -19
- package/{src/lib/math/calculateMedian.ts → lib/math/calculateMedian.d.ts} +1 -17
- package/{src/lib/math/circularIndex.ts → lib/math/circularIndex.d.ts} +1 -5
- package/lib/math/clampf.d.ts +8 -0
- package/lib/math/degrees.d.ts +2 -0
- package/{src/lib/math/floatCompare.ts → lib/math/floatCompare.d.ts} +3 -30
- package/{src/lib/math/inverseLerp.ts → lib/math/inverseLerp.d.ts} +1 -22
- package/lib/math/lerp.d.ts +7 -0
- package/{src/lib/mutex/Mutex.ts → lib/mutex/Mutex.d.ts} +8 -15
- package/{src/lib/mutex/Semaphore.ts → lib/mutex/Semaphore.d.ts} +7 -27
- package/lib/mutex/TaskRunner.d.ts +5 -0
- package/lib/predicates/BooleanPredictors.d.ts +27 -0
- package/{src/lib/predicates/textForSearch.ts → lib/predicates/textForSearch.d.ts} +1 -17
- package/{src/lib/predicates/where.ts → lib/predicates/where.d.ts} +2 -32
- package/lib/rxjs/leadingTrailingDebounceTime.d.ts +15 -0
- package/{src/lib/rxjs/smoothTransition.ts → lib/rxjs/smoothTransition.d.ts} +1 -19
- package/lib/rxjs/tapLog.d.ts +2 -0
- package/lib/strings/pad.d.ts +8 -0
- package/package.json +13 -2
- package/eslint.config.js +0 -37
- package/ng-package.json +0 -7
- package/src/lib/color/HEXtoRGB.ts +0 -9
- package/src/lib/color/HSVtoRGB.ts +0 -82
- package/src/lib/color/RGBtoHEX.ts +0 -17
- package/src/lib/color/RGBtoHSV.ts +0 -53
- package/src/lib/color/hsv.ts +0 -14
- package/src/lib/color/max.ts +0 -18
- package/src/lib/color/min.ts +0 -18
- package/src/lib/color/overlay.ts +0 -25
- package/src/lib/color/sub.ts +0 -18
- package/src/lib/color/subtract.ts +0 -27
- package/src/lib/color/sum.ts +0 -19
- package/src/lib/color/toRGBA.ts +0 -8
- package/src/lib/constants/color-codes.constant.ts +0 -9
- package/src/lib/csv/CSV2Array.ts +0 -66
- package/src/lib/csv/CSV2Records.ts +0 -56
- package/src/lib/csv/ObjectToCSV.ts +0 -21
- package/src/lib/dev/dev3d.ts +0 -1
- package/src/lib/dev/logger.ts +0 -94
- package/src/lib/dev/timeToString.ts +0 -16
- package/src/lib/filenaming/cleanupFileName.ts +0 -18
- package/src/lib/filenaming/makePath.ts +0 -5
- package/src/lib/filenaming/normalizePath.ts +0 -9
- package/src/lib/geom/expandOverRectangle.ts +0 -17
- package/src/lib/geom/fitIntoRectangle.ts +0 -43
- package/src/lib/geom/interfaces/size.interface.ts +0 -4
- package/src/lib/geom/interfaces//321/201oords.interface.ts +0 -4
- package/src/lib/helpers/BatchLoader.ts +0 -243
- package/src/lib/helpers/KeyboardNumericCode.ts +0 -118
- package/src/lib/helpers/serialize.ts +0 -11
- package/src/lib/helpers/sleep.ts +0 -3
- package/src/lib/helpers/trimLastSlashFromUrl.ts +0 -9
- package/src/lib/image/SaveImage.ts +0 -65
- package/src/lib/image/getCanvasCached.ts +0 -16
- package/src/lib/image/getSnapshot.ts +0 -99
- package/src/lib/image/loadImage.ts +0 -13
- package/src/lib/interfaces/image-output.ts +0 -8
- package/src/lib/interfaces/load-args.interface.ts +0 -15
- package/src/lib/math/clampf.ts +0 -14
- package/src/lib/math/degrees.ts +0 -7
- package/src/lib/math/lerp.ts +0 -12
- package/src/lib/mutex/TaskRunner.ts +0 -26
- package/src/lib/predicates/BooleanPredictors.ts +0 -47
- package/src/lib/rxjs/leadingTrailingDebounceTime.ts +0 -86
- package/src/lib/rxjs/tapLog.ts +0 -13
- package/src/lib/strings/pad.ts +0 -18
- package/tsconfig.lib.json +0 -13
- package/tsconfig.lib.prod.json +0 -11
- /package/{src/lib/color/index.ts → lib/color/index.d.ts} +0 -0
- /package/{src/lib/constants/index.ts → lib/constants/index.d.ts} +0 -0
- /package/{src/lib/csv/index.ts → lib/csv/index.d.ts} +0 -0
- /package/{src/lib/dev/index.ts → lib/dev/index.d.ts} +0 -0
- /package/{src/lib/filenaming/index.ts → lib/filenaming/index.d.ts} +0 -0
- /package/{src/lib/geom/index.ts → lib/geom/index.d.ts} +0 -0
- /package/{src/lib/geom/interfaces/index.ts → lib/geom/interfaces/index.d.ts} +0 -0
- /package/{src/lib/helpers/index.ts → lib/helpers/index.d.ts} +0 -0
- /package/{src/lib/image/index.ts → lib/image/index.d.ts} +0 -0
- /package/{src/lib/interfaces/index.ts → lib/interfaces/index.d.ts} +0 -0
- /package/{src/lib/math/index.ts → lib/math/index.d.ts} +0 -0
- /package/{src/lib/mutex/index.ts → lib/mutex/index.d.ts} +0 -0
- /package/{src/lib/predicates/index.ts → lib/predicates/index.d.ts} +0 -0
- /package/{src/lib/rxjs/index.ts → lib/rxjs/index.d.ts} +0 -0
- /package/{src/lib/strings/index.ts → lib/strings/index.d.ts} +0 -0
- /package/{src/public-api.ts → public-api.d.ts} +0 -0
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
/* eslint-disable prefer-const */
|
|
2
|
-
/**
|
|
3
|
-
* HSV from each of the RGB values to determine a return as an any[].
|
|
4
|
-
* RGB values are as follows.
|
|
5
|
-
* R - a number from 0 to 255
|
|
6
|
-
* G - a number from 0 to 255
|
|
7
|
-
* B - a number from 0 to 255
|
|
8
|
-
*
|
|
9
|
-
* HSV values are as follows.
|
|
10
|
-
* H - a number between 360-0
|
|
11
|
-
* S - number between 0 and 1.0
|
|
12
|
-
* V - number between 0 and 1.0
|
|
13
|
-
*
|
|
14
|
-
* H is replaced with equivalent numbers in the range of the 360-0 that is out of range.
|
|
15
|
-
* Cannot compute, including alpha.
|
|
16
|
-
*
|
|
17
|
-
* @ Param h hue (Hue) number that indicates (to 360-0)
|
|
18
|
-
* @ Param s the saturation (Saturation) shows the number (0.0 to 1.0)
|
|
19
|
-
* @ Param v lightness (Value) indicates the number (0.0 to 1.0)
|
|
20
|
-
* @ Return RGB values into an any[] of [R, G, B]
|
|
21
|
-
**/
|
|
22
|
-
|
|
23
|
-
export function HSVtoRGB(h: number, s: number, v: number): number[] {
|
|
24
|
-
let r = 0,
|
|
25
|
-
g = 0,
|
|
26
|
-
b = 0;
|
|
27
|
-
let i, x, y, z;
|
|
28
|
-
if (s < 0) {
|
|
29
|
-
s = 0;
|
|
30
|
-
}
|
|
31
|
-
if (s > 1) {
|
|
32
|
-
s = 1;
|
|
33
|
-
}
|
|
34
|
-
if (v < 0) {
|
|
35
|
-
v = 0;
|
|
36
|
-
}
|
|
37
|
-
if (v > 1) {
|
|
38
|
-
v = 1;
|
|
39
|
-
}
|
|
40
|
-
h = h % 360;
|
|
41
|
-
if (h < 0) {
|
|
42
|
-
h += 360;
|
|
43
|
-
}
|
|
44
|
-
h /= 60;
|
|
45
|
-
i = h >> 0;
|
|
46
|
-
x = v * (1 - s);
|
|
47
|
-
y = v * (1 - s * (h - i));
|
|
48
|
-
z = v * (1 - s * (1 - h + i));
|
|
49
|
-
switch (i) {
|
|
50
|
-
case 0:
|
|
51
|
-
r = v;
|
|
52
|
-
g = z;
|
|
53
|
-
b = x;
|
|
54
|
-
break;
|
|
55
|
-
case 1:
|
|
56
|
-
r = y;
|
|
57
|
-
g = v;
|
|
58
|
-
b = x;
|
|
59
|
-
break;
|
|
60
|
-
case 2:
|
|
61
|
-
r = x;
|
|
62
|
-
g = v;
|
|
63
|
-
b = z;
|
|
64
|
-
break;
|
|
65
|
-
case 3:
|
|
66
|
-
r = x;
|
|
67
|
-
g = y;
|
|
68
|
-
b = v;
|
|
69
|
-
break;
|
|
70
|
-
case 4:
|
|
71
|
-
r = z;
|
|
72
|
-
g = x;
|
|
73
|
-
b = v;
|
|
74
|
-
break;
|
|
75
|
-
case 5:
|
|
76
|
-
r = v;
|
|
77
|
-
g = x;
|
|
78
|
-
b = y;
|
|
79
|
-
break;
|
|
80
|
-
}
|
|
81
|
-
return [(r * 255) >> 0, (g * 255) >> 0, (b * 255) >> 0];
|
|
82
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export function RGBtoHEX(r: number, g: number, b: number): string {
|
|
2
|
-
let redColor = r.toString(16);
|
|
3
|
-
let greenColor = g.toString(16);
|
|
4
|
-
let blackColor = b.toString(16);
|
|
5
|
-
|
|
6
|
-
if (redColor.length === 1) {
|
|
7
|
-
redColor = '0' + redColor;
|
|
8
|
-
}
|
|
9
|
-
if (greenColor.length === 1) {
|
|
10
|
-
greenColor = '0' + greenColor;
|
|
11
|
-
}
|
|
12
|
-
if (blackColor.length === 1) {
|
|
13
|
-
blackColor = '0' + blackColor;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
return (redColor + greenColor + blackColor).toUpperCase();
|
|
17
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* RGB from the respective figures, HSV sequences in terms of returns.
|
|
3
|
-
* RGB values are as follows.
|
|
4
|
-
* R - a number from 0 to 255
|
|
5
|
-
* G - a number from 0 to 255
|
|
6
|
-
* B - a number from 0 to 255
|
|
7
|
-
*
|
|
8
|
-
* HSV values are as follows.
|
|
9
|
-
* H - a number between 360-0
|
|
10
|
-
* S - number between 0 and 1.0
|
|
11
|
-
* V - number between 0 and 1.0
|
|
12
|
-
*
|
|
13
|
-
* Cannot compute, including alpha.
|
|
14
|
-
* @ Param r the red (R) indicating the number (0x00 to 0xFF to)
|
|
15
|
-
* @ Param g green (G) indicates the number (0x00 to 0xFF to)
|
|
16
|
-
* @ Param b blue (B) shows the number (0x00 to 0xFF to)
|
|
17
|
-
* @ Return HSV values into an any[] of [H, S, V]
|
|
18
|
-
**/
|
|
19
|
-
export function RGBtoHSV(r: number, g: number, b: number): number[] {
|
|
20
|
-
r /= 255;
|
|
21
|
-
g /= 255;
|
|
22
|
-
b /= 255;
|
|
23
|
-
let h = 0,
|
|
24
|
-
s = 0,
|
|
25
|
-
v = 0;
|
|
26
|
-
let x: number, y: number;
|
|
27
|
-
if (r >= g) x = r;
|
|
28
|
-
else x = g;
|
|
29
|
-
if (b > x) x = b;
|
|
30
|
-
if (r <= g) y = r;
|
|
31
|
-
else y = g;
|
|
32
|
-
if (b < y) y = b;
|
|
33
|
-
v = x;
|
|
34
|
-
const c: number = x - y;
|
|
35
|
-
if (x === 0) s = 0;
|
|
36
|
-
else s = c / x;
|
|
37
|
-
if (s !== 0) {
|
|
38
|
-
if (r === x) {
|
|
39
|
-
h = (g - b) / c;
|
|
40
|
-
} else {
|
|
41
|
-
if (g === x) {
|
|
42
|
-
h = 2 + (b - r) / c;
|
|
43
|
-
} else {
|
|
44
|
-
if (b === x) {
|
|
45
|
-
h = 4 + (r - g) / c;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
h = h * 60;
|
|
50
|
-
if (h < 0) h = h + 360;
|
|
51
|
-
}
|
|
52
|
-
return [h, s, v];
|
|
53
|
-
}
|
package/src/lib/color/hsv.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/* eslint-disable prefer-spread */
|
|
2
|
-
/**
|
|
3
|
-
* HSV calculated from the numbers of each RGB color value.
|
|
4
|
-
* @ Param h hue (Hue) number that indicates (to 360-0)
|
|
5
|
-
* @ Param s the saturation (Saturation) shows the number (0.0 to 1.0)
|
|
6
|
-
* @ Param v lightness (Value) indicates the number (0.0 to 1.0)
|
|
7
|
-
* @ Return obtained from the RGB color value for each indicating the number
|
|
8
|
-
**/
|
|
9
|
-
import { rgb } from './rgb';
|
|
10
|
-
import { HSVtoRGB } from './HSVtoRGB';
|
|
11
|
-
|
|
12
|
-
export function hsv(h: number, s: number, v: number): number {
|
|
13
|
-
return rgb.apply(null, HSVtoRGB(h, s, v) as any);
|
|
14
|
-
}
|
package/src/lib/color/max.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Comparison (light).
|
|
3
|
-
* 2 RGB single number that indicates (0x000000 0xFFFFFF up from) to compare,
|
|
4
|
-
* RGB values combined with higher returns to their numbers.
|
|
5
|
-
* @ Param col1 RGB numbers show (0x000000 0xFFFFFF up from)
|
|
6
|
-
* @ Param col2 RGB numbers show (0x000000 0xFFFFFF up from)
|
|
7
|
-
* @ Return comparison (light) value
|
|
8
|
-
**/
|
|
9
|
-
import { toRGB } from './toRGB';
|
|
10
|
-
|
|
11
|
-
export function max(col1: number, col2: number): number {
|
|
12
|
-
const c1: any[] = toRGB(col1);
|
|
13
|
-
const c2: any[] = toRGB(col2);
|
|
14
|
-
const r: number = Math.max(c1[0], c2[0]);
|
|
15
|
-
const g: number = Math.max(c1[1], c2[1]);
|
|
16
|
-
const b: number = Math.max(c1[2], c2[2]);
|
|
17
|
-
return (r << 16) | (g << 8) | b;
|
|
18
|
-
}
|
package/src/lib/color/min.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Comparison (dark).
|
|
3
|
-
* 2 RGB single numbers that indicate (0x000000 0xFFFFFF up from) to compare,
|
|
4
|
-
* RGB lower combined returns a numeric value for each number.
|
|
5
|
-
* @ Param col1 RGB numbers show (0x000000 0xFFFFFF up from)
|
|
6
|
-
* @ Param col2 RGB numbers show (0x000000 0xFFFFFF up from)
|
|
7
|
-
* @ Return comparison (dark) values
|
|
8
|
-
**/
|
|
9
|
-
import { toRGB } from './toRGB';
|
|
10
|
-
|
|
11
|
-
export function min(col1: number, col2: number): number {
|
|
12
|
-
const c1: any[] = toRGB(col1);
|
|
13
|
-
const c2: any[] = toRGB(col2);
|
|
14
|
-
const r: number = Math.min(c1[0], c2[0]);
|
|
15
|
-
const g: number = Math.min(c1[1], c2[1]);
|
|
16
|
-
const b: number = Math.min(c1[2], c2[2]);
|
|
17
|
-
return (r << 16) | (g << 8) | b;
|
|
18
|
-
}
|
package/src/lib/color/overlay.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
*
|
|
3
|
-
There are two part of formula:
|
|
4
|
-
First part: If Lower Layer Value > 127.5, then do the following -
|
|
5
|
-
Value Unit = (255-Lower Layer Value)/127.5
|
|
6
|
-
Min Value = Lower Layer Value - (255-Lower Layer Value)
|
|
7
|
-
Overlay = (Upper Layer Value * Value Unit) + Min Value
|
|
8
|
-
Second part: If Lower Layer Value < 127.5, then do the following -
|
|
9
|
-
Value Unit=Lower Layer Value/127.5
|
|
10
|
-
|
|
11
|
-
Overlay = Upper Layer Value * Value Unit
|
|
12
|
-
* @param {number} col1
|
|
13
|
-
* @param {number} col2
|
|
14
|
-
* @return {number}
|
|
15
|
-
*/
|
|
16
|
-
import { toRGB } from './toRGB';
|
|
17
|
-
|
|
18
|
-
export function overlay(col1: number, col2: number): number {
|
|
19
|
-
const c1: any[] = toRGB(col1);
|
|
20
|
-
const c2: any[] = toRGB(col2);
|
|
21
|
-
const r: number = Math.max(c1[0], c2[0]);
|
|
22
|
-
const g: number = Math.max(c1[1], c2[1]);
|
|
23
|
-
const b: number = Math.max(c1[2], c2[2]);
|
|
24
|
-
return (r << 16) | (g << 8) | b;
|
|
25
|
-
}
|
package/src/lib/color/sub.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Subtractive.
|
|
3
|
-
* 2 RGB single numbers that indicate (0x000000 0xFFFFFF up from) Return the value
|
|
4
|
-
* of the subtractive color.
|
|
5
|
-
* @ Param col1 RGB numbers show (0x000000 0xFFFFFF up from)
|
|
6
|
-
* @ Param col2 RGB numbers show (0x000000 0xFFFFFF up from)
|
|
7
|
-
* @ Return the subtractive
|
|
8
|
-
**/
|
|
9
|
-
import { toRGB } from './toRGB';
|
|
10
|
-
|
|
11
|
-
export function sub(col1: number, col2: number): number {
|
|
12
|
-
const c1: any[] = toRGB(col1);
|
|
13
|
-
const c2: any[] = toRGB(col2);
|
|
14
|
-
const r: number = Math.max(c1[0] - c2[0], 0);
|
|
15
|
-
const g: number = Math.max(c1[1] - c2[1], 0);
|
|
16
|
-
const b: number = Math.max(c1[2] - c2[2], 0);
|
|
17
|
-
return (r << 16) | (g << 8) | b;
|
|
18
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Subtraction.
|
|
3
|
-
* 2 RGB single number that indicates (0x000000 0xFFFFFF up from) is subtracted
|
|
4
|
-
* from the return numbers.
|
|
5
|
-
* @ Param col1 RGB numbers show (0x000000 0xFFFFFF up from)
|
|
6
|
-
* @ Param col2 RGB numbers show (0x000000 0xFFFFFF up from)
|
|
7
|
-
* @ Return value subtracted Blend
|
|
8
|
-
**/
|
|
9
|
-
import { toRGB } from './toRGB';
|
|
10
|
-
|
|
11
|
-
export function subtract(col1: number, col2: number): number {
|
|
12
|
-
const colA: any[] = toRGB(col1);
|
|
13
|
-
const colB: any[] = toRGB(col2);
|
|
14
|
-
const r: number = Math.max(
|
|
15
|
-
Math.max(colB[0] - (256 - colA[0]), colA[0] - (256 - colB[0])),
|
|
16
|
-
0,
|
|
17
|
-
);
|
|
18
|
-
const g: number = Math.max(
|
|
19
|
-
Math.max(colB[1] - (256 - colA[1]), colA[1] - (256 - colB[1])),
|
|
20
|
-
0,
|
|
21
|
-
);
|
|
22
|
-
const b: number = Math.max(
|
|
23
|
-
Math.max(colB[2] - (256 - colA[2]), colA[2] - (256 - colB[2])),
|
|
24
|
-
0,
|
|
25
|
-
);
|
|
26
|
-
return (r << 16) | (g << 8) | b;
|
|
27
|
-
}
|
package/src/lib/color/sum.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Additive color.
|
|
3
|
-
* 2 RGB single numbers that indicate (0x000000 0xFFFFFF up from) Return the value
|
|
4
|
-
* of the additive mixture.
|
|
5
|
-
* @ Param col1 RGB numbers show (0x000000 0xFFFFFF up from)
|
|
6
|
-
* @ Param col2 RGB numbers show (0x000000 0xFFFFFF up from)
|
|
7
|
-
* @ Return the additive color
|
|
8
|
-
**/
|
|
9
|
-
import { toRGB } from './toRGB';
|
|
10
|
-
|
|
11
|
-
export function sum(col1: number, col2: number): number {
|
|
12
|
-
const c1: any[] = toRGB(col1);
|
|
13
|
-
const c2: any[] = toRGB(col2);
|
|
14
|
-
const r: number = Math.min(c1[0] + c2[0], 255);
|
|
15
|
-
const g: number = Math.min(c1[1] + c2[1], 255);
|
|
16
|
-
const b: number = Math.min(c1[2] + c2[2], 255);
|
|
17
|
-
|
|
18
|
-
return (r << 16) | (g << 8) | b;
|
|
19
|
-
}
|
package/src/lib/color/toRGBA.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export const COLOR_CODES = {
|
|
2
|
-
TO_UNREAL: ['#ffffff', '#005912', `UNREAL <-`],
|
|
3
|
-
TAP_LOG: ['#ffff00', '#1976d2', ' [TAPLOG]'],
|
|
4
|
-
FROM_UNREAL: ['#ffff00', '#898989', 'UNREAL ->'],
|
|
5
|
-
FROM_UNREAL_ERROR: ['#ffffff', '#ff0000', 'UNREAL ERROR ->'],
|
|
6
|
-
FROM_CIRRUS: ['#ffffff', '#ef702b', 'CIRRUS ->'],
|
|
7
|
-
FROM_CIRRUS_ERROR: ['#ffffff', '#ff0000', 'CIRRUS ->'],
|
|
8
|
-
TO_CIRRUS: ['#ffffff', '#3c9738', 'CIRRUS <-'],
|
|
9
|
-
} as const;
|
package/src/lib/csv/CSV2Array.ts
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
export function CSV2Array(strData: any, strDelimiter?: string): any[] {
|
|
2
|
-
// Check to see if the delimiter is defined. If not,
|
|
3
|
-
// then default to comma.
|
|
4
|
-
strDelimiter = strDelimiter || ',';
|
|
5
|
-
|
|
6
|
-
// Create a regular expression to parse the CSV values.
|
|
7
|
-
const objPattern = new RegExp(
|
|
8
|
-
// Delimiters.
|
|
9
|
-
'(\\' +
|
|
10
|
-
strDelimiter +
|
|
11
|
-
'|\\r?\\n|\\r|^)' +
|
|
12
|
-
// Quoted fields.
|
|
13
|
-
'(?:"([^"]*(?:""[^"]*)*)"|' +
|
|
14
|
-
// Standard fields.
|
|
15
|
-
'([^"\\' +
|
|
16
|
-
strDelimiter +
|
|
17
|
-
'\\r\\n]*))',
|
|
18
|
-
'gi',
|
|
19
|
-
);
|
|
20
|
-
|
|
21
|
-
// Create an array to hold our data. Give the array
|
|
22
|
-
// a default empty first row.
|
|
23
|
-
const arrData: any[] = [[]];
|
|
24
|
-
|
|
25
|
-
// Create an array to hold our individual pattern
|
|
26
|
-
// matching groups.
|
|
27
|
-
let arrMatches = null;
|
|
28
|
-
|
|
29
|
-
// Keep looping over the regular expression matches
|
|
30
|
-
// until we can no longer find a match.
|
|
31
|
-
while ((arrMatches = objPattern.exec(strData))) {
|
|
32
|
-
// Get the delimiter that was found.
|
|
33
|
-
const strMatchedDelimiter = arrMatches[1];
|
|
34
|
-
|
|
35
|
-
// Check to see if the given delimiter has a length
|
|
36
|
-
// (is not the start of string) and if it matches
|
|
37
|
-
// field delimiter. If idKey does not, then we know
|
|
38
|
-
// that this delimiter is a row delimiter.
|
|
39
|
-
if (strMatchedDelimiter.length && strMatchedDelimiter !== strDelimiter) {
|
|
40
|
-
// Since we have reached a new row of data,
|
|
41
|
-
// add an empty row to our data array.
|
|
42
|
-
arrData.push([]);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
let strMatchedValue: any;
|
|
46
|
-
|
|
47
|
-
// Now that we have our delimiter out of the way,
|
|
48
|
-
// let's check to see which kind of value we
|
|
49
|
-
// captured (quoted or unquoted).
|
|
50
|
-
if (arrMatches[2]) {
|
|
51
|
-
// We found a quoted value. When we capture
|
|
52
|
-
// this value, unescape any double quotes.
|
|
53
|
-
strMatchedValue = arrMatches[2].replace(new RegExp('""', 'g'), '"');
|
|
54
|
-
} else {
|
|
55
|
-
// We found a non-quoted value.
|
|
56
|
-
strMatchedValue = arrMatches[3];
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
// Now that we have our value string, let's add
|
|
60
|
-
// it to the data array.
|
|
61
|
-
arrData[arrData.length - 1].push(strMatchedValue);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
// Return the parsed data.
|
|
65
|
-
return arrData;
|
|
66
|
-
}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { CSV2Array } from './CSV2Array';
|
|
2
|
-
|
|
3
|
-
const booleanRegex = /^(true|false)$/i;
|
|
4
|
-
const trueRegex = /^(true)$/i;
|
|
5
|
-
const jsonRegex = /([\d.]+)|(\[])|(\[.+])|({.+})/i;
|
|
6
|
-
|
|
7
|
-
const zipObject = (props: string[], values: any[]) =>
|
|
8
|
-
props.reduce(
|
|
9
|
-
(obj: any, prop, index) => ((obj[prop] = values[index]), obj),
|
|
10
|
-
{},
|
|
11
|
-
);
|
|
12
|
-
|
|
13
|
-
const toHead = (input: any): string => {
|
|
14
|
-
return String(input).trim();
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
const toCorrectString = (input: any): any => {
|
|
18
|
-
if (typeof input === 'string') {
|
|
19
|
-
if (input.match(jsonRegex)) {
|
|
20
|
-
// optimization for use try-catch only after regex match. much faster than without regex
|
|
21
|
-
try {
|
|
22
|
-
return JSON.parse(input);
|
|
23
|
-
} catch {
|
|
24
|
-
/* empty */
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
if (input.match(booleanRegex)) {
|
|
28
|
-
return !!input.match(trueRegex);
|
|
29
|
-
}
|
|
30
|
-
return input.trim();
|
|
31
|
-
} else if (typeof input === 'number') {
|
|
32
|
-
return input;
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
export function CSV2Records(
|
|
37
|
-
csv: string,
|
|
38
|
-
useRowAsHead = 0,
|
|
39
|
-
strDelimiter?: string,
|
|
40
|
-
): any {
|
|
41
|
-
const arr = CSV2Array(csv, strDelimiter);
|
|
42
|
-
const total = arr.length;
|
|
43
|
-
const keys = arr[useRowAsHead].map(toHead);
|
|
44
|
-
const data: any[] = [];
|
|
45
|
-
|
|
46
|
-
let tmpSKU = 0;
|
|
47
|
-
|
|
48
|
-
for (let i = useRowAsHead + 1; i < total; i++) {
|
|
49
|
-
const obj = zipObject(keys, arr[i].map(toCorrectString));
|
|
50
|
-
data.push(obj);
|
|
51
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
52
|
-
tmpSKU++;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return data.filter(Boolean);
|
|
56
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export function ObjectToCSV<T extends object>(records: T[]) {
|
|
2
|
-
if (records.length === 0) {
|
|
3
|
-
return;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
const uniqueFields = Array.from(
|
|
7
|
-
records.reduce((fields, record) => {
|
|
8
|
-
Object.keys(record).forEach((field: string) => fields.add(field));
|
|
9
|
-
return fields;
|
|
10
|
-
}, new Set<string>()),
|
|
11
|
-
);
|
|
12
|
-
|
|
13
|
-
const csvHeader = uniqueFields.join(',') + '\n';
|
|
14
|
-
const csvRows = records
|
|
15
|
-
.map((record: any) =>
|
|
16
|
-
uniqueFields.map((field: any) => `"${record[field] || ''}"`).join(','),
|
|
17
|
-
)
|
|
18
|
-
.join('\n');
|
|
19
|
-
|
|
20
|
-
return csvHeader + csvRows;
|
|
21
|
-
}
|
package/src/lib/dev/dev3d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const isLocalhost = !!window.location.href.match(/localhost/gi);
|
package/src/lib/dev/logger.ts
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import { timeUTCToString } from './timeToString';
|
|
2
|
-
import { Truthy } from '../predicates/BooleanPredictors';
|
|
3
|
-
|
|
4
|
-
export class Logger {
|
|
5
|
-
static isDevMode = Truthy(localStorage.getItem('devMode'));
|
|
6
|
-
|
|
7
|
-
static colored(color: string, background: string, ...args: unknown[]) {
|
|
8
|
-
if (!Logger.isDevMode) {
|
|
9
|
-
return;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
const [first, ...rest] = args;
|
|
13
|
-
console.log.apply(console, [
|
|
14
|
-
`%c ${timeUTCToString()} ${first} `,
|
|
15
|
-
`color: ${color}; background: ${background};`,
|
|
16
|
-
...rest,
|
|
17
|
-
]);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
static log(...args: unknown[]) {
|
|
21
|
-
if (!Logger.isDevMode) {
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
console.log.apply(console, [
|
|
26
|
-
`%c ${timeUTCToString()} [ LOG ] `,
|
|
27
|
-
'color: black; background: #80ff80;',
|
|
28
|
-
...args,
|
|
29
|
-
]);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
static warn(...args: unknown[]) {
|
|
33
|
-
if (!Logger.isDevMode) {
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
console.warn.apply(console, [
|
|
38
|
-
`%c ${timeUTCToString()} WARN `,
|
|
39
|
-
'color: black; background: #ffd500;',
|
|
40
|
-
...args,
|
|
41
|
-
]);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
static info(...args: unknown[]) {
|
|
45
|
-
if (!Logger.isDevMode) {
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
console.log.apply(console, [
|
|
50
|
-
`%c ${timeUTCToString()} [ INFO ] `,
|
|
51
|
-
'color: white; background: blue;',
|
|
52
|
-
...args,
|
|
53
|
-
]);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
static error(...args: unknown[]) {
|
|
57
|
-
if (!Logger.isDevMode) {
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
console.error.apply(console, [
|
|
62
|
-
`%c ${timeUTCToString()} ERROR `,
|
|
63
|
-
'color: white; background: red;',
|
|
64
|
-
...args,
|
|
65
|
-
]);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
static table(...args: unknown[]) {
|
|
69
|
-
if (!Logger.isDevMode) {
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
// eslint-disable-next-line no-console
|
|
74
|
-
console.table.apply(console, [args]);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
static time(...args: any) {
|
|
78
|
-
if (!Logger.isDevMode) {
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
// eslint-disable-next-line no-console,prefer-spread
|
|
83
|
-
console.time.apply(console, args);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
static timeEnd(...args: any) {
|
|
87
|
-
if (!Logger.isDevMode) {
|
|
88
|
-
return;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
// eslint-disable-next-line no-console,prefer-spread
|
|
92
|
-
console.timeEnd.apply(console, args);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { pad } from '../strings';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Create a string of the form 'HOURS.MINUTES.SECONDS.MILLISECONDS'.
|
|
5
|
-
*/
|
|
6
|
-
export function timeToString() {
|
|
7
|
-
const date = new Date();
|
|
8
|
-
|
|
9
|
-
return `${pad(date.getHours(), 2)}:${pad(date.getMinutes(), 2)}:${pad(date.getSeconds(), 2)}.${pad(date.getMilliseconds(), 3)}`;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export function timeUTCToString() {
|
|
13
|
-
const date = new Date();
|
|
14
|
-
|
|
15
|
-
return `${pad(date.getUTCHours(), 2)}:${pad(date.getUTCMinutes(), 2)}:${pad(date.getUTCSeconds(), 2)}.${pad(date.getUTCMilliseconds(), 3)}`;
|
|
16
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export function cleanupFileName(value: string): string {
|
|
2
|
-
if (!value) {
|
|
3
|
-
return value;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
value = value
|
|
7
|
-
.toString()
|
|
8
|
-
.replace(/undefined/g, '')
|
|
9
|
-
.trim()
|
|
10
|
-
.replace(/\//g, '-')
|
|
11
|
-
.replace(/[-]+/g, '-')
|
|
12
|
-
.replace(/[^\w^.-]+/gi, '_')
|
|
13
|
-
.replace(/[\^]+/gi, '_');
|
|
14
|
-
|
|
15
|
-
value = value.split('_').filter(Boolean).join('_').toLowerCase();
|
|
16
|
-
|
|
17
|
-
return value;
|
|
18
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { Area, Rect } from './interfaces';
|
|
2
|
-
|
|
3
|
-
export function expandOverRectangle(objectRect: Rect, areaRect: Rect): Area {
|
|
4
|
-
const ratio: number = objectRect.w / objectRect.h;
|
|
5
|
-
const result: Area = { x: 0, y: 0, w: 0, h: 0, scale: 1 };
|
|
6
|
-
if (areaRect.w / ratio < areaRect.h) {
|
|
7
|
-
result.w = areaRect.h * ratio;
|
|
8
|
-
result.h = areaRect.h;
|
|
9
|
-
} else {
|
|
10
|
-
result.w = areaRect.w;
|
|
11
|
-
result.h = areaRect.w / ratio;
|
|
12
|
-
}
|
|
13
|
-
result.x = areaRect.x + (areaRect.w - result.w) / 2;
|
|
14
|
-
result.y = areaRect.y + (areaRect.h - result.h) / 2;
|
|
15
|
-
result.scale = result.w / objectRect.w;
|
|
16
|
-
return result;
|
|
17
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import type { Area, Rect } from './interfaces';
|
|
2
|
-
|
|
3
|
-
export function fitIntoRectangle(
|
|
4
|
-
objectRect: Rect,
|
|
5
|
-
areaRect: Rect,
|
|
6
|
-
round = true,
|
|
7
|
-
fixedRatio: number | null = null,
|
|
8
|
-
): Area {
|
|
9
|
-
const result: Area = { x: 0, y: 0, w: 0, h: 0, scale: 1 };
|
|
10
|
-
const ratio: number = objectRect.h / objectRect.w;
|
|
11
|
-
|
|
12
|
-
if (objectRect.h > objectRect.w) {
|
|
13
|
-
result.h = areaRect.h;
|
|
14
|
-
result.w = areaRect.h / ratio;
|
|
15
|
-
|
|
16
|
-
if (result.w > areaRect.w) {
|
|
17
|
-
result.w = areaRect.w;
|
|
18
|
-
result.h = areaRect.w * ratio;
|
|
19
|
-
}
|
|
20
|
-
} else {
|
|
21
|
-
result.w = areaRect.w;
|
|
22
|
-
result.h = areaRect.w * ratio;
|
|
23
|
-
|
|
24
|
-
if (result.h > areaRect.h) {
|
|
25
|
-
result.h = areaRect.h;
|
|
26
|
-
result.w = areaRect.h / ratio;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
if (fixedRatio) {
|
|
31
|
-
result.w = objectRect.w * fixedRatio;
|
|
32
|
-
result.h = objectRect.h * fixedRatio;
|
|
33
|
-
}
|
|
34
|
-
const wOut: number = round ? Math.floor(result.w) : result.w;
|
|
35
|
-
const hOut: number = round ? Math.floor(result.h) : result.h;
|
|
36
|
-
return {
|
|
37
|
-
x: areaRect.x + (areaRect.w - wOut) / 2,
|
|
38
|
-
y: areaRect.y + (areaRect.h - hOut) / 2,
|
|
39
|
-
w: wOut,
|
|
40
|
-
h: hOut,
|
|
41
|
-
scale: wOut / objectRect.w,
|
|
42
|
-
};
|
|
43
|
-
}
|