@bitbybit-dev/base 0.19.6 → 0.19.8
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/babel.config.cjs +0 -1
- package/{index.js → index.ts} +2 -1
- package/lib/api/inputs/base-inputs.ts +18 -0
- package/lib/api/inputs/{color-inputs.d.ts → color-inputs.ts} +48 -26
- package/lib/api/inputs/{lists-inputs.d.ts → lists-inputs.ts} +190 -91
- package/lib/api/inputs/{logic-inputs.d.ts → logic-inputs.ts} +46 -24
- package/lib/api/inputs/{math-inputs.d.ts → math-inputs.ts} +97 -53
- package/lib/api/inputs/{point-inputs.d.ts → point-inputs.ts} +168 -77
- package/lib/api/inputs/text-inputs.ts +108 -0
- package/lib/api/inputs/{transforms-inputs.d.ts → transforms-inputs.ts} +64 -35
- package/lib/api/inputs/{vector-inputs.d.ts → vector-inputs.ts} +104 -48
- package/lib/api/services/color.test.ts +86 -0
- package/lib/api/services/{color.js → color.ts} +34 -15
- package/lib/api/services/{geometry-helper.js → geometry-helper.ts} +43 -31
- package/lib/api/services/{index.d.ts → index.ts} +1 -1
- package/lib/api/services/lists.test.ts +612 -0
- package/lib/api/services/{lists.js → lists.ts} +83 -59
- package/lib/api/services/logic.test.ts +187 -0
- package/lib/api/services/{logic.js → logic.ts} +32 -24
- package/lib/api/services/math.test.ts +622 -0
- package/lib/api/services/{math.js → math.ts} +136 -71
- package/lib/api/services/{point.js → point.ts} +67 -32
- package/lib/api/services/text.test.ts +55 -0
- package/lib/api/services/{text.js → text.ts} +17 -7
- package/lib/api/services/{transforms.js → transforms.ts} +83 -37
- package/lib/api/services/vector.test.ts +360 -0
- package/lib/api/services/{vector.js → vector.ts} +80 -42
- package/lib/{index.d.ts → index.ts} +1 -0
- package/package.json +1 -1
- package/tsconfig.bitbybit.json +26 -0
- package/tsconfig.json +24 -0
- package/babel.config.d.cts +0 -5
- package/index.d.ts +0 -1
- package/lib/api/index.js +0 -1
- package/lib/api/inputs/base-inputs.d.ts +0 -35
- package/lib/api/inputs/base-inputs.js +0 -1
- package/lib/api/inputs/color-inputs.js +0 -164
- package/lib/api/inputs/index.js +0 -9
- package/lib/api/inputs/inputs.js +0 -9
- package/lib/api/inputs/lists-inputs.js +0 -576
- package/lib/api/inputs/logic-inputs.js +0 -111
- package/lib/api/inputs/math-inputs.js +0 -391
- package/lib/api/inputs/point-inputs.js +0 -521
- package/lib/api/inputs/text-inputs.d.ts +0 -83
- package/lib/api/inputs/text-inputs.js +0 -120
- package/lib/api/inputs/transforms-inputs.js +0 -200
- package/lib/api/inputs/vector-inputs.js +0 -304
- package/lib/api/services/color.d.ts +0 -114
- package/lib/api/services/geometry-helper.d.ts +0 -15
- package/lib/api/services/index.js +0 -9
- package/lib/api/services/lists.d.ts +0 -287
- package/lib/api/services/logic.d.ts +0 -99
- package/lib/api/services/math.d.ts +0 -349
- package/lib/api/services/point.d.ts +0 -222
- package/lib/api/services/text.d.ts +0 -69
- package/lib/api/services/transforms.d.ts +0 -122
- package/lib/api/services/vector.d.ts +0 -320
- package/lib/index.js +0 -1
- /package/lib/api/{index.d.ts → index.ts} +0 -0
- /package/lib/api/inputs/{index.d.ts → index.ts} +0 -0
- /package/lib/api/inputs/{inputs.d.ts → inputs.ts} +0 -0
|
@@ -1,7 +1,14 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-namespace */
|
|
1
2
|
import { Base } from "./base-inputs";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
|
|
4
|
+
export namespace Transforms {
|
|
5
|
+
|
|
6
|
+
export class RotationCenterAxisDto {
|
|
7
|
+
constructor(angle?: number, axis?: Base.Vector3, center?: Base.Point3) {
|
|
8
|
+
if (angle !== undefined) { this.angle = angle; }
|
|
9
|
+
if (axis !== undefined) { this.axis = axis; }
|
|
10
|
+
if (center !== undefined) { this.center = center; }
|
|
11
|
+
}
|
|
5
12
|
/**
|
|
6
13
|
* Angle of rotation in degrees
|
|
7
14
|
* @default 90
|
|
@@ -9,20 +16,23 @@ export declare namespace Transforms {
|
|
|
9
16
|
* @maximum Infinity
|
|
10
17
|
* @step 1
|
|
11
18
|
*/
|
|
12
|
-
angle
|
|
19
|
+
angle = 90;
|
|
13
20
|
/**
|
|
14
21
|
* Axis vector for rotation
|
|
15
22
|
* @default [0, 1, 0]
|
|
16
23
|
*/
|
|
17
|
-
axis: Base.Vector3;
|
|
24
|
+
axis: Base.Vector3 = [0, 1, 0];
|
|
18
25
|
/**
|
|
19
26
|
* The center from which the axis is pointing
|
|
20
27
|
* @default [0, 0, 0]
|
|
21
28
|
*/
|
|
22
|
-
center: Base.Point3;
|
|
29
|
+
center: Base.Point3 = [0, 0, 0];
|
|
23
30
|
}
|
|
24
|
-
class RotationCenterDto {
|
|
25
|
-
constructor(angle?: number, center?: Base.Point3)
|
|
31
|
+
export class RotationCenterDto {
|
|
32
|
+
constructor(angle?: number, center?: Base.Point3) {
|
|
33
|
+
if (angle !== undefined) { this.angle = angle; }
|
|
34
|
+
if (center !== undefined) { this.center = center; }
|
|
35
|
+
}
|
|
26
36
|
/**
|
|
27
37
|
* Angle of rotation in degrees
|
|
28
38
|
* @default 90
|
|
@@ -30,15 +40,20 @@ export declare namespace Transforms {
|
|
|
30
40
|
* @maximum Infinity
|
|
31
41
|
* @step 1
|
|
32
42
|
*/
|
|
33
|
-
angle
|
|
43
|
+
angle = 90;
|
|
34
44
|
/**
|
|
35
45
|
* The center from which the axis is pointing
|
|
36
46
|
* @default [0, 0, 0]
|
|
37
47
|
*/
|
|
38
|
-
center: Base.Point3;
|
|
48
|
+
center: Base.Point3 = [0, 0, 0];
|
|
39
49
|
}
|
|
40
|
-
class RotationCenterYawPitchRollDto {
|
|
41
|
-
constructor(yaw?: number, pitch?: number, roll?: number, center?: Base.Point3)
|
|
50
|
+
export class RotationCenterYawPitchRollDto {
|
|
51
|
+
constructor(yaw?: number, pitch?: number, roll?: number, center?: Base.Point3) {
|
|
52
|
+
if (yaw !== undefined) { this.yaw = yaw; }
|
|
53
|
+
if (pitch !== undefined) { this.pitch = pitch; }
|
|
54
|
+
if (roll !== undefined) { this.roll = roll; }
|
|
55
|
+
if (center !== undefined) { this.center = center; }
|
|
56
|
+
}
|
|
42
57
|
/**
|
|
43
58
|
* Yaw angle (Rotation around X) in degrees
|
|
44
59
|
* @default 0
|
|
@@ -46,7 +61,7 @@ export declare namespace Transforms {
|
|
|
46
61
|
* @maximum Infinity
|
|
47
62
|
* @step 1
|
|
48
63
|
*/
|
|
49
|
-
yaw
|
|
64
|
+
yaw = 0;
|
|
50
65
|
/**
|
|
51
66
|
* Pitch angle (Rotation around Y) in degrees
|
|
52
67
|
* @default 0
|
|
@@ -54,7 +69,7 @@ export declare namespace Transforms {
|
|
|
54
69
|
* @maximum Infinity
|
|
55
70
|
* @step 1
|
|
56
71
|
*/
|
|
57
|
-
pitch
|
|
72
|
+
pitch = 0;
|
|
58
73
|
/**
|
|
59
74
|
* Roll angle (Rotation around Z) in degrees
|
|
60
75
|
* @default 0
|
|
@@ -62,36 +77,43 @@ export declare namespace Transforms {
|
|
|
62
77
|
* @maximum Infinity
|
|
63
78
|
* @step 1
|
|
64
79
|
*/
|
|
65
|
-
roll
|
|
80
|
+
roll = 0;
|
|
66
81
|
/**
|
|
67
82
|
* The center from which the rotations are applied
|
|
68
83
|
* @default [0, 0, 0]
|
|
69
84
|
*/
|
|
70
|
-
center: Base.Point3;
|
|
85
|
+
center: Base.Point3 = [0, 0, 0];
|
|
71
86
|
}
|
|
72
|
-
class ScaleXYZDto {
|
|
73
|
-
constructor(scaleXyz?: Base.Vector3)
|
|
87
|
+
export class ScaleXYZDto {
|
|
88
|
+
constructor(scaleXyz?: Base.Vector3) {
|
|
89
|
+
if (scaleXyz !== undefined) { this.scaleXyz = scaleXyz; }
|
|
90
|
+
}
|
|
74
91
|
/**
|
|
75
92
|
* Scaling factors for each axis [1, 2, 1] means that Y axis will be scaled 200% and both x and z axis will remain on 100%
|
|
76
93
|
* @default [1, 1, 1]
|
|
77
94
|
*/
|
|
78
|
-
scaleXyz: Base.Vector3;
|
|
95
|
+
scaleXyz: Base.Vector3 = [1, 1, 1];
|
|
79
96
|
}
|
|
80
|
-
class ScaleCenterXYZDto {
|
|
81
|
-
constructor(center?: Base.Point3, scaleXyz?: Base.Vector3)
|
|
97
|
+
export class ScaleCenterXYZDto {
|
|
98
|
+
constructor(center?: Base.Point3, scaleXyz?: Base.Vector3) {
|
|
99
|
+
if (center !== undefined) { this.center = center; }
|
|
100
|
+
if (scaleXyz !== undefined) { this.scaleXyz = scaleXyz; }
|
|
101
|
+
}
|
|
82
102
|
/**
|
|
83
103
|
* The center from which the scaling is applied
|
|
84
104
|
* @default [0, 0, 0]
|
|
85
105
|
*/
|
|
86
|
-
center: Base.Point3;
|
|
106
|
+
center: Base.Point3 = [0, 0, 0];
|
|
87
107
|
/**
|
|
88
108
|
* Scaling factors for each axis [1, 2, 1] means that Y axis will be scaled 200% and both x and z axis will remain on 100%
|
|
89
109
|
* @default [1, 1, 1]
|
|
90
110
|
*/
|
|
91
|
-
scaleXyz: Base.Vector3;
|
|
111
|
+
scaleXyz: Base.Vector3 = [1, 1, 1];
|
|
92
112
|
}
|
|
93
|
-
class UniformScaleDto {
|
|
94
|
-
constructor(scale?: number)
|
|
113
|
+
export class UniformScaleDto {
|
|
114
|
+
constructor(scale?: number) {
|
|
115
|
+
if (scale !== undefined) { this.scale = scale; }
|
|
116
|
+
}
|
|
95
117
|
/**
|
|
96
118
|
* Uniform scale factor for all x, y, z directions. 1 will keep everything on original size, 2 will scale 200%;
|
|
97
119
|
* @default 1
|
|
@@ -99,10 +121,13 @@ export declare namespace Transforms {
|
|
|
99
121
|
* @maximum Infinity
|
|
100
122
|
* @step 0.1
|
|
101
123
|
*/
|
|
102
|
-
scale
|
|
124
|
+
scale = 1;
|
|
103
125
|
}
|
|
104
|
-
class UniformScaleFromCenterDto {
|
|
105
|
-
constructor(scale?: number, center?: Base.Point3)
|
|
126
|
+
export class UniformScaleFromCenterDto {
|
|
127
|
+
constructor(scale?: number, center?: Base.Point3) {
|
|
128
|
+
if (scale !== undefined) { this.scale = scale; }
|
|
129
|
+
if (center !== undefined) { this.center = center; }
|
|
130
|
+
}
|
|
106
131
|
/**
|
|
107
132
|
* Scale factor for all x, y, z directions. 1 will keep everything on original size, 2 will scale 200%;
|
|
108
133
|
* @default 1
|
|
@@ -110,23 +135,27 @@ export declare namespace Transforms {
|
|
|
110
135
|
* @maximum Infinity
|
|
111
136
|
* @step 0.1
|
|
112
137
|
*/
|
|
113
|
-
scale
|
|
138
|
+
scale = 1;
|
|
114
139
|
/**
|
|
115
140
|
* Center position of the scaling
|
|
116
141
|
* @default [0, 0, 0]
|
|
117
142
|
*/
|
|
118
|
-
center: Base.Point3;
|
|
143
|
+
center: Base.Point3 = [0, 0, 0];
|
|
119
144
|
}
|
|
120
|
-
class TranslationXYZDto {
|
|
121
|
-
constructor(translation?: Base.Vector3)
|
|
145
|
+
export class TranslationXYZDto {
|
|
146
|
+
constructor(translation?: Base.Vector3) {
|
|
147
|
+
if (translation !== undefined) { this.translation = translation; }
|
|
148
|
+
}
|
|
122
149
|
/**
|
|
123
150
|
* Translation vector with [x, y, z] distances
|
|
124
151
|
* @default [0, 0, 0]
|
|
125
152
|
*/
|
|
126
|
-
translation: Base.Vector3;
|
|
153
|
+
translation: Base.Vector3 = [0, 0, 0];
|
|
127
154
|
}
|
|
128
|
-
class TranslationsXYZDto {
|
|
129
|
-
constructor(translations?: Base.Vector3[])
|
|
155
|
+
export class TranslationsXYZDto {
|
|
156
|
+
constructor(translations?: Base.Vector3[]) {
|
|
157
|
+
if (translations !== undefined) { this.translations = translations; }
|
|
158
|
+
}
|
|
130
159
|
/**
|
|
131
160
|
* Translation vectors with [x, y, z] distances
|
|
132
161
|
* @default undefined
|
|
@@ -1,8 +1,14 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-namespace */
|
|
1
2
|
import { Base } from "./base-inputs";
|
|
2
3
|
import { Math } from "./inputs";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
|
|
5
|
+
export namespace Vector {
|
|
6
|
+
|
|
7
|
+
export class TwoVectorsDto {
|
|
8
|
+
constructor(first?: number[], second?: number[]) {
|
|
9
|
+
if (first !== undefined) { this.first = first; }
|
|
10
|
+
if (second !== undefined) { this.second = second; }
|
|
11
|
+
}
|
|
6
12
|
/**
|
|
7
13
|
* First vector
|
|
8
14
|
* @default undefined
|
|
@@ -14,16 +20,21 @@ export declare namespace Vector {
|
|
|
14
20
|
*/
|
|
15
21
|
second: number[];
|
|
16
22
|
}
|
|
17
|
-
class VectorBoolDto {
|
|
18
|
-
constructor(vector?: boolean[])
|
|
23
|
+
export class VectorBoolDto {
|
|
24
|
+
constructor(vector?: boolean[]) {
|
|
25
|
+
if (vector !== undefined) { this.vector = vector; }
|
|
26
|
+
}
|
|
19
27
|
/**
|
|
20
28
|
* Vector of booleans
|
|
21
29
|
* @default undefined
|
|
22
30
|
*/
|
|
23
31
|
vector: boolean[];
|
|
24
32
|
}
|
|
25
|
-
class RemoveAllDuplicateVectorsDto {
|
|
26
|
-
constructor(vectors?: number[][], tolerance?: number)
|
|
33
|
+
export class RemoveAllDuplicateVectorsDto {
|
|
34
|
+
constructor(vectors?: number[][], tolerance?: number) {
|
|
35
|
+
if (vectors !== undefined) { this.vectors = vectors; }
|
|
36
|
+
if (tolerance !== undefined) { this.tolerance = tolerance; }
|
|
37
|
+
}
|
|
27
38
|
/**
|
|
28
39
|
* Vectors array
|
|
29
40
|
* @default undefined
|
|
@@ -35,10 +46,14 @@ export declare namespace Vector {
|
|
|
35
46
|
* @minimum 0
|
|
36
47
|
* @maximum Infinity
|
|
37
48
|
*/
|
|
38
|
-
tolerance
|
|
49
|
+
tolerance = 1e-7;
|
|
39
50
|
}
|
|
40
|
-
class RemoveConsecutiveDuplicateVectorsDto {
|
|
41
|
-
constructor(vectors?: number[][], checkFirstAndLast?: boolean, tolerance?: number)
|
|
51
|
+
export class RemoveConsecutiveDuplicateVectorsDto {
|
|
52
|
+
constructor(vectors?: number[][], checkFirstAndLast?: boolean, tolerance?: number) {
|
|
53
|
+
if (vectors !== undefined) { this.vectors = vectors; }
|
|
54
|
+
if (checkFirstAndLast !== undefined) { this.checkFirstAndLast = checkFirstAndLast; }
|
|
55
|
+
if (tolerance !== undefined) { this.tolerance = tolerance; }
|
|
56
|
+
}
|
|
42
57
|
/**
|
|
43
58
|
* Vectors array
|
|
44
59
|
* @default undefined
|
|
@@ -48,25 +63,29 @@ export declare namespace Vector {
|
|
|
48
63
|
* Check first and last vectors
|
|
49
64
|
* @default false
|
|
50
65
|
*/
|
|
51
|
-
checkFirstAndLast
|
|
66
|
+
checkFirstAndLast = false;
|
|
52
67
|
/**
|
|
53
68
|
* Tolerance value
|
|
54
69
|
* @default 1e-7
|
|
55
70
|
* @minimum 0
|
|
56
71
|
* @maximum Infinity
|
|
57
72
|
*/
|
|
58
|
-
tolerance
|
|
73
|
+
tolerance = 1e-7;
|
|
59
74
|
}
|
|
60
|
-
class VectorDto {
|
|
61
|
-
constructor(vector?: number[])
|
|
75
|
+
export class VectorDto {
|
|
76
|
+
constructor(vector?: number[]) {
|
|
77
|
+
if (vector !== undefined) { this.vector = vector; }
|
|
78
|
+
}
|
|
62
79
|
/**
|
|
63
80
|
* Vector array of numbers
|
|
64
81
|
* @default undefined
|
|
65
82
|
*/
|
|
66
83
|
vector: number[];
|
|
67
84
|
}
|
|
68
|
-
class RangeMaxDto {
|
|
69
|
-
constructor(max?: number)
|
|
85
|
+
export class RangeMaxDto {
|
|
86
|
+
constructor(max?: number) {
|
|
87
|
+
if (max !== undefined) { this.max = max; }
|
|
88
|
+
}
|
|
70
89
|
/**
|
|
71
90
|
* Maximum range boundary
|
|
72
91
|
* @default 10
|
|
@@ -76,8 +95,12 @@ export declare namespace Vector {
|
|
|
76
95
|
*/
|
|
77
96
|
max: number;
|
|
78
97
|
}
|
|
79
|
-
class VectorXYZDto {
|
|
80
|
-
constructor(x?: number, y?: number, z?: number)
|
|
98
|
+
export class VectorXYZDto {
|
|
99
|
+
constructor(x?: number, y?: number, z?: number) {
|
|
100
|
+
if (x !== undefined) { this.x = x; }
|
|
101
|
+
if (y !== undefined) { this.y = y; }
|
|
102
|
+
if (z !== undefined) { this.z = z; }
|
|
103
|
+
}
|
|
81
104
|
/**
|
|
82
105
|
* X value of vector
|
|
83
106
|
* @default 0
|
|
@@ -103,8 +126,11 @@ export declare namespace Vector {
|
|
|
103
126
|
*/
|
|
104
127
|
z: number;
|
|
105
128
|
}
|
|
106
|
-
class VectorXYDto {
|
|
107
|
-
constructor(x?: number, y?: number)
|
|
129
|
+
export class VectorXYDto {
|
|
130
|
+
constructor(x?: number, y?: number) {
|
|
131
|
+
if (x !== undefined) { this.x = x; }
|
|
132
|
+
if (y !== undefined) { this.y = y; }
|
|
133
|
+
}
|
|
108
134
|
/**
|
|
109
135
|
* X value of vector
|
|
110
136
|
* @default 0
|
|
@@ -122,8 +148,12 @@ export declare namespace Vector {
|
|
|
122
148
|
*/
|
|
123
149
|
y: number;
|
|
124
150
|
}
|
|
125
|
-
class SpanDto {
|
|
126
|
-
constructor(step?: number, min?: number, max?: number)
|
|
151
|
+
export class SpanDto {
|
|
152
|
+
constructor(step?: number, min?: number, max?: number) {
|
|
153
|
+
if (step !== undefined) { this.step = step; }
|
|
154
|
+
if (min !== undefined) { this.min = min; }
|
|
155
|
+
if (max !== undefined) { this.max = max; }
|
|
156
|
+
}
|
|
127
157
|
/**
|
|
128
158
|
* Step of the span
|
|
129
159
|
* @default 0.1
|
|
@@ -131,7 +161,7 @@ export declare namespace Vector {
|
|
|
131
161
|
* @maximum Infinity
|
|
132
162
|
* @step 0.1
|
|
133
163
|
*/
|
|
134
|
-
step
|
|
164
|
+
step = 0.1;
|
|
135
165
|
/**
|
|
136
166
|
* Min value of the span
|
|
137
167
|
* @default 0
|
|
@@ -139,7 +169,7 @@ export declare namespace Vector {
|
|
|
139
169
|
* @maximum Infinity
|
|
140
170
|
* @step 1
|
|
141
171
|
*/
|
|
142
|
-
min
|
|
172
|
+
min = 0;
|
|
143
173
|
/**
|
|
144
174
|
* Max value of the span
|
|
145
175
|
* @default 1
|
|
@@ -147,10 +177,15 @@ export declare namespace Vector {
|
|
|
147
177
|
* @maximum Infinity
|
|
148
178
|
* @step 1
|
|
149
179
|
*/
|
|
150
|
-
max
|
|
180
|
+
max = 1;
|
|
151
181
|
}
|
|
152
|
-
class SpanEaseItemsDto {
|
|
153
|
-
constructor(nrItems?: number, min?: number, max?: number, ease?: Math.easeEnum)
|
|
182
|
+
export class SpanEaseItemsDto {
|
|
183
|
+
constructor(nrItems?: number, min?: number, max?: number, ease?: Math.easeEnum) {
|
|
184
|
+
if (nrItems !== undefined) { this.nrItems = nrItems; }
|
|
185
|
+
if (min !== undefined) { this.min = min; }
|
|
186
|
+
if (max !== undefined) { this.max = max; }
|
|
187
|
+
if (ease !== undefined) { this.ease = ease; }
|
|
188
|
+
}
|
|
154
189
|
/**
|
|
155
190
|
* Nr of items in the span
|
|
156
191
|
* @default 100
|
|
@@ -158,7 +193,7 @@ export declare namespace Vector {
|
|
|
158
193
|
* @maximum Infinity
|
|
159
194
|
* @step 1
|
|
160
195
|
*/
|
|
161
|
-
nrItems
|
|
196
|
+
nrItems = 100;
|
|
162
197
|
/**
|
|
163
198
|
* Min value of the span
|
|
164
199
|
* @default 0
|
|
@@ -166,7 +201,7 @@ export declare namespace Vector {
|
|
|
166
201
|
* @maximum Infinity
|
|
167
202
|
* @step 1
|
|
168
203
|
*/
|
|
169
|
-
min
|
|
204
|
+
min = 0;
|
|
170
205
|
/**
|
|
171
206
|
* Max value of the span
|
|
172
207
|
* @default 1
|
|
@@ -174,20 +209,24 @@ export declare namespace Vector {
|
|
|
174
209
|
* @maximum Infinity
|
|
175
210
|
* @step 1
|
|
176
211
|
*/
|
|
177
|
-
max
|
|
212
|
+
max = 1;
|
|
178
213
|
/**
|
|
179
214
|
* Ease type
|
|
180
215
|
* @default easeInSine
|
|
181
216
|
*/
|
|
182
|
-
ease: Math.easeEnum;
|
|
217
|
+
ease: Math.easeEnum = Math.easeEnum.easeInSine;
|
|
183
218
|
/**
|
|
184
219
|
* Indicates wether only intervals should be outputed. This will output step lengths between the values.
|
|
185
220
|
* @default false
|
|
186
221
|
*/
|
|
187
|
-
intervals
|
|
222
|
+
intervals = false;
|
|
188
223
|
}
|
|
189
|
-
class SpanLinearItemsDto {
|
|
190
|
-
constructor(nrItems?: number, min?: number, max?: number)
|
|
224
|
+
export class SpanLinearItemsDto {
|
|
225
|
+
constructor(nrItems?: number, min?: number, max?: number) {
|
|
226
|
+
if (nrItems !== undefined) { this.nrItems = nrItems; }
|
|
227
|
+
if (min !== undefined) { this.min = min; }
|
|
228
|
+
if (max !== undefined) { this.max = max; }
|
|
229
|
+
}
|
|
191
230
|
/**
|
|
192
231
|
* Nr of items in the span
|
|
193
232
|
* @default 100
|
|
@@ -195,7 +234,7 @@ export declare namespace Vector {
|
|
|
195
234
|
* @maximum Infinity
|
|
196
235
|
* @step 1
|
|
197
236
|
*/
|
|
198
|
-
nrItems
|
|
237
|
+
nrItems = 100;
|
|
199
238
|
/**
|
|
200
239
|
* Min value of the span
|
|
201
240
|
* @default 0
|
|
@@ -203,7 +242,7 @@ export declare namespace Vector {
|
|
|
203
242
|
* @maximum Infinity
|
|
204
243
|
* @step 1
|
|
205
244
|
*/
|
|
206
|
-
min
|
|
245
|
+
min = 0;
|
|
207
246
|
/**
|
|
208
247
|
* Max value of the span
|
|
209
248
|
* @default 1
|
|
@@ -211,10 +250,14 @@ export declare namespace Vector {
|
|
|
211
250
|
* @maximum Infinity
|
|
212
251
|
* @step 1
|
|
213
252
|
*/
|
|
214
|
-
max
|
|
253
|
+
max = 1;
|
|
215
254
|
}
|
|
216
|
-
class RayPointDto {
|
|
217
|
-
constructor(point?: Base.Point3, distance?: number, vector?: number[])
|
|
255
|
+
export class RayPointDto {
|
|
256
|
+
constructor(point?: Base.Point3, distance?: number, vector?: number[]) {
|
|
257
|
+
if (point !== undefined) { this.point = point; }
|
|
258
|
+
if (distance !== undefined) { this.distance = distance; }
|
|
259
|
+
if (vector !== undefined) { this.vector = vector; }
|
|
260
|
+
}
|
|
218
261
|
/**
|
|
219
262
|
* Origin location of the ray
|
|
220
263
|
* @default undefined
|
|
@@ -234,16 +277,22 @@ export declare namespace Vector {
|
|
|
234
277
|
*/
|
|
235
278
|
vector: number[];
|
|
236
279
|
}
|
|
237
|
-
class VectorsDto {
|
|
238
|
-
constructor(vectors?: number[][])
|
|
280
|
+
export class VectorsDto {
|
|
281
|
+
constructor(vectors?: number[][]) {
|
|
282
|
+
if (vectors !== undefined) { this.vectors = vectors; }
|
|
283
|
+
}
|
|
239
284
|
/**
|
|
240
285
|
* Vectors array
|
|
241
286
|
* @default undefined
|
|
242
287
|
*/
|
|
243
288
|
vectors: number[][];
|
|
244
289
|
}
|
|
245
|
-
class FractionTwoVectorsDto {
|
|
246
|
-
constructor(fraction?: number, first?: Base.Vector3, second?: Base.Vector3)
|
|
290
|
+
export class FractionTwoVectorsDto {
|
|
291
|
+
constructor(fraction?: number, first?: Base.Vector3, second?: Base.Vector3) {
|
|
292
|
+
if (fraction !== undefined) { this.fraction = fraction; }
|
|
293
|
+
if (first !== undefined) { this.first = first; }
|
|
294
|
+
if (second !== undefined) { this.second = second; }
|
|
295
|
+
}
|
|
247
296
|
/**
|
|
248
297
|
* Fraction number
|
|
249
298
|
* @default 0.5
|
|
@@ -251,7 +300,7 @@ export declare namespace Vector {
|
|
|
251
300
|
* @maximum Infinity
|
|
252
301
|
* @step 0.1
|
|
253
302
|
*/
|
|
254
|
-
fraction
|
|
303
|
+
fraction = 0.5;
|
|
255
304
|
/**
|
|
256
305
|
* First vector
|
|
257
306
|
* @default undefined
|
|
@@ -263,8 +312,11 @@ export declare namespace Vector {
|
|
|
263
312
|
*/
|
|
264
313
|
second: Base.Vector3;
|
|
265
314
|
}
|
|
266
|
-
class VectorScalarDto {
|
|
267
|
-
constructor(scalar?: number, vector?: number[])
|
|
315
|
+
export class VectorScalarDto {
|
|
316
|
+
constructor(scalar?: number, vector?: number[]) {
|
|
317
|
+
if (scalar !== undefined) { this.scalar = scalar; }
|
|
318
|
+
if (vector !== undefined) { this.vector = vector; }
|
|
319
|
+
}
|
|
268
320
|
/**
|
|
269
321
|
* Scalar number
|
|
270
322
|
* @default 1
|
|
@@ -279,8 +331,12 @@ export declare namespace Vector {
|
|
|
279
331
|
*/
|
|
280
332
|
vector: number[];
|
|
281
333
|
}
|
|
282
|
-
class TwoVectorsReferenceDto {
|
|
283
|
-
constructor(reference?: number[], first?: Base.Vector3, second?: Base.Vector3)
|
|
334
|
+
export class TwoVectorsReferenceDto {
|
|
335
|
+
constructor(reference?: number[], first?: Base.Vector3, second?: Base.Vector3) {
|
|
336
|
+
if (reference !== undefined) { this.reference = reference; }
|
|
337
|
+
if (first !== undefined) { this.first = first; }
|
|
338
|
+
if (second !== undefined) { this.second = second; }
|
|
339
|
+
}
|
|
284
340
|
/**
|
|
285
341
|
* Reference vector
|
|
286
342
|
* @default undefined
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { Color } from "./color";
|
|
2
|
+
import { MathBitByBit } from "./math";
|
|
3
|
+
|
|
4
|
+
describe("Color unit tests", () => {
|
|
5
|
+
let color: Color;
|
|
6
|
+
|
|
7
|
+
beforeAll(async () => {
|
|
8
|
+
const math = new MathBitByBit();
|
|
9
|
+
color = new Color(math);
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it("should create hex color", () => {
|
|
13
|
+
const res = color.hexColor({ color: "#ff0000" });
|
|
14
|
+
expect(res).toEqual("#ff0000");
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it("should convert hex to rgb", () => {
|
|
18
|
+
const res = color.hexToRgb({ color: "#ff0000" });
|
|
19
|
+
expect(res).toEqual({ r: 255, g: 0, b: 0 });
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it("should convert hex to rgb mapped", () => {
|
|
23
|
+
const res = color.hexToRgbMapped({ color: "#ff0000", from: 0, to: 1 });
|
|
24
|
+
expect(res).toEqual({ r: 1, g: 0, b: 0 });
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it("should get red param", () => {
|
|
28
|
+
const res = color.getRedParam({ color: "#ff0000", from: 0, to: 1 });
|
|
29
|
+
expect(res).toEqual(1);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it("should get green param", () => {
|
|
33
|
+
const res = color.getGreenParam({ color: "#00ff00", from: 0, to: 1 });
|
|
34
|
+
expect(res).toEqual(1);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it("should get blue param", () => {
|
|
38
|
+
const res = color.getBlueParam({ color: "#0000ff", from: 0, to: 1 });
|
|
39
|
+
expect(res).toEqual(1);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it("should convert rgb to hex", () => {
|
|
43
|
+
const res = color.rgbToHex({ r: 255, g: 150, b: 23, min: 0, max: 255 });
|
|
44
|
+
expect(res).toEqual("#ff9617");
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it("should convert rgb to hex", () => {
|
|
48
|
+
const res = color.rgbToHex({ r: 1, g: 0.3, b: 0.6, min: 0, max: 1 });
|
|
49
|
+
expect(res).toEqual("#ff4d99");
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it("should convert rgb obj to hex", () => {
|
|
53
|
+
const res = color.rgbObjToHex({ rgb: { r: 1, g: 0.3, b: 0.6 }, min: 0, max: 1 });
|
|
54
|
+
expect(res).toEqual("#ff4d99");
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it("should get R from rgb obj", () => {
|
|
58
|
+
const res = color.rgbToRed({ rgb: { r: 1, g: 0.3, b: 0.6 } });
|
|
59
|
+
expect(res).toEqual(1);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it("should get G from rgb obj", () => {
|
|
63
|
+
const res = color.rgbToGreen({ rgb: { r: 1, g: 0.3, b: 0.6 } });
|
|
64
|
+
expect(res).toEqual(0.3);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it("should get B from rgb obj", () => {
|
|
68
|
+
const res = color.rgbToBlue({ rgb: { r: 1, g: 0.3, b: 0.6 } });
|
|
69
|
+
expect(res).toEqual(0.6);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it("should invert colors", () => {
|
|
73
|
+
const res = color.invert({ color: "#ff4d99", blackAndWhite: false });
|
|
74
|
+
expect(res).toEqual("#00b266");
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it("should invert colors to black and white", () => {
|
|
78
|
+
const res = color.invert({ color: "#ff4d99", blackAndWhite: true });
|
|
79
|
+
expect(res).toEqual("#ffffff");
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it("should invert colors to black and white", () => {
|
|
83
|
+
const res = color.invert({ color: "#ffeeaa", blackAndWhite: true });
|
|
84
|
+
expect(res).toEqual("#000000");
|
|
85
|
+
});
|
|
86
|
+
});
|