@bitbybit-dev/base 1.0.0-rc.0 → 1.0.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/babel.config.cjs +1 -1
- package/babel.config.d.cts +1 -1
- package/lib/api/GlobalCDNProvider.js +1 -1
- package/lib/api/inputs/base-inputs.d.ts +6 -0
- package/lib/api/inputs/color-inputs.d.ts +150 -0
- package/lib/api/inputs/color-inputs.js +220 -0
- package/lib/api/inputs/math-inputs.d.ts +8 -0
- package/lib/api/inputs/math-inputs.js +13 -0
- package/lib/api/models/simplex.js +2 -2
- package/lib/api/services/color.d.ts +55 -1
- package/lib/api/services/color.js +67 -1
- package/lib/api/services/helpers/dxf/dxf-generator.js +10 -10
- package/lib/api/services/math.d.ts +12 -0
- package/lib/api/services/math.js +122 -0
- package/lib/api/services/point.js +1 -1
- package/lib/api/services/transforms.js +3 -3
- package/package.json +13 -14
package/babel.config.cjs
CHANGED
package/babel.config.d.cts
CHANGED
|
@@ -8,6 +8,156 @@ export declare namespace Color {
|
|
|
8
8
|
*/
|
|
9
9
|
color: Base.Color;
|
|
10
10
|
}
|
|
11
|
+
class Rgb255Dto {
|
|
12
|
+
constructor(colorRgb?: Base.ColorRGB);
|
|
13
|
+
/**
|
|
14
|
+
* Color rgb
|
|
15
|
+
* @default { "r": 0, "g": 0, "b": 255 }
|
|
16
|
+
* @min 0
|
|
17
|
+
* @max 255
|
|
18
|
+
*/
|
|
19
|
+
colorRgb: Base.ColorRGB;
|
|
20
|
+
}
|
|
21
|
+
class Rgb1Dto {
|
|
22
|
+
constructor(colorRgb?: Base.ColorRGB);
|
|
23
|
+
/**
|
|
24
|
+
* Color rgb
|
|
25
|
+
* @default { "r": 0, "g": 0, "b": 1 }
|
|
26
|
+
* @min 0
|
|
27
|
+
* @max 1
|
|
28
|
+
*/
|
|
29
|
+
colorRgb: Base.ColorRGB;
|
|
30
|
+
}
|
|
31
|
+
class Rgba255Dto {
|
|
32
|
+
constructor(colorRgba?: Base.ColorRGBA);
|
|
33
|
+
/**
|
|
34
|
+
* Color rgba
|
|
35
|
+
* @default { "r": 0, "g": 0, "b": 255, "a": 1 }
|
|
36
|
+
* @min 0
|
|
37
|
+
* @max 255
|
|
38
|
+
*/
|
|
39
|
+
colorRgba: Base.ColorRGBA;
|
|
40
|
+
}
|
|
41
|
+
class Rgba1Dto {
|
|
42
|
+
constructor(colorRgba?: Base.ColorRGBA);
|
|
43
|
+
/**
|
|
44
|
+
* Color rgba
|
|
45
|
+
* @default { "r": 0, "g": 0, "b": 1, "a": 1 }
|
|
46
|
+
* @min 0
|
|
47
|
+
* @max 1
|
|
48
|
+
*/
|
|
49
|
+
colorRgba: Base.ColorRGBA;
|
|
50
|
+
}
|
|
51
|
+
class RgbAttomic255Dto {
|
|
52
|
+
constructor(r?: number, g?: number, b?: number);
|
|
53
|
+
/**
|
|
54
|
+
* Red component
|
|
55
|
+
* @default 0
|
|
56
|
+
* @minimum 0
|
|
57
|
+
* @maximum 255
|
|
58
|
+
*/
|
|
59
|
+
r: number;
|
|
60
|
+
/**
|
|
61
|
+
* Green component
|
|
62
|
+
* @default 0
|
|
63
|
+
* @minimum 0
|
|
64
|
+
* @maximum 255
|
|
65
|
+
*/
|
|
66
|
+
g: number;
|
|
67
|
+
/**
|
|
68
|
+
* Blue component
|
|
69
|
+
* @default 255
|
|
70
|
+
* @minimum 0
|
|
71
|
+
* @maximum 255
|
|
72
|
+
*/
|
|
73
|
+
b: number;
|
|
74
|
+
}
|
|
75
|
+
class RgbaAttomic255Dto {
|
|
76
|
+
constructor(r?: number, g?: number, b?: number, a?: number);
|
|
77
|
+
/**
|
|
78
|
+
* Red component
|
|
79
|
+
* @default 0
|
|
80
|
+
* @minimum 0
|
|
81
|
+
* @maximum 255
|
|
82
|
+
*/
|
|
83
|
+
r: number;
|
|
84
|
+
/**
|
|
85
|
+
* Green component
|
|
86
|
+
* @default 0
|
|
87
|
+
* @minimum 0
|
|
88
|
+
* @maximum 255
|
|
89
|
+
*/
|
|
90
|
+
g: number;
|
|
91
|
+
/**
|
|
92
|
+
* Blue component
|
|
93
|
+
* @default 255
|
|
94
|
+
* @minimum 0
|
|
95
|
+
* @maximum 255
|
|
96
|
+
*/
|
|
97
|
+
b: number;
|
|
98
|
+
/**
|
|
99
|
+
* Alpha component
|
|
100
|
+
* @default 1
|
|
101
|
+
* @minimum 0
|
|
102
|
+
* @maximum 1
|
|
103
|
+
*/
|
|
104
|
+
a: number;
|
|
105
|
+
}
|
|
106
|
+
class RgbAttomic1Dto {
|
|
107
|
+
constructor(r?: number, g?: number, b?: number);
|
|
108
|
+
/**
|
|
109
|
+
* Red component
|
|
110
|
+
* @default 0
|
|
111
|
+
* @minimum 0
|
|
112
|
+
* @maximum 1
|
|
113
|
+
*/
|
|
114
|
+
r: number;
|
|
115
|
+
/**
|
|
116
|
+
* Green component
|
|
117
|
+
* @default 0
|
|
118
|
+
* @minimum 0
|
|
119
|
+
* @maximum 1
|
|
120
|
+
*/
|
|
121
|
+
g: number;
|
|
122
|
+
/**
|
|
123
|
+
* Blue component
|
|
124
|
+
* @default 1
|
|
125
|
+
* @minimum 0
|
|
126
|
+
* @maximum 1
|
|
127
|
+
*/
|
|
128
|
+
b: number;
|
|
129
|
+
}
|
|
130
|
+
class RgbaAttomic1Dto {
|
|
131
|
+
constructor(r?: number, g?: number, b?: number, a?: number);
|
|
132
|
+
/**
|
|
133
|
+
* Red component
|
|
134
|
+
* @default 0
|
|
135
|
+
* @minimum 0
|
|
136
|
+
* @maximum 1
|
|
137
|
+
*/
|
|
138
|
+
r: number;
|
|
139
|
+
/**
|
|
140
|
+
* Green component
|
|
141
|
+
* @default 0
|
|
142
|
+
* @minimum 0
|
|
143
|
+
* @maximum 1
|
|
144
|
+
*/
|
|
145
|
+
g: number;
|
|
146
|
+
/**
|
|
147
|
+
* Blue component
|
|
148
|
+
* @default 1
|
|
149
|
+
* @minimum 0
|
|
150
|
+
* @maximum 1
|
|
151
|
+
*/
|
|
152
|
+
b: number;
|
|
153
|
+
/**
|
|
154
|
+
* Alpha component
|
|
155
|
+
* @default 1
|
|
156
|
+
* @minimum 0
|
|
157
|
+
* @maximum 1
|
|
158
|
+
*/
|
|
159
|
+
a: number;
|
|
160
|
+
}
|
|
11
161
|
class InvertHexDto {
|
|
12
162
|
constructor(color?: Base.Color);
|
|
13
163
|
/**
|
|
@@ -14,6 +14,226 @@ export var Color;
|
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
Color.HexDto = HexDto;
|
|
17
|
+
class Rgb255Dto {
|
|
18
|
+
constructor(colorRgb) {
|
|
19
|
+
/**
|
|
20
|
+
* Color rgb
|
|
21
|
+
* @default { "r": 0, "g": 0, "b": 255 }
|
|
22
|
+
* @min 0
|
|
23
|
+
* @max 255
|
|
24
|
+
*/
|
|
25
|
+
this.colorRgb = { r: 0, g: 0, b: 255 };
|
|
26
|
+
if (colorRgb !== undefined) {
|
|
27
|
+
this.colorRgb = colorRgb;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
Color.Rgb255Dto = Rgb255Dto;
|
|
32
|
+
class Rgb1Dto {
|
|
33
|
+
constructor(colorRgb) {
|
|
34
|
+
/**
|
|
35
|
+
* Color rgb
|
|
36
|
+
* @default { "r": 0, "g": 0, "b": 1 }
|
|
37
|
+
* @min 0
|
|
38
|
+
* @max 1
|
|
39
|
+
*/
|
|
40
|
+
this.colorRgb = { r: 0, g: 0, b: 1 };
|
|
41
|
+
if (colorRgb !== undefined) {
|
|
42
|
+
this.colorRgb = colorRgb;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
Color.Rgb1Dto = Rgb1Dto;
|
|
47
|
+
class Rgba255Dto {
|
|
48
|
+
constructor(colorRgba) {
|
|
49
|
+
/**
|
|
50
|
+
* Color rgba
|
|
51
|
+
* @default { "r": 0, "g": 0, "b": 255, "a": 1 }
|
|
52
|
+
* @min 0
|
|
53
|
+
* @max 255
|
|
54
|
+
*/
|
|
55
|
+
this.colorRgba = { r: 0, g: 0, b: 255, a: 1 };
|
|
56
|
+
if (colorRgba !== undefined) {
|
|
57
|
+
this.colorRgba = colorRgba;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
Color.Rgba255Dto = Rgba255Dto;
|
|
62
|
+
class Rgba1Dto {
|
|
63
|
+
constructor(colorRgba) {
|
|
64
|
+
/**
|
|
65
|
+
* Color rgba
|
|
66
|
+
* @default { "r": 0, "g": 0, "b": 1, "a": 1 }
|
|
67
|
+
* @min 0
|
|
68
|
+
* @max 1
|
|
69
|
+
*/
|
|
70
|
+
this.colorRgba = { r: 0, g: 0, b: 1, a: 1 };
|
|
71
|
+
if (colorRgba !== undefined) {
|
|
72
|
+
this.colorRgba = colorRgba;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
Color.Rgba1Dto = Rgba1Dto;
|
|
77
|
+
class RgbAttomic255Dto {
|
|
78
|
+
constructor(r, g, b) {
|
|
79
|
+
/**
|
|
80
|
+
* Red component
|
|
81
|
+
* @default 0
|
|
82
|
+
* @minimum 0
|
|
83
|
+
* @maximum 255
|
|
84
|
+
*/
|
|
85
|
+
this.r = 0;
|
|
86
|
+
/**
|
|
87
|
+
* Green component
|
|
88
|
+
* @default 0
|
|
89
|
+
* @minimum 0
|
|
90
|
+
* @maximum 255
|
|
91
|
+
*/
|
|
92
|
+
this.g = 0;
|
|
93
|
+
/**
|
|
94
|
+
* Blue component
|
|
95
|
+
* @default 255
|
|
96
|
+
* @minimum 0
|
|
97
|
+
* @maximum 255
|
|
98
|
+
*/
|
|
99
|
+
this.b = 255;
|
|
100
|
+
if (r !== undefined) {
|
|
101
|
+
this.r = r;
|
|
102
|
+
}
|
|
103
|
+
if (g !== undefined) {
|
|
104
|
+
this.g = g;
|
|
105
|
+
}
|
|
106
|
+
if (b !== undefined) {
|
|
107
|
+
this.b = b;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
Color.RgbAttomic255Dto = RgbAttomic255Dto;
|
|
112
|
+
class RgbaAttomic255Dto {
|
|
113
|
+
constructor(r, g, b, a) {
|
|
114
|
+
/**
|
|
115
|
+
* Red component
|
|
116
|
+
* @default 0
|
|
117
|
+
* @minimum 0
|
|
118
|
+
* @maximum 255
|
|
119
|
+
*/
|
|
120
|
+
this.r = 0;
|
|
121
|
+
/**
|
|
122
|
+
* Green component
|
|
123
|
+
* @default 0
|
|
124
|
+
* @minimum 0
|
|
125
|
+
* @maximum 255
|
|
126
|
+
*/
|
|
127
|
+
this.g = 0;
|
|
128
|
+
/**
|
|
129
|
+
* Blue component
|
|
130
|
+
* @default 255
|
|
131
|
+
* @minimum 0
|
|
132
|
+
* @maximum 255
|
|
133
|
+
*/
|
|
134
|
+
this.b = 255;
|
|
135
|
+
/**
|
|
136
|
+
* Alpha component
|
|
137
|
+
* @default 1
|
|
138
|
+
* @minimum 0
|
|
139
|
+
* @maximum 1
|
|
140
|
+
*/
|
|
141
|
+
this.a = 1;
|
|
142
|
+
if (r !== undefined) {
|
|
143
|
+
this.r = r;
|
|
144
|
+
}
|
|
145
|
+
if (g !== undefined) {
|
|
146
|
+
this.g = g;
|
|
147
|
+
}
|
|
148
|
+
if (b !== undefined) {
|
|
149
|
+
this.b = b;
|
|
150
|
+
}
|
|
151
|
+
if (a !== undefined) {
|
|
152
|
+
this.a = a;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
Color.RgbaAttomic255Dto = RgbaAttomic255Dto;
|
|
157
|
+
class RgbAttomic1Dto {
|
|
158
|
+
constructor(r, g, b) {
|
|
159
|
+
/**
|
|
160
|
+
* Red component
|
|
161
|
+
* @default 0
|
|
162
|
+
* @minimum 0
|
|
163
|
+
* @maximum 1
|
|
164
|
+
*/
|
|
165
|
+
this.r = 0;
|
|
166
|
+
/**
|
|
167
|
+
* Green component
|
|
168
|
+
* @default 0
|
|
169
|
+
* @minimum 0
|
|
170
|
+
* @maximum 1
|
|
171
|
+
*/
|
|
172
|
+
this.g = 0;
|
|
173
|
+
/**
|
|
174
|
+
* Blue component
|
|
175
|
+
* @default 1
|
|
176
|
+
* @minimum 0
|
|
177
|
+
* @maximum 1
|
|
178
|
+
*/
|
|
179
|
+
this.b = 1;
|
|
180
|
+
if (r !== undefined) {
|
|
181
|
+
this.r = r;
|
|
182
|
+
}
|
|
183
|
+
if (g !== undefined) {
|
|
184
|
+
this.g = g;
|
|
185
|
+
}
|
|
186
|
+
if (b !== undefined) {
|
|
187
|
+
this.b = b;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
Color.RgbAttomic1Dto = RgbAttomic1Dto;
|
|
192
|
+
class RgbaAttomic1Dto {
|
|
193
|
+
constructor(r, g, b, a) {
|
|
194
|
+
/**
|
|
195
|
+
* Red component
|
|
196
|
+
* @default 0
|
|
197
|
+
* @minimum 0
|
|
198
|
+
* @maximum 1
|
|
199
|
+
*/
|
|
200
|
+
this.r = 0;
|
|
201
|
+
/**
|
|
202
|
+
* Green component
|
|
203
|
+
* @default 0
|
|
204
|
+
* @minimum 0
|
|
205
|
+
* @maximum 1
|
|
206
|
+
*/
|
|
207
|
+
this.g = 0;
|
|
208
|
+
/**
|
|
209
|
+
* Blue component
|
|
210
|
+
* @default 1
|
|
211
|
+
* @minimum 0
|
|
212
|
+
* @maximum 1
|
|
213
|
+
*/
|
|
214
|
+
this.b = 1;
|
|
215
|
+
/**
|
|
216
|
+
* Alpha component
|
|
217
|
+
* @default 1
|
|
218
|
+
* @minimum 0
|
|
219
|
+
* @maximum 1
|
|
220
|
+
*/
|
|
221
|
+
this.a = 1;
|
|
222
|
+
if (r !== undefined) {
|
|
223
|
+
this.r = r;
|
|
224
|
+
}
|
|
225
|
+
if (g !== undefined) {
|
|
226
|
+
this.g = g;
|
|
227
|
+
}
|
|
228
|
+
if (b !== undefined) {
|
|
229
|
+
this.b = b;
|
|
230
|
+
}
|
|
231
|
+
if (a !== undefined) {
|
|
232
|
+
this.a = a;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
Color.RgbaAttomic1Dto = RgbaAttomic1Dto;
|
|
17
237
|
class InvertHexDto {
|
|
18
238
|
constructor(color) {
|
|
19
239
|
/**
|
|
@@ -462,4 +462,12 @@ export declare namespace Math {
|
|
|
462
462
|
*/
|
|
463
463
|
maxDelta: number;
|
|
464
464
|
}
|
|
465
|
+
class EvalArithmeticDto {
|
|
466
|
+
constructor(expression?: string);
|
|
467
|
+
/**
|
|
468
|
+
* Arithmetic expression containing numbers, +, -, *, /, and parentheses
|
|
469
|
+
* @default "1+1"
|
|
470
|
+
*/
|
|
471
|
+
expression: string;
|
|
472
|
+
}
|
|
465
473
|
}
|
|
@@ -605,4 +605,17 @@ export var Math;
|
|
|
605
605
|
}
|
|
606
606
|
}
|
|
607
607
|
Math.MoveTowardsDto = MoveTowardsDto;
|
|
608
|
+
class EvalArithmeticDto {
|
|
609
|
+
constructor(expression) {
|
|
610
|
+
/**
|
|
611
|
+
* Arithmetic expression containing numbers, +, -, *, /, and parentheses
|
|
612
|
+
* @default "1+1"
|
|
613
|
+
*/
|
|
614
|
+
this.expression = "1+1";
|
|
615
|
+
if (expression !== undefined) {
|
|
616
|
+
this.expression = expression;
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
Math.EvalArithmeticDto = EvalArithmeticDto;
|
|
608
621
|
})(Math || (Math = {}));
|
|
@@ -163,8 +163,8 @@ export const defaultsVectorParams = {
|
|
|
163
163
|
input: "?",
|
|
164
164
|
align: "left",
|
|
165
165
|
font: simplex,
|
|
166
|
-
height: 21,
|
|
167
|
-
lineSpacing: 2.142857142857143,
|
|
166
|
+
height: 21, // == old vector_xxx simplex font height
|
|
167
|
+
lineSpacing: 2.142857142857143, // == 30/14 == old vector_xxx ratio
|
|
168
168
|
letterSpacing: 1,
|
|
169
169
|
extrudeOffset: 0
|
|
170
170
|
};
|
|
@@ -9,10 +9,64 @@ export declare class Color {
|
|
|
9
9
|
* @param inputs Color hex
|
|
10
10
|
* @returns color string
|
|
11
11
|
* @group create
|
|
12
|
-
* @shortname color
|
|
12
|
+
* @shortname color hex
|
|
13
13
|
* @drawable false
|
|
14
14
|
*/
|
|
15
15
|
hexColor(inputs: Inputs.Color.HexDto): Inputs.Base.Color;
|
|
16
|
+
/**
|
|
17
|
+
* Creates and returns rgb color object
|
|
18
|
+
* @param inputs Color rgb
|
|
19
|
+
* @returns color object
|
|
20
|
+
* @group create
|
|
21
|
+
* @shortname color rgb 0-255
|
|
22
|
+
* @drawable false
|
|
23
|
+
*/
|
|
24
|
+
rgb255Color(inputs: Inputs.Color.Rgb255Dto): Inputs.Base.ColorRGB;
|
|
25
|
+
/**
|
|
26
|
+
* Creates and returns rgb color object
|
|
27
|
+
* @param inputs Color rgb
|
|
28
|
+
* @returns color object
|
|
29
|
+
* @group create
|
|
30
|
+
* @shortname color rgb 0-1
|
|
31
|
+
* @drawable false
|
|
32
|
+
*/
|
|
33
|
+
rgb1Color(inputs: Inputs.Color.Rgb1Dto): Inputs.Base.ColorRGB;
|
|
34
|
+
/**
|
|
35
|
+
* Creates and returns rgba color object
|
|
36
|
+
* @param inputs Color rgba
|
|
37
|
+
* @returns color object
|
|
38
|
+
* @group create
|
|
39
|
+
* @shortname color rgba 0-255
|
|
40
|
+
* @drawable false
|
|
41
|
+
*/
|
|
42
|
+
rgba255Color(inputs: Inputs.Color.Rgba255Dto): Inputs.Base.ColorRGBA;
|
|
43
|
+
/**
|
|
44
|
+
* Creates and returns rgba color object
|
|
45
|
+
* @param inputs Color rgba
|
|
46
|
+
* @returns color object
|
|
47
|
+
* @group create
|
|
48
|
+
* @shortname color rgba 0-1
|
|
49
|
+
* @drawable false
|
|
50
|
+
*/
|
|
51
|
+
rgba1Color(inputs: Inputs.Color.Rgba1Dto): Inputs.Base.ColorRGBA;
|
|
52
|
+
/**
|
|
53
|
+
* Creates atomic rgb color object
|
|
54
|
+
* @param inputs Color rgb
|
|
55
|
+
* @returns color object
|
|
56
|
+
* @group create
|
|
57
|
+
* @shortname atomic color rgb 0-255
|
|
58
|
+
* @drawable false
|
|
59
|
+
*/
|
|
60
|
+
rgbAtomic255Color(inputs: Inputs.Color.RgbAttomic255Dto): Inputs.Base.ColorRGB;
|
|
61
|
+
/**
|
|
62
|
+
* Creates atomic rgb color object
|
|
63
|
+
* @param inputs Color rgb
|
|
64
|
+
* @returns color object
|
|
65
|
+
* @group create
|
|
66
|
+
* @shortname atomic color rgb 0-1
|
|
67
|
+
* @drawable false
|
|
68
|
+
*/
|
|
69
|
+
rgbAtomic1Color(inputs: Inputs.Color.RgbAttomic1Dto): Inputs.Base.ColorRGB;
|
|
16
70
|
/**
|
|
17
71
|
* Converts hex color to RGB object with r, g, b values (0-255 range).
|
|
18
72
|
* Example: '#FF5733' → {r: 255, g: 87, b: 51}
|
|
@@ -8,12 +8,78 @@ export class Color {
|
|
|
8
8
|
* @param inputs Color hex
|
|
9
9
|
* @returns color string
|
|
10
10
|
* @group create
|
|
11
|
-
* @shortname color
|
|
11
|
+
* @shortname color hex
|
|
12
12
|
* @drawable false
|
|
13
13
|
*/
|
|
14
14
|
hexColor(inputs) {
|
|
15
15
|
return inputs.color;
|
|
16
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* Creates and returns rgb color object
|
|
19
|
+
* @param inputs Color rgb
|
|
20
|
+
* @returns color object
|
|
21
|
+
* @group create
|
|
22
|
+
* @shortname color rgb 0-255
|
|
23
|
+
* @drawable false
|
|
24
|
+
*/
|
|
25
|
+
rgb255Color(inputs) {
|
|
26
|
+
return inputs.colorRgb;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Creates and returns rgb color object
|
|
30
|
+
* @param inputs Color rgb
|
|
31
|
+
* @returns color object
|
|
32
|
+
* @group create
|
|
33
|
+
* @shortname color rgb 0-1
|
|
34
|
+
* @drawable false
|
|
35
|
+
*/
|
|
36
|
+
rgb1Color(inputs) {
|
|
37
|
+
return inputs.colorRgb;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Creates and returns rgba color object
|
|
41
|
+
* @param inputs Color rgba
|
|
42
|
+
* @returns color object
|
|
43
|
+
* @group create
|
|
44
|
+
* @shortname color rgba 0-255
|
|
45
|
+
* @drawable false
|
|
46
|
+
*/
|
|
47
|
+
rgba255Color(inputs) {
|
|
48
|
+
return inputs.colorRgba;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Creates and returns rgba color object
|
|
52
|
+
* @param inputs Color rgba
|
|
53
|
+
* @returns color object
|
|
54
|
+
* @group create
|
|
55
|
+
* @shortname color rgba 0-1
|
|
56
|
+
* @drawable false
|
|
57
|
+
*/
|
|
58
|
+
rgba1Color(inputs) {
|
|
59
|
+
return inputs.colorRgba;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Creates atomic rgb color object
|
|
63
|
+
* @param inputs Color rgb
|
|
64
|
+
* @returns color object
|
|
65
|
+
* @group create
|
|
66
|
+
* @shortname atomic color rgb 0-255
|
|
67
|
+
* @drawable false
|
|
68
|
+
*/
|
|
69
|
+
rgbAtomic255Color(inputs) {
|
|
70
|
+
return Object.assign({}, inputs);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Creates atomic rgb color object
|
|
74
|
+
* @param inputs Color rgb
|
|
75
|
+
* @returns color object
|
|
76
|
+
* @group create
|
|
77
|
+
* @shortname atomic color rgb 0-1
|
|
78
|
+
* @drawable false
|
|
79
|
+
*/
|
|
80
|
+
rgbAtomic1Color(inputs) {
|
|
81
|
+
return Object.assign({}, inputs);
|
|
82
|
+
}
|
|
17
83
|
/**
|
|
18
84
|
* Converts hex color to RGB object with r, g, b values (0-255 range).
|
|
19
85
|
* Example: '#FF5733' → {r: 255, g: 87, b: 51}
|
|
@@ -133,7 +133,7 @@ export class DxfGenerator {
|
|
|
133
133
|
"2",
|
|
134
134
|
"VPORT",
|
|
135
135
|
"70",
|
|
136
|
-
"2",
|
|
136
|
+
"2", // Number of viewports
|
|
137
137
|
"0",
|
|
138
138
|
"VPORT",
|
|
139
139
|
"2",
|
|
@@ -606,7 +606,7 @@ export class DxfGenerator {
|
|
|
606
606
|
// Use 24-bit true color for full color spectrum (newer CAD software)
|
|
607
607
|
const trueColor = (r * 65536) + (g * 256) + b;
|
|
608
608
|
return [
|
|
609
|
-
{ code: "62", value: "256" },
|
|
609
|
+
{ code: "62", value: "256" }, // 256 = ByEntity
|
|
610
610
|
{ code: "420", value: trueColor.toString() }
|
|
611
611
|
];
|
|
612
612
|
}
|
|
@@ -627,14 +627,14 @@ export class DxfGenerator {
|
|
|
627
627
|
rgbToAciColorIndex(r, g, b) {
|
|
628
628
|
// ACI standard colors (simplified mapping)
|
|
629
629
|
const aciColors = {
|
|
630
|
-
1: [255, 0, 0],
|
|
631
|
-
2: [255, 255, 0],
|
|
632
|
-
3: [0, 255, 0],
|
|
633
|
-
4: [0, 255, 255],
|
|
634
|
-
5: [0, 0, 255],
|
|
635
|
-
6: [255, 0, 255],
|
|
636
|
-
7: [255, 255, 255],
|
|
637
|
-
8: [128, 128, 128],
|
|
630
|
+
1: [255, 0, 0], // Red
|
|
631
|
+
2: [255, 255, 0], // Yellow
|
|
632
|
+
3: [0, 255, 0], // Green
|
|
633
|
+
4: [0, 255, 255], // Cyan
|
|
634
|
+
5: [0, 0, 255], // Blue
|
|
635
|
+
6: [255, 0, 255], // Magenta
|
|
636
|
+
7: [255, 255, 255], // White
|
|
637
|
+
8: [128, 128, 128], // Gray
|
|
638
638
|
9: [192, 192, 192] // Light gray
|
|
639
639
|
};
|
|
640
640
|
// Special case for black or very dark colors
|
|
@@ -461,6 +461,18 @@ export declare class MathBitByBit {
|
|
|
461
461
|
* @drawable false
|
|
462
462
|
*/
|
|
463
463
|
moveTowards(inputs: Inputs.Math.MoveTowardsDto): number;
|
|
464
|
+
/**
|
|
465
|
+
* Safely evaluates a simple arithmetic expression containing only
|
|
466
|
+
* numbers, +, -, *, /, parentheses, and whitespace.
|
|
467
|
+
* Uses the shunting-yard algorithm — no eval/Function.
|
|
468
|
+
* Example: "(3+2)*4" → 20, "10/3" → 3.3333...
|
|
469
|
+
* @param inputs arithmetic expression string
|
|
470
|
+
* @returns evaluated result
|
|
471
|
+
* @group operations
|
|
472
|
+
* @shortname eval arithmetic
|
|
473
|
+
* @drawable false
|
|
474
|
+
*/
|
|
475
|
+
evalArithmetic(inputs: Inputs.Math.EvalArithmeticDto): number;
|
|
464
476
|
private easeInSine;
|
|
465
477
|
private easeOutSine;
|
|
466
478
|
private easeInOutSine;
|
package/lib/api/services/math.js
CHANGED
|
@@ -660,6 +660,128 @@ export class MathBitByBit {
|
|
|
660
660
|
}
|
|
661
661
|
return inputs.current + Math.sign(delta) * inputs.maxDelta;
|
|
662
662
|
}
|
|
663
|
+
/**
|
|
664
|
+
* Safely evaluates a simple arithmetic expression containing only
|
|
665
|
+
* numbers, +, -, *, /, parentheses, and whitespace.
|
|
666
|
+
* Uses the shunting-yard algorithm — no eval/Function.
|
|
667
|
+
* Example: "(3+2)*4" → 20, "10/3" → 3.3333...
|
|
668
|
+
* @param inputs arithmetic expression string
|
|
669
|
+
* @returns evaluated result
|
|
670
|
+
* @group operations
|
|
671
|
+
* @shortname eval arithmetic
|
|
672
|
+
* @drawable false
|
|
673
|
+
*/
|
|
674
|
+
evalArithmetic(inputs) {
|
|
675
|
+
var _a;
|
|
676
|
+
const expr = inputs.expression;
|
|
677
|
+
const tokens = [];
|
|
678
|
+
let i = 0;
|
|
679
|
+
while (i < expr.length) {
|
|
680
|
+
const ch = expr[i];
|
|
681
|
+
if (ch === " ") {
|
|
682
|
+
i++;
|
|
683
|
+
continue;
|
|
684
|
+
}
|
|
685
|
+
if (ch === "(" || ch === ")") {
|
|
686
|
+
tokens.push(ch);
|
|
687
|
+
i++;
|
|
688
|
+
continue;
|
|
689
|
+
}
|
|
690
|
+
if (ch === "+" || ch === "*" || ch === "/") {
|
|
691
|
+
tokens.push(ch);
|
|
692
|
+
i++;
|
|
693
|
+
continue;
|
|
694
|
+
}
|
|
695
|
+
if (ch === "-") {
|
|
696
|
+
const prev = tokens.length > 0 ? tokens[tokens.length - 1] : undefined;
|
|
697
|
+
if (prev === undefined || prev === "(" || prev === "+" || prev === "-" || prev === "*" || prev === "/") {
|
|
698
|
+
let num = "-";
|
|
699
|
+
i++;
|
|
700
|
+
while (i < expr.length && (expr[i] >= "0" && expr[i] <= "9" || expr[i] === ".")) {
|
|
701
|
+
num += expr[i];
|
|
702
|
+
i++;
|
|
703
|
+
}
|
|
704
|
+
if (num === "-") {
|
|
705
|
+
throw new Error("Invalid expression");
|
|
706
|
+
}
|
|
707
|
+
tokens.push(num);
|
|
708
|
+
continue;
|
|
709
|
+
}
|
|
710
|
+
tokens.push(ch);
|
|
711
|
+
i++;
|
|
712
|
+
continue;
|
|
713
|
+
}
|
|
714
|
+
if ((ch >= "0" && ch <= "9") || ch === ".") {
|
|
715
|
+
let num = "";
|
|
716
|
+
while (i < expr.length && (expr[i] >= "0" && expr[i] <= "9" || expr[i] === ".")) {
|
|
717
|
+
num += expr[i];
|
|
718
|
+
i++;
|
|
719
|
+
}
|
|
720
|
+
tokens.push(num);
|
|
721
|
+
continue;
|
|
722
|
+
}
|
|
723
|
+
throw new Error("Invalid character in expression");
|
|
724
|
+
}
|
|
725
|
+
const output = [];
|
|
726
|
+
const ops = [];
|
|
727
|
+
const prec = { "+": 1, "-": 1, "*": 2, "/": 2 };
|
|
728
|
+
const applyOp = () => {
|
|
729
|
+
const op = ops.pop();
|
|
730
|
+
const b = output.pop();
|
|
731
|
+
const a = output.pop();
|
|
732
|
+
switch (op) {
|
|
733
|
+
case "+":
|
|
734
|
+
output.push(a + b);
|
|
735
|
+
break;
|
|
736
|
+
case "-":
|
|
737
|
+
output.push(a - b);
|
|
738
|
+
break;
|
|
739
|
+
case "*":
|
|
740
|
+
output.push(a * b);
|
|
741
|
+
break;
|
|
742
|
+
case "/":
|
|
743
|
+
output.push(a / b);
|
|
744
|
+
break;
|
|
745
|
+
}
|
|
746
|
+
};
|
|
747
|
+
for (const tok of tokens) {
|
|
748
|
+
if (tok === "(") {
|
|
749
|
+
ops.push(tok);
|
|
750
|
+
}
|
|
751
|
+
else if (tok === ")") {
|
|
752
|
+
while (ops.length > 0 && ops[ops.length - 1] !== "(") {
|
|
753
|
+
applyOp();
|
|
754
|
+
}
|
|
755
|
+
if (ops.length === 0) {
|
|
756
|
+
throw new Error("Mismatched parentheses");
|
|
757
|
+
}
|
|
758
|
+
ops.pop();
|
|
759
|
+
}
|
|
760
|
+
else if (tok in prec) {
|
|
761
|
+
while (ops.length > 0 && ops[ops.length - 1] !== "(" && ((_a = prec[ops[ops.length - 1]]) !== null && _a !== void 0 ? _a : 0) >= prec[tok]) {
|
|
762
|
+
applyOp();
|
|
763
|
+
}
|
|
764
|
+
ops.push(tok);
|
|
765
|
+
}
|
|
766
|
+
else {
|
|
767
|
+
const n = parseFloat(tok);
|
|
768
|
+
if (isNaN(n)) {
|
|
769
|
+
throw new Error("Invalid number");
|
|
770
|
+
}
|
|
771
|
+
output.push(n);
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
while (ops.length > 0) {
|
|
775
|
+
if (ops[ops.length - 1] === "(") {
|
|
776
|
+
throw new Error("Mismatched parentheses");
|
|
777
|
+
}
|
|
778
|
+
applyOp();
|
|
779
|
+
}
|
|
780
|
+
if (output.length !== 1) {
|
|
781
|
+
throw new Error("Invalid expression");
|
|
782
|
+
}
|
|
783
|
+
return output[0];
|
|
784
|
+
}
|
|
663
785
|
easeInSine(x) {
|
|
664
786
|
return 1 - Math.cos((x * Math.PI) / 2);
|
|
665
787
|
}
|
|
@@ -450,7 +450,7 @@ export class Point {
|
|
|
450
450
|
radiusHexagon: BASE_RADIUS,
|
|
451
451
|
nrHexagonsX: nrHexagonsInWidth,
|
|
452
452
|
nrHexagonsY: nrHexagonsInHeight,
|
|
453
|
-
orientOnCenter: false,
|
|
453
|
+
orientOnCenter: false, // Important: Do not center here
|
|
454
454
|
pointsOnGround: false // Keep on XY plane for now
|
|
455
455
|
});
|
|
456
456
|
if (unscaledCenters.length === 0) {
|
|
@@ -323,9 +323,9 @@ export class Transforms {
|
|
|
323
323
|
// m41, m42, m43 = 0, m44 = 1
|
|
324
324
|
// Assemble the 4x4 matrix in COLUMN-MAJOR order
|
|
325
325
|
const m = [
|
|
326
|
-
m11, m21, m31, 0.0,
|
|
327
|
-
m12, m22, m32, 0.0,
|
|
328
|
-
m13, m23, m33, 0.0,
|
|
326
|
+
m11, m21, m31, 0.0, // Column 1
|
|
327
|
+
m12, m22, m32, 0.0, // Column 2
|
|
328
|
+
m13, m23, m33, 0.0, // Column 3
|
|
329
329
|
0.0, 0.0, 0.0, 1.0 // Column 4
|
|
330
330
|
];
|
|
331
331
|
return m;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bitbybit-dev/base",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.2",
|
|
4
4
|
"description": "Bit By Bit Developers Base CAD Library to Program Geometry",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"repository": {
|
|
@@ -60,19 +60,18 @@
|
|
|
60
60
|
"dependencies": {},
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"shx":"0.4.0",
|
|
63
|
-
"
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
"
|
|
67
|
-
"ts-
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
"
|
|
71
|
-
"babel
|
|
72
|
-
"@babel/
|
|
73
|
-
"@babel/preset-
|
|
74
|
-
"
|
|
75
|
-
"jest-html-reporters": "3.0.11"
|
|
63
|
+
"@testing-library/jest-dom": "6.9.1",
|
|
64
|
+
"mvdir": "1.0.22",
|
|
65
|
+
"jest": "30.2.0",
|
|
66
|
+
"ts-node": "10.9.2",
|
|
67
|
+
"ts-jest": "29.4.6",
|
|
68
|
+
"typescript": "5.9.3",
|
|
69
|
+
"@types/jest": "30.0.0",
|
|
70
|
+
"babel-jest": "30.2.0",
|
|
71
|
+
"@babel/core": "7.28.6",
|
|
72
|
+
"@babel/preset-env": "7.28.6",
|
|
73
|
+
"@babel/preset-typescript": "7.28.5",
|
|
74
|
+
"jest-html-reporters": "3.1.7"
|
|
76
75
|
},
|
|
77
76
|
"jest": {
|
|
78
77
|
"preset": "ts-jest",
|