@3dsource/utils 0.0.1
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/README.md +64 -0
- package/eslint.config.js +37 -0
- package/ng-package.json +7 -0
- package/package.json +11 -0
- package/src/lib/color/CMYKtoRGB.ts +20 -0
- package/src/lib/color/HEXtoRGB.ts +9 -0
- package/src/lib/color/HSVtoRGB.ts +82 -0
- package/src/lib/color/RGBtoCMYK.ts +50 -0
- package/src/lib/color/RGBtoHEX.ts +17 -0
- package/src/lib/color/RGBtoHSV.ts +53 -0
- package/src/lib/color/hsv.ts +14 -0
- package/src/lib/color/index.ts +16 -0
- package/src/lib/color/max.ts +18 -0
- package/src/lib/color/min.ts +18 -0
- package/src/lib/color/overlay.ts +25 -0
- package/src/lib/color/rgb.ts +10 -0
- package/src/lib/color/sub.ts +18 -0
- package/src/lib/color/subtract.ts +27 -0
- package/src/lib/color/sum.ts +19 -0
- package/src/lib/color/toRGB.ts +14 -0
- package/src/lib/color/toRGBA.ts +8 -0
- package/src/lib/constants/color-codes.constant.ts +9 -0
- package/src/lib/constants/index.ts +1 -0
- package/src/lib/csv/CSV2Array.ts +66 -0
- package/src/lib/csv/CSV2Records.ts +56 -0
- package/src/lib/csv/ObjectToCSV.ts +21 -0
- package/src/lib/csv/index.ts +3 -0
- package/src/lib/csv/test/Csv.spec.ts +51 -0
- package/src/lib/dev/dev3d.ts +1 -0
- package/src/lib/dev/index.ts +3 -0
- package/src/lib/dev/logger.ts +94 -0
- package/src/lib/dev/timeToString.ts +16 -0
- package/src/lib/filenaming/cleanupFileName.ts +18 -0
- package/src/lib/filenaming/index.ts +3 -0
- package/src/lib/filenaming/makePath.ts +5 -0
- package/src/lib/filenaming/normalizePath.ts +9 -0
- package/src/lib/filenaming/test/cleanupFileName.spec.ts +9 -0
- package/src/lib/filenaming/test/makePath.spec.ts +7 -0
- package/src/lib/filenaming/test/normalizePath.spec.ts +9 -0
- package/src/lib/geom/expandOverRectangle.ts +17 -0
- package/src/lib/geom/fitIntoRectangle.ts +43 -0
- package/src/lib/geom/index.ts +3 -0
- package/src/lib/geom/interfaces/area.interface.ts +5 -0
- package/src/lib/geom/interfaces/index.ts +4 -0
- package/src/lib/geom/interfaces/rect.interface.ts +4 -0
- package/src/lib/geom/interfaces/size.interface.ts +4 -0
- package/src/lib/geom/interfaces//321/201oords.interface.ts +4 -0
- package/src/lib/geom/test/fitRectangle.spec.ts +54 -0
- package/src/lib/helpers/BatchLoader.ts +243 -0
- package/src/lib/helpers/KeyboardNumericCode.ts +118 -0
- package/src/lib/helpers/index.ts +6 -0
- package/src/lib/helpers/serialize.ts +11 -0
- package/src/lib/helpers/sleep.ts +3 -0
- package/src/lib/helpers/test/sleep.spec.ts +11 -0
- package/src/lib/helpers/trimLastSlashFromUrl.ts +9 -0
- package/src/lib/image/SaveImage.ts +65 -0
- package/src/lib/image/getCanvasCached.ts +16 -0
- package/src/lib/image/getSnapshot.ts +99 -0
- package/src/lib/image/index.ts +4 -0
- package/src/lib/image/loadImage.ts +13 -0
- package/src/lib/interfaces/image-output.ts +8 -0
- package/src/lib/interfaces/index.ts +3 -0
- package/src/lib/interfaces/load-args-tmp.interface.ts +5 -0
- package/src/lib/interfaces/load-args.interface.ts +15 -0
- package/src/lib/math/baseSortedIndex.ts +43 -0
- package/src/lib/math/calculateMedian.ts +33 -0
- package/src/lib/math/circularIndex.ts +39 -0
- package/src/lib/math/clampf.ts +14 -0
- package/src/lib/math/degrees.ts +7 -0
- package/src/lib/math/floatCompare.ts +69 -0
- package/src/lib/math/index.ts +8 -0
- package/src/lib/math/inverseLerp.ts +38 -0
- package/src/lib/math/lerp.ts +12 -0
- package/src/lib/math/test/baseSortedIndex.spec.ts +43 -0
- package/src/lib/math/test/circularIndex.spec.ts +38 -0
- package/src/lib/mutex/Mutex.ts +50 -0
- package/src/lib/mutex/Semaphore.ts +62 -0
- package/src/lib/mutex/TaskRunner.ts +26 -0
- package/src/lib/mutex/index.ts +3 -0
- package/src/lib/predicates/BooleanPredictors.ts +47 -0
- package/src/lib/predicates/index.ts +3 -0
- package/src/lib/predicates/test/BooleanPredictors.spec.ts +71 -0
- package/src/lib/predicates/test/where.spec.ts +94 -0
- package/src/lib/predicates/textForSearch.ts +34 -0
- package/src/lib/predicates/where.ts +76 -0
- package/src/lib/rxjs/index.ts +3 -0
- package/src/lib/rxjs/leadingTrailingDebounceTime.ts +86 -0
- package/src/lib/rxjs/smoothTransition.ts +29 -0
- package/src/lib/rxjs/tapLog.ts +13 -0
- package/src/lib/strings/index.ts +1 -0
- package/src/lib/strings/pad.ts +18 -0
- package/src/public-api.ts +14 -0
- package/tsconfig.lib.json +13 -0
- package/tsconfig.lib.prod.json +11 -0
package/README.md
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# Utils
|
|
2
|
+
|
|
3
|
+
This project was generated using [Angular CLI](https://github.com/angular/angular-cli) version 19.2.0.
|
|
4
|
+
|
|
5
|
+
## Code scaffolding
|
|
6
|
+
|
|
7
|
+
Angular CLI includes powerful code scaffolding tools. To generate a new component, run:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
ng generate component component-name
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
For a complete list of available schematics (such as `components`, `directives`, or `pipes`), run:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
ng generate --help
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Building
|
|
20
|
+
|
|
21
|
+
To build the library, run:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
ng build utils
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
This command will compile your project, and the build artifacts will be placed in the `dist/` directory.
|
|
28
|
+
|
|
29
|
+
### Publishing the Library
|
|
30
|
+
|
|
31
|
+
Once the project is built, you can publish your library by following these steps:
|
|
32
|
+
|
|
33
|
+
1. Navigate to the `dist` directory:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
cd dist/utils
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
2. Run the `npm publish` command to publish your library to the npm registry:
|
|
40
|
+
```bash
|
|
41
|
+
npm publish
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Running unit tests
|
|
45
|
+
|
|
46
|
+
To execute unit tests with the [Karma](https://karma-runner.github.io) test runner, use the following command:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
ng test
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Running end-to-end tests
|
|
53
|
+
|
|
54
|
+
For end-to-end (e2e) testing, run:
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
ng e2e
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Angular CLI does not come with an end-to-end testing framework by default. You can choose one that suits your needs.
|
|
61
|
+
|
|
62
|
+
## Additional Resources
|
|
63
|
+
|
|
64
|
+
For more information on using the Angular CLI, including detailed command references, visit the [Angular CLI Overview and Command Reference](https://angular.dev/tools/cli) page.
|
package/eslint.config.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
const tseslint = require('typescript-eslint');
|
|
3
|
+
const rootConfig = require('../../../eslint.config.js');
|
|
4
|
+
|
|
5
|
+
module.exports = tseslint.config(
|
|
6
|
+
...rootConfig,
|
|
7
|
+
{
|
|
8
|
+
files: ['**/*.ts'],
|
|
9
|
+
languageOptions: {
|
|
10
|
+
parserOptions: {
|
|
11
|
+
projectService: true,
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
rules: {
|
|
15
|
+
'@angular-eslint/directive-selector': [
|
|
16
|
+
'error',
|
|
17
|
+
{
|
|
18
|
+
type: 'attribute',
|
|
19
|
+
prefix: 'lib',
|
|
20
|
+
style: 'camelCase',
|
|
21
|
+
},
|
|
22
|
+
],
|
|
23
|
+
'@angular-eslint/component-selector': [
|
|
24
|
+
'error',
|
|
25
|
+
{
|
|
26
|
+
type: 'element',
|
|
27
|
+
prefix: 'lib',
|
|
28
|
+
style: 'kebab-case',
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
files: ['**/*.html'],
|
|
35
|
+
rules: {},
|
|
36
|
+
},
|
|
37
|
+
);
|
package/ng-package.json
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RGB from each of the CMYK values to determine a return as an any[].
|
|
3
|
+
* CMYK values are as follows.
|
|
4
|
+
* C - a number between 0 and 255 representing cyan
|
|
5
|
+
* M - number between 0 and 255 representing magenta
|
|
6
|
+
* Y - number between 0 and 255 representing yellow
|
|
7
|
+
* K - number between 0 and 255 representing black
|
|
8
|
+
*
|
|
9
|
+
**/
|
|
10
|
+
export function CMYKtoRGB(c: number, m: number, y: number, k: number): any[] {
|
|
11
|
+
c = 255 - c;
|
|
12
|
+
m = 255 - m;
|
|
13
|
+
y = 255 - y;
|
|
14
|
+
k = 255 - k;
|
|
15
|
+
return [
|
|
16
|
+
((255 - c) * (255 - k)) / 255,
|
|
17
|
+
((255 - m) * (255 - k)) / 255,
|
|
18
|
+
((255 - y) * (255 - k)) / 255,
|
|
19
|
+
];
|
|
20
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
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
|
+
* CMYK values are as follows.
|
|
9
|
+
* C - a number between 0 and 255 representing cyan
|
|
10
|
+
* M - number between 0 and 255 representing magenta
|
|
11
|
+
* Y - number between 0 and 255 representing yellow
|
|
12
|
+
* K - number between 0 and 255 representing black
|
|
13
|
+
*
|
|
14
|
+
* Cannot compute, including alpha.
|
|
15
|
+
* @ Param r the red (R) indicating the number (0x00 to 0xFF to)
|
|
16
|
+
* @ Param g green (G) indicates the number (0x00 to 0xFF to)
|
|
17
|
+
* @ Param b blue (B) shows the number (0x00 to 0xFF to)
|
|
18
|
+
* @ Return CMYK values into an any[] of [H, S, V]
|
|
19
|
+
**/
|
|
20
|
+
export function RGBtoCMYK(r: number, g: number, b: number): any[] {
|
|
21
|
+
let c = 0;
|
|
22
|
+
let m = 0;
|
|
23
|
+
let y = 0;
|
|
24
|
+
let k = 0;
|
|
25
|
+
|
|
26
|
+
c = 255 - r;
|
|
27
|
+
m = 255 - g;
|
|
28
|
+
y = 255 - b;
|
|
29
|
+
k = 255;
|
|
30
|
+
|
|
31
|
+
if (c < k) {
|
|
32
|
+
k = c;
|
|
33
|
+
}
|
|
34
|
+
if (m < k) {
|
|
35
|
+
k = m;
|
|
36
|
+
}
|
|
37
|
+
if (y < k) {
|
|
38
|
+
k = y;
|
|
39
|
+
}
|
|
40
|
+
if (k === 255) {
|
|
41
|
+
c = 0;
|
|
42
|
+
m = 0;
|
|
43
|
+
y = 0;
|
|
44
|
+
} else {
|
|
45
|
+
c = Math.round((255 * (c - k)) / (255 - k));
|
|
46
|
+
m = Math.round((255 * (m - k)) / (255 - k));
|
|
47
|
+
y = Math.round((255 * (y - k)) / (255 - k));
|
|
48
|
+
}
|
|
49
|
+
return [c, m, y, k];
|
|
50
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export * from './CMYKtoRGB';
|
|
2
|
+
export * from './HEXtoRGB';
|
|
3
|
+
export * from './hsv';
|
|
4
|
+
export * from './HSVtoRGB';
|
|
5
|
+
export * from './max';
|
|
6
|
+
export * from './min';
|
|
7
|
+
export * from './overlay';
|
|
8
|
+
export * from './rgb';
|
|
9
|
+
export * from './RGBtoCMYK';
|
|
10
|
+
export * from './RGBtoHEX';
|
|
11
|
+
export * from './RGBtoHSV';
|
|
12
|
+
export * from './sub';
|
|
13
|
+
export * from './subtract';
|
|
14
|
+
export * from './sum';
|
|
15
|
+
export * from './toRGB';
|
|
16
|
+
export * from './toRGBA';
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Values calculated from each RGB * RGB color value.
|
|
3
|
+
* @ Param r the red (R) indicating the number (0-255)
|
|
4
|
+
* @ Param g green (G) indicates the number (0-255)
|
|
5
|
+
* @ Param b blue (B) shows the number (0-255)
|
|
6
|
+
* @ Return obtained from the RGB color value for each indicating the number
|
|
7
|
+
**/
|
|
8
|
+
export function rgb(r: number, g: number, b: number): number {
|
|
9
|
+
return (r << 16) | (g << 8) | b;
|
|
10
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RGB figures show (0x000000 0xFFFFFF up from) the
|
|
3
|
+
* R, G, B returns an any[] divided into a number from 0 to 255, respectively.
|
|
4
|
+
*
|
|
5
|
+
* @ Param rgb numbers show (0x000000 0xFFFFFF up from)
|
|
6
|
+
* @ Return any[] indicates the value of each color [R, G, B]
|
|
7
|
+
**/
|
|
8
|
+
export function toRGB(rgb: number): number[] {
|
|
9
|
+
const r: number = (rgb >> 16) & 0xff;
|
|
10
|
+
const g: number = (rgb >> 8) & 0xff;
|
|
11
|
+
const b: number = rgb & 0xff;
|
|
12
|
+
|
|
13
|
+
return [r, g, b];
|
|
14
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
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;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './color-codes.constant';
|
|
@@ -0,0 +1,66 @@
|
|
|
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
|
+
}
|