@bitbybit-dev/base 0.19.0-alpha.0
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/LICENSE +21 -0
- package/README.md +71 -0
- package/babel.config.cjs +14 -0
- package/babel.config.d.cts +5 -0
- package/index.d.ts +1 -0
- package/index.js +4 -0
- package/lib/api/index.d.ts +1 -0
- package/lib/api/index.js +1 -0
- package/lib/api/inputs/base-inputs.d.ts +35 -0
- package/lib/api/inputs/base-inputs.js +1 -0
- package/lib/api/inputs/color-inputs.d.ts +122 -0
- package/lib/api/inputs/color-inputs.js +164 -0
- package/lib/api/inputs/index.d.ts +8 -0
- package/lib/api/inputs/index.js +8 -0
- package/lib/api/inputs/inputs.d.ts +10 -0
- package/lib/api/inputs/inputs.js +10 -0
- package/lib/api/inputs/lists-inputs.d.ts +478 -0
- package/lib/api/inputs/lists-inputs.js +576 -0
- package/lib/api/inputs/logic-inputs.d.ts +163 -0
- package/lib/api/inputs/logic-inputs.js +111 -0
- package/lib/api/inputs/math-inputs.d.ts +311 -0
- package/lib/api/inputs/math-inputs.js +391 -0
- package/lib/api/inputs/point-inputs.d.ts +446 -0
- package/lib/api/inputs/point-inputs.js +521 -0
- package/lib/api/inputs/text-inputs.d.ts +83 -0
- package/lib/api/inputs/text-inputs.js +120 -0
- package/lib/api/inputs/transforms-inputs.d.ts +136 -0
- package/lib/api/inputs/transforms-inputs.js +200 -0
- package/lib/api/inputs/vector-inputs.d.ts +300 -0
- package/lib/api/inputs/vector-inputs.js +304 -0
- package/lib/api/services/color.d.ts +114 -0
- package/lib/api/services/color.js +170 -0
- package/lib/api/services/geometry-helper.d.ts +15 -0
- package/lib/api/services/geometry-helper.js +151 -0
- package/lib/api/services/index.d.ts +9 -0
- package/lib/api/services/index.js +9 -0
- package/lib/api/services/lists.d.ts +287 -0
- package/lib/api/services/lists.js +682 -0
- package/lib/api/services/logic.d.ts +99 -0
- package/lib/api/services/logic.js +203 -0
- package/lib/api/services/math.d.ts +349 -0
- package/lib/api/services/math.js +621 -0
- package/lib/api/services/point.d.ts +223 -0
- package/lib/api/services/point.js +351 -0
- package/lib/api/services/text.d.ts +69 -0
- package/lib/api/services/text.js +84 -0
- package/lib/api/services/transforms.d.ts +122 -0
- package/lib/api/services/transforms.js +256 -0
- package/lib/api/services/vector.d.ts +320 -0
- package/lib/api/services/vector.js +468 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/package.json +93 -0
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
import { Math } from "./inputs";
|
|
2
|
+
export var Vector;
|
|
3
|
+
(function (Vector) {
|
|
4
|
+
class TwoVectorsDto {
|
|
5
|
+
constructor(first, second) {
|
|
6
|
+
if (first !== undefined) {
|
|
7
|
+
this.first = first;
|
|
8
|
+
}
|
|
9
|
+
if (second !== undefined) {
|
|
10
|
+
this.second = second;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
Vector.TwoVectorsDto = TwoVectorsDto;
|
|
15
|
+
class VectorBoolDto {
|
|
16
|
+
constructor(vector) {
|
|
17
|
+
if (vector !== undefined) {
|
|
18
|
+
this.vector = vector;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
Vector.VectorBoolDto = VectorBoolDto;
|
|
23
|
+
class RemoveAllDuplicateVectorsDto {
|
|
24
|
+
constructor(vectors, tolerance) {
|
|
25
|
+
/**
|
|
26
|
+
* Tolerance value
|
|
27
|
+
* @default 1e-7
|
|
28
|
+
* @minimum 0
|
|
29
|
+
* @maximum Infinity
|
|
30
|
+
*/
|
|
31
|
+
this.tolerance = 1e-7;
|
|
32
|
+
if (vectors !== undefined) {
|
|
33
|
+
this.vectors = vectors;
|
|
34
|
+
}
|
|
35
|
+
if (tolerance !== undefined) {
|
|
36
|
+
this.tolerance = tolerance;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
Vector.RemoveAllDuplicateVectorsDto = RemoveAllDuplicateVectorsDto;
|
|
41
|
+
class RemoveConsecutiveDuplicateVectorsDto {
|
|
42
|
+
constructor(vectors, checkFirstAndLast, tolerance) {
|
|
43
|
+
/**
|
|
44
|
+
* Check first and last vectors
|
|
45
|
+
* @default false
|
|
46
|
+
*/
|
|
47
|
+
this.checkFirstAndLast = false;
|
|
48
|
+
/**
|
|
49
|
+
* Tolerance value
|
|
50
|
+
* @default 1e-7
|
|
51
|
+
* @minimum 0
|
|
52
|
+
* @maximum Infinity
|
|
53
|
+
*/
|
|
54
|
+
this.tolerance = 1e-7;
|
|
55
|
+
if (vectors !== undefined) {
|
|
56
|
+
this.vectors = vectors;
|
|
57
|
+
}
|
|
58
|
+
if (checkFirstAndLast !== undefined) {
|
|
59
|
+
this.checkFirstAndLast = checkFirstAndLast;
|
|
60
|
+
}
|
|
61
|
+
if (tolerance !== undefined) {
|
|
62
|
+
this.tolerance = tolerance;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
Vector.RemoveConsecutiveDuplicateVectorsDto = RemoveConsecutiveDuplicateVectorsDto;
|
|
67
|
+
class VectorDto {
|
|
68
|
+
constructor(vector) {
|
|
69
|
+
if (vector !== undefined) {
|
|
70
|
+
this.vector = vector;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
Vector.VectorDto = VectorDto;
|
|
75
|
+
class RangeMaxDto {
|
|
76
|
+
constructor(max) {
|
|
77
|
+
if (max !== undefined) {
|
|
78
|
+
this.max = max;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
Vector.RangeMaxDto = RangeMaxDto;
|
|
83
|
+
class VectorXYZDto {
|
|
84
|
+
constructor(x, y, z) {
|
|
85
|
+
if (x !== undefined) {
|
|
86
|
+
this.x = x;
|
|
87
|
+
}
|
|
88
|
+
if (y !== undefined) {
|
|
89
|
+
this.y = y;
|
|
90
|
+
}
|
|
91
|
+
if (z !== undefined) {
|
|
92
|
+
this.z = z;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
Vector.VectorXYZDto = VectorXYZDto;
|
|
97
|
+
class VectorXYDto {
|
|
98
|
+
constructor(x, y) {
|
|
99
|
+
if (x !== undefined) {
|
|
100
|
+
this.x = x;
|
|
101
|
+
}
|
|
102
|
+
if (y !== undefined) {
|
|
103
|
+
this.y = y;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
Vector.VectorXYDto = VectorXYDto;
|
|
108
|
+
class SpanDto {
|
|
109
|
+
constructor(step, min, max) {
|
|
110
|
+
/**
|
|
111
|
+
* Step of the span
|
|
112
|
+
* @default 0.1
|
|
113
|
+
* @minimum -Infinity
|
|
114
|
+
* @maximum Infinity
|
|
115
|
+
* @step 0.1
|
|
116
|
+
*/
|
|
117
|
+
this.step = 0.1;
|
|
118
|
+
/**
|
|
119
|
+
* Min value of the span
|
|
120
|
+
* @default 0
|
|
121
|
+
* @minimum -Infinity
|
|
122
|
+
* @maximum Infinity
|
|
123
|
+
* @step 1
|
|
124
|
+
*/
|
|
125
|
+
this.min = 0;
|
|
126
|
+
/**
|
|
127
|
+
* Max value of the span
|
|
128
|
+
* @default 1
|
|
129
|
+
* @minimum -Infinity
|
|
130
|
+
* @maximum Infinity
|
|
131
|
+
* @step 1
|
|
132
|
+
*/
|
|
133
|
+
this.max = 1;
|
|
134
|
+
if (step !== undefined) {
|
|
135
|
+
this.step = step;
|
|
136
|
+
}
|
|
137
|
+
if (min !== undefined) {
|
|
138
|
+
this.min = min;
|
|
139
|
+
}
|
|
140
|
+
if (max !== undefined) {
|
|
141
|
+
this.max = max;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
Vector.SpanDto = SpanDto;
|
|
146
|
+
class SpanEaseItemsDto {
|
|
147
|
+
constructor(nrItems, min, max, ease) {
|
|
148
|
+
/**
|
|
149
|
+
* Nr of items in the span
|
|
150
|
+
* @default 100
|
|
151
|
+
* @minimum 2
|
|
152
|
+
* @maximum Infinity
|
|
153
|
+
* @step 1
|
|
154
|
+
*/
|
|
155
|
+
this.nrItems = 100;
|
|
156
|
+
/**
|
|
157
|
+
* Min value of the span
|
|
158
|
+
* @default 0
|
|
159
|
+
* @minimum -Infinity
|
|
160
|
+
* @maximum Infinity
|
|
161
|
+
* @step 1
|
|
162
|
+
*/
|
|
163
|
+
this.min = 0;
|
|
164
|
+
/**
|
|
165
|
+
* Max value of the span
|
|
166
|
+
* @default 1
|
|
167
|
+
* @minimum -Infinity
|
|
168
|
+
* @maximum Infinity
|
|
169
|
+
* @step 1
|
|
170
|
+
*/
|
|
171
|
+
this.max = 1;
|
|
172
|
+
/**
|
|
173
|
+
* Ease type
|
|
174
|
+
* @default easeInSine
|
|
175
|
+
*/
|
|
176
|
+
this.ease = Math.easeEnum.easeInSine;
|
|
177
|
+
/**
|
|
178
|
+
* Indicates wether only intervals should be outputed. This will output step lengths between the values.
|
|
179
|
+
* @default false
|
|
180
|
+
*/
|
|
181
|
+
this.intervals = false;
|
|
182
|
+
if (nrItems !== undefined) {
|
|
183
|
+
this.nrItems = nrItems;
|
|
184
|
+
}
|
|
185
|
+
if (min !== undefined) {
|
|
186
|
+
this.min = min;
|
|
187
|
+
}
|
|
188
|
+
if (max !== undefined) {
|
|
189
|
+
this.max = max;
|
|
190
|
+
}
|
|
191
|
+
if (ease !== undefined) {
|
|
192
|
+
this.ease = ease;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
Vector.SpanEaseItemsDto = SpanEaseItemsDto;
|
|
197
|
+
class SpanLinearItemsDto {
|
|
198
|
+
constructor(nrItems, min, max) {
|
|
199
|
+
/**
|
|
200
|
+
* Nr of items in the span
|
|
201
|
+
* @default 100
|
|
202
|
+
* @minimum 2
|
|
203
|
+
* @maximum Infinity
|
|
204
|
+
* @step 1
|
|
205
|
+
*/
|
|
206
|
+
this.nrItems = 100;
|
|
207
|
+
/**
|
|
208
|
+
* Min value of the span
|
|
209
|
+
* @default 0
|
|
210
|
+
* @minimum -Infinity
|
|
211
|
+
* @maximum Infinity
|
|
212
|
+
* @step 1
|
|
213
|
+
*/
|
|
214
|
+
this.min = 0;
|
|
215
|
+
/**
|
|
216
|
+
* Max value of the span
|
|
217
|
+
* @default 1
|
|
218
|
+
* @minimum -Infinity
|
|
219
|
+
* @maximum Infinity
|
|
220
|
+
* @step 1
|
|
221
|
+
*/
|
|
222
|
+
this.max = 1;
|
|
223
|
+
if (nrItems !== undefined) {
|
|
224
|
+
this.nrItems = nrItems;
|
|
225
|
+
}
|
|
226
|
+
if (min !== undefined) {
|
|
227
|
+
this.min = min;
|
|
228
|
+
}
|
|
229
|
+
if (max !== undefined) {
|
|
230
|
+
this.max = max;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
Vector.SpanLinearItemsDto = SpanLinearItemsDto;
|
|
235
|
+
class RayPointDto {
|
|
236
|
+
constructor(point, distance, vector) {
|
|
237
|
+
if (point !== undefined) {
|
|
238
|
+
this.point = point;
|
|
239
|
+
}
|
|
240
|
+
if (distance !== undefined) {
|
|
241
|
+
this.distance = distance;
|
|
242
|
+
}
|
|
243
|
+
if (vector !== undefined) {
|
|
244
|
+
this.vector = vector;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
Vector.RayPointDto = RayPointDto;
|
|
249
|
+
class VectorsDto {
|
|
250
|
+
constructor(vectors) {
|
|
251
|
+
if (vectors !== undefined) {
|
|
252
|
+
this.vectors = vectors;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
Vector.VectorsDto = VectorsDto;
|
|
257
|
+
class FractionTwoVectorsDto {
|
|
258
|
+
constructor(fraction, first, second) {
|
|
259
|
+
/**
|
|
260
|
+
* Fraction number
|
|
261
|
+
* @default 0.5
|
|
262
|
+
* @minimum -Infinity
|
|
263
|
+
* @maximum Infinity
|
|
264
|
+
* @step 0.1
|
|
265
|
+
*/
|
|
266
|
+
this.fraction = 0.5;
|
|
267
|
+
if (fraction !== undefined) {
|
|
268
|
+
this.fraction = fraction;
|
|
269
|
+
}
|
|
270
|
+
if (first !== undefined) {
|
|
271
|
+
this.first = first;
|
|
272
|
+
}
|
|
273
|
+
if (second !== undefined) {
|
|
274
|
+
this.second = second;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
Vector.FractionTwoVectorsDto = FractionTwoVectorsDto;
|
|
279
|
+
class VectorScalarDto {
|
|
280
|
+
constructor(scalar, vector) {
|
|
281
|
+
if (scalar !== undefined) {
|
|
282
|
+
this.scalar = scalar;
|
|
283
|
+
}
|
|
284
|
+
if (vector !== undefined) {
|
|
285
|
+
this.vector = vector;
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
Vector.VectorScalarDto = VectorScalarDto;
|
|
290
|
+
class TwoVectorsReferenceDto {
|
|
291
|
+
constructor(reference, first, second) {
|
|
292
|
+
if (reference !== undefined) {
|
|
293
|
+
this.reference = reference;
|
|
294
|
+
}
|
|
295
|
+
if (first !== undefined) {
|
|
296
|
+
this.first = first;
|
|
297
|
+
}
|
|
298
|
+
if (second !== undefined) {
|
|
299
|
+
this.second = second;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
Vector.TwoVectorsReferenceDto = TwoVectorsReferenceDto;
|
|
304
|
+
})(Vector || (Vector = {}));
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import * as Inputs from "../inputs/inputs";
|
|
2
|
+
import { MathBitByBit } from "./math";
|
|
3
|
+
export declare class Color {
|
|
4
|
+
private readonly math;
|
|
5
|
+
constructor(math: MathBitByBit);
|
|
6
|
+
/**
|
|
7
|
+
* Creates a hex color
|
|
8
|
+
* @param inputs Color hex
|
|
9
|
+
* @returns color string
|
|
10
|
+
* @group create
|
|
11
|
+
* @shortname color
|
|
12
|
+
* @drawable false
|
|
13
|
+
*/
|
|
14
|
+
hexColor(inputs: Inputs.Color.HexDto): Inputs.Base.Color;
|
|
15
|
+
/**
|
|
16
|
+
* Creates rgb color from hex
|
|
17
|
+
* @param inputs Color hex
|
|
18
|
+
* @returns rgb color
|
|
19
|
+
* @group convert
|
|
20
|
+
* @shortname hex to rgb
|
|
21
|
+
* @drawable false
|
|
22
|
+
*/
|
|
23
|
+
hexToRgb(inputs: Inputs.Color.HexDto): Inputs.Base.ColorRGB;
|
|
24
|
+
/**
|
|
25
|
+
* Creates hex color from rgb
|
|
26
|
+
* @param inputs Color hext
|
|
27
|
+
* @returns hex color
|
|
28
|
+
* @group convert
|
|
29
|
+
* @shortname rgb to hex
|
|
30
|
+
* @drawable false
|
|
31
|
+
*/
|
|
32
|
+
rgbToHex(inputs: Inputs.Color.RGBMinMaxDto): Inputs.Base.Color;
|
|
33
|
+
/**
|
|
34
|
+
* Creates hex color from rgb obj that contains {r, g, b} properties in certain range
|
|
35
|
+
* @param inputs Color hext
|
|
36
|
+
* @returns hex color string
|
|
37
|
+
* @group convert
|
|
38
|
+
* @shortname rgb obj to hex
|
|
39
|
+
* @drawable false
|
|
40
|
+
*/
|
|
41
|
+
rgbObjToHex(inputs: Inputs.Color.RGBObjectMaxDto): Inputs.Base.Color;
|
|
42
|
+
/**
|
|
43
|
+
* Creates rgb color from hex and maps to different range if needed
|
|
44
|
+
* @param inputs Color hext
|
|
45
|
+
* @returns rgb color
|
|
46
|
+
* @group convert
|
|
47
|
+
* @shortname hex to rgb mapped
|
|
48
|
+
* @drawable false
|
|
49
|
+
*/
|
|
50
|
+
hexToRgbMapped(inputs: Inputs.Color.HexDtoMapped): Inputs.Base.ColorRGB;
|
|
51
|
+
/**
|
|
52
|
+
* Get red param
|
|
53
|
+
* @param inputs Color hext
|
|
54
|
+
* @returns rgb color
|
|
55
|
+
* @group hex to
|
|
56
|
+
* @shortname red
|
|
57
|
+
* @drawable false
|
|
58
|
+
*/
|
|
59
|
+
getRedParam(inputs: Inputs.Color.HexDtoMapped): number;
|
|
60
|
+
/**
|
|
61
|
+
* Get green param
|
|
62
|
+
* @param inputs Color hext
|
|
63
|
+
* @returns rgb color
|
|
64
|
+
* @group hex to
|
|
65
|
+
* @shortname green
|
|
66
|
+
* @drawable false
|
|
67
|
+
*/
|
|
68
|
+
getGreenParam(inputs: Inputs.Color.HexDtoMapped): number;
|
|
69
|
+
/**
|
|
70
|
+
* Get blue param
|
|
71
|
+
* @param inputs Color hext
|
|
72
|
+
* @returns blue param
|
|
73
|
+
* @group hex to
|
|
74
|
+
* @shortname blue
|
|
75
|
+
* @drawable false
|
|
76
|
+
*/
|
|
77
|
+
getBlueParam(inputs: Inputs.Color.HexDtoMapped): number;
|
|
78
|
+
/**
|
|
79
|
+
* RGB to red
|
|
80
|
+
* @param inputs Color rgb
|
|
81
|
+
* @returns red param
|
|
82
|
+
* @group rgb to
|
|
83
|
+
* @shortname red
|
|
84
|
+
* @drawable false
|
|
85
|
+
*/
|
|
86
|
+
rgbToRed(inputs: Inputs.Color.RGBObjectDto): number;
|
|
87
|
+
/**
|
|
88
|
+
* RGB to green
|
|
89
|
+
* @param inputs Color rgb
|
|
90
|
+
* @returns green param
|
|
91
|
+
* @group rgb to
|
|
92
|
+
* @shortname green
|
|
93
|
+
* @drawable false
|
|
94
|
+
*/
|
|
95
|
+
rgbToGreen(inputs: Inputs.Color.RGBObjectDto): number;
|
|
96
|
+
/**
|
|
97
|
+
* RGB to blue
|
|
98
|
+
* @param inputs Color rgb
|
|
99
|
+
* @returns blue param
|
|
100
|
+
* @group rgb to
|
|
101
|
+
* @shortname blue
|
|
102
|
+
* @drawable false
|
|
103
|
+
*/
|
|
104
|
+
rgbToBlue(inputs: Inputs.Color.RGBObjectDto): number;
|
|
105
|
+
/**
|
|
106
|
+
* Invert color
|
|
107
|
+
* @param inputs hex color and black and white option
|
|
108
|
+
* @returns inverted color
|
|
109
|
+
* @group hex to
|
|
110
|
+
* @shortname invert color
|
|
111
|
+
* @drawable false
|
|
112
|
+
*/
|
|
113
|
+
invert(inputs: Inputs.Color.InvertHexDto): Inputs.Base.Color;
|
|
114
|
+
}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
export class Color {
|
|
2
|
+
constructor(math) {
|
|
3
|
+
this.math = math;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Creates a hex color
|
|
7
|
+
* @param inputs Color hex
|
|
8
|
+
* @returns color string
|
|
9
|
+
* @group create
|
|
10
|
+
* @shortname color
|
|
11
|
+
* @drawable false
|
|
12
|
+
*/
|
|
13
|
+
hexColor(inputs) {
|
|
14
|
+
return inputs.color;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Creates rgb color from hex
|
|
18
|
+
* @param inputs Color hex
|
|
19
|
+
* @returns rgb color
|
|
20
|
+
* @group convert
|
|
21
|
+
* @shortname hex to rgb
|
|
22
|
+
* @drawable false
|
|
23
|
+
*/
|
|
24
|
+
hexToRgb(inputs) {
|
|
25
|
+
const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(inputs.color);
|
|
26
|
+
return result ? {
|
|
27
|
+
r: parseInt(result[1], 16),
|
|
28
|
+
g: parseInt(result[2], 16),
|
|
29
|
+
b: parseInt(result[3], 16)
|
|
30
|
+
} : undefined;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Creates hex color from rgb
|
|
34
|
+
* @param inputs Color hext
|
|
35
|
+
* @returns hex color
|
|
36
|
+
* @group convert
|
|
37
|
+
* @shortname rgb to hex
|
|
38
|
+
* @drawable false
|
|
39
|
+
*/
|
|
40
|
+
rgbToHex(inputs) {
|
|
41
|
+
let r = inputs.r;
|
|
42
|
+
let g = inputs.g;
|
|
43
|
+
let b = inputs.b;
|
|
44
|
+
// sometimes rgb values are in 0 - 100 or 0 - 1 ranges
|
|
45
|
+
// so we need to remap them to 0 - 255
|
|
46
|
+
if (inputs.max !== 255) {
|
|
47
|
+
r = Math.round(this.math.remap({ number: r, fromLow: inputs.min, fromHigh: inputs.max, toLow: 0, toHigh: 255 }));
|
|
48
|
+
g = Math.round(this.math.remap({ number: g, fromLow: inputs.min, fromHigh: inputs.max, toLow: 0, toHigh: 255 }));
|
|
49
|
+
b = Math.round(this.math.remap({ number: b, fromLow: inputs.min, fromHigh: inputs.max, toLow: 0, toHigh: 255 }));
|
|
50
|
+
}
|
|
51
|
+
const s = `#${Number(0x1000000 + r * 0x10000 + g * 0x100 + b).toString(16).substring(1, 7)}`;
|
|
52
|
+
return s;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Creates hex color from rgb obj that contains {r, g, b} properties in certain range
|
|
56
|
+
* @param inputs Color hext
|
|
57
|
+
* @returns hex color string
|
|
58
|
+
* @group convert
|
|
59
|
+
* @shortname rgb obj to hex
|
|
60
|
+
* @drawable false
|
|
61
|
+
*/
|
|
62
|
+
rgbObjToHex(inputs) {
|
|
63
|
+
return this.rgbToHex({ r: inputs.rgb.r, g: inputs.rgb.g, b: inputs.rgb.b, min: inputs.min, max: inputs.max });
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Creates rgb color from hex and maps to different range if needed
|
|
67
|
+
* @param inputs Color hext
|
|
68
|
+
* @returns rgb color
|
|
69
|
+
* @group convert
|
|
70
|
+
* @shortname hex to rgb mapped
|
|
71
|
+
* @drawable false
|
|
72
|
+
*/
|
|
73
|
+
hexToRgbMapped(inputs) {
|
|
74
|
+
const rgb = this.hexToRgb(inputs);
|
|
75
|
+
return {
|
|
76
|
+
r: this.math.remap({ number: rgb.r, fromLow: 0, fromHigh: 255, toLow: inputs.from, toHigh: inputs.to }),
|
|
77
|
+
g: this.math.remap({ number: rgb.g, fromLow: 0, fromHigh: 255, toLow: inputs.from, toHigh: inputs.to }),
|
|
78
|
+
b: this.math.remap({ number: rgb.b, fromLow: 0, fromHigh: 255, toLow: inputs.from, toHigh: inputs.to }),
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Get red param
|
|
83
|
+
* @param inputs Color hext
|
|
84
|
+
* @returns rgb color
|
|
85
|
+
* @group hex to
|
|
86
|
+
* @shortname red
|
|
87
|
+
* @drawable false
|
|
88
|
+
*/
|
|
89
|
+
getRedParam(inputs) {
|
|
90
|
+
const rgb = this.hexToRgbMapped(inputs);
|
|
91
|
+
return rgb.r;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Get green param
|
|
95
|
+
* @param inputs Color hext
|
|
96
|
+
* @returns rgb color
|
|
97
|
+
* @group hex to
|
|
98
|
+
* @shortname green
|
|
99
|
+
* @drawable false
|
|
100
|
+
*/
|
|
101
|
+
getGreenParam(inputs) {
|
|
102
|
+
const rgb = this.hexToRgbMapped(inputs);
|
|
103
|
+
return rgb.g;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Get blue param
|
|
107
|
+
* @param inputs Color hext
|
|
108
|
+
* @returns blue param
|
|
109
|
+
* @group hex to
|
|
110
|
+
* @shortname blue
|
|
111
|
+
* @drawable false
|
|
112
|
+
*/
|
|
113
|
+
getBlueParam(inputs) {
|
|
114
|
+
const rgb = this.hexToRgbMapped(inputs);
|
|
115
|
+
return rgb.b;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* RGB to red
|
|
119
|
+
* @param inputs Color rgb
|
|
120
|
+
* @returns red param
|
|
121
|
+
* @group rgb to
|
|
122
|
+
* @shortname red
|
|
123
|
+
* @drawable false
|
|
124
|
+
*/
|
|
125
|
+
rgbToRed(inputs) {
|
|
126
|
+
return inputs.rgb.r;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* RGB to green
|
|
130
|
+
* @param inputs Color rgb
|
|
131
|
+
* @returns green param
|
|
132
|
+
* @group rgb to
|
|
133
|
+
* @shortname green
|
|
134
|
+
* @drawable false
|
|
135
|
+
*/
|
|
136
|
+
rgbToGreen(inputs) {
|
|
137
|
+
return inputs.rgb.g;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* RGB to blue
|
|
141
|
+
* @param inputs Color rgb
|
|
142
|
+
* @returns blue param
|
|
143
|
+
* @group rgb to
|
|
144
|
+
* @shortname blue
|
|
145
|
+
* @drawable false
|
|
146
|
+
*/
|
|
147
|
+
rgbToBlue(inputs) {
|
|
148
|
+
return inputs.rgb.b;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Invert color
|
|
152
|
+
* @param inputs hex color and black and white option
|
|
153
|
+
* @returns inverted color
|
|
154
|
+
* @group hex to
|
|
155
|
+
* @shortname invert color
|
|
156
|
+
* @drawable false
|
|
157
|
+
*/
|
|
158
|
+
invert(inputs) {
|
|
159
|
+
const { r, g, b } = this.hexToRgbMapped({ color: inputs.color, from: 0, to: 255 });
|
|
160
|
+
if (inputs.blackAndWhite) {
|
|
161
|
+
return (r * 0.299 + g * 0.587 + b * 0.114) > 186
|
|
162
|
+
? "#000000"
|
|
163
|
+
: "#ffffff";
|
|
164
|
+
}
|
|
165
|
+
const rInv = (255 - r);
|
|
166
|
+
const gInv = (255 - g);
|
|
167
|
+
const bInv = (255 - b);
|
|
168
|
+
return this.rgbToHex({ r: rInv, g: gInv, b: bInv, min: 0, max: 255 });
|
|
169
|
+
}
|
|
170
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as Inputs from "../inputs/inputs";
|
|
2
|
+
export declare class GeometryHelper {
|
|
3
|
+
transformControlPoints(transformation: number[][] | number[][][], transformedControlPoints: Inputs.Base.Point3[]): Inputs.Base.Point3[];
|
|
4
|
+
getFlatTransformations(transformation: number[][] | number[][][]): number[][];
|
|
5
|
+
getArrayDepth: (value: any) => number;
|
|
6
|
+
transformPointsByMatrixArray(points: Inputs.Base.Point3[], transform: number[]): Inputs.Base.Point3[];
|
|
7
|
+
transformPointsCoordinates(points: Inputs.Base.Point3[], transform: number[]): Inputs.Base.Point3[];
|
|
8
|
+
removeAllDuplicateVectors(vectors: number[][], tolerance?: number): number[][];
|
|
9
|
+
removeConsecutiveVectorDuplicates(vectors: number[][], checkFirstAndLast?: boolean, tolerance?: number): number[][];
|
|
10
|
+
vectorsTheSame(vec1: number[], vec2: number[], tolerance: number): boolean;
|
|
11
|
+
approxEq(num1: number, num2: number, tolerance: number): boolean;
|
|
12
|
+
removeConsecutivePointDuplicates(points: Inputs.Base.Point3[], checkFirstAndLast?: boolean, tolerance?: number): Inputs.Base.Point3[];
|
|
13
|
+
arePointsTheSame(pointA: Inputs.Base.Point3 | Inputs.Base.Point2, pointB: Inputs.Base.Point3 | Inputs.Base.Point2, tolerance: number): boolean;
|
|
14
|
+
private transformCoordinates;
|
|
15
|
+
}
|