@bitbybit-dev/base 1.2.0 → 1.3.0-rc.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.
Files changed (55) hide show
  1. package/lib/api/GlobalCDNProvider.js +1 -1
  2. package/lib/api/inputs/base-inputs.d.ts +13 -12
  3. package/lib/api/inputs/color-inputs.d.ts +97 -48
  4. package/lib/api/inputs/color-inputs.js +95 -46
  5. package/lib/api/inputs/dates-inputs.d.ts +67 -26
  6. package/lib/api/inputs/dates-inputs.js +57 -16
  7. package/lib/api/inputs/io-inputs.d.ts +13 -15
  8. package/lib/api/inputs/io-inputs.js +7 -8
  9. package/lib/api/inputs/line-inputs.d.ts +88 -33
  10. package/lib/api/inputs/line-inputs.js +61 -11
  11. package/lib/api/inputs/lists-inputs.d.ts +207 -96
  12. package/lib/api/inputs/lists-inputs.js +153 -45
  13. package/lib/api/inputs/logic-inputs.d.ts +52 -22
  14. package/lib/api/inputs/logic-inputs.js +41 -12
  15. package/lib/api/inputs/math-inputs.d.ts +113 -52
  16. package/lib/api/inputs/math-inputs.js +112 -51
  17. package/lib/api/inputs/mesh-inputs.d.ts +30 -11
  18. package/lib/api/inputs/mesh-inputs.js +21 -3
  19. package/lib/api/inputs/point-inputs.d.ts +240 -107
  20. package/lib/api/inputs/point-inputs.js +199 -73
  21. package/lib/api/inputs/polyline-inputs.d.ts +68 -28
  22. package/lib/api/inputs/polyline-inputs.js +48 -13
  23. package/lib/api/inputs/text-inputs.d.ts +117 -46
  24. package/lib/api/inputs/text-inputs.js +111 -41
  25. package/lib/api/inputs/transforms-inputs.d.ts +65 -23
  26. package/lib/api/inputs/transforms-inputs.js +64 -22
  27. package/lib/api/inputs/vector-inputs.d.ts +154 -76
  28. package/lib/api/inputs/vector-inputs.js +132 -57
  29. package/lib/api/models/point/hex-grid-data.d.ts +1 -1
  30. package/lib/api/models/point/hex-grid-data.js +1 -1
  31. package/lib/api/services/color.d.ts +149 -70
  32. package/lib/api/services/color.js +149 -70
  33. package/lib/api/services/dates.d.ts +313 -150
  34. package/lib/api/services/dates.js +313 -150
  35. package/lib/api/services/line.d.ts +138 -68
  36. package/lib/api/services/line.js +138 -68
  37. package/lib/api/services/lists.d.ts +357 -177
  38. package/lib/api/services/lists.js +357 -177
  39. package/lib/api/services/logic.d.ts +98 -45
  40. package/lib/api/services/logic.js +98 -45
  41. package/lib/api/services/math.d.ts +363 -211
  42. package/lib/api/services/math.js +363 -211
  43. package/lib/api/services/mesh.d.ts +73 -31
  44. package/lib/api/services/mesh.js +73 -31
  45. package/lib/api/services/point.d.ts +367 -147
  46. package/lib/api/services/point.js +367 -147
  47. package/lib/api/services/polyline.d.ts +146 -71
  48. package/lib/api/services/polyline.js +146 -71
  49. package/lib/api/services/text.d.ts +320 -165
  50. package/lib/api/services/text.js +320 -165
  51. package/lib/api/services/transforms.d.ts +145 -58
  52. package/lib/api/services/transforms.js +145 -58
  53. package/lib/api/services/vector.d.ts +381 -156
  54. package/lib/api/services/vector.js +381 -156
  55. package/package.json +1 -1
@@ -1,183 +1,262 @@
1
1
  import * as Inputs from "../inputs";
2
2
  import { MathBitByBit } from "./math";
3
+ /**
4
+ * Colors in the two forms the library uses: a hex text such as `#ff5733`, and an object `{ r, g, b
5
+ * }` or `{ r, g, b, a }` whose channels run either from 0 to 255 or from 0 to 1. The methods here
6
+ * build colors in each form, convert between them with an explicit channel range, read single
7
+ * channels and invert a color.
8
+ */
3
9
  export declare class Color {
4
10
  private readonly math;
5
11
  constructor(math: MathBitByBit);
6
12
  /**
7
- * Creates and returns a hex color string (pass-through for color input).
8
- * Example: '#FF5733' → '#FF5733'
9
- * @param inputs Color hex
10
- * @returns color string
13
+ * Passes a hex color through unchanged, so a color can be given a name and reused.
14
+ *
15
+ * Example: '#FF5733' -> '#FF5733'
16
+ * @param inputs - The hex color
17
+ * @returns The same hex color
11
18
  * @group create
12
19
  * @shortname color hex
13
20
  * @drawable false
14
21
  */
15
22
  hexColor(inputs: Inputs.Color.HexDto): Inputs.Base.Color;
16
23
  /**
17
- * Creates and returns rgb color object
18
- * @param inputs Color rgb
19
- * @returns color object
24
+ * Passes an `{ r, g, b }` color with channels from 0 to 255 through unchanged, so it can be
25
+ * given a name and reused.
26
+ *
27
+ * Example: { r: 255, g: 87, b: 51 } -> the same object
28
+ * @param inputs - The color object
29
+ * @returns The same color object
20
30
  * @group create
21
31
  * @shortname color rgb 0-255
22
32
  * @drawable false
23
33
  */
24
34
  rgb255Color(inputs: Inputs.Color.Rgb255Dto): Inputs.Base.ColorRGB;
25
35
  /**
26
- * Creates and returns rgb color object
27
- * @param inputs Color rgb
28
- * @returns color object
36
+ * Passes an `{ r, g, b }` color with channels from 0 to 1 through unchanged, so it can be
37
+ * given a name and reused.
38
+ *
39
+ * Example: { r: 1, g: 0.34, b: 0.2 } -> the same object
40
+ * @param inputs - The color object
41
+ * @returns The same color object
29
42
  * @group create
30
43
  * @shortname color rgb 0-1
31
44
  * @drawable false
32
45
  */
33
46
  rgb1Color(inputs: Inputs.Color.Rgb1Dto): Inputs.Base.ColorRGB;
34
47
  /**
35
- * Creates and returns rgba color object
36
- * @param inputs Color rgba
37
- * @returns color object
48
+ * Passes an `{ r, g, b, a }` color with color channels from 0 to 255 and opacity from 0 to 1
49
+ * through unchanged, so it can be given a name and reused.
50
+ *
51
+ * Example: { r: 255, g: 87, b: 51, a: 1 } -> the same object
52
+ * @param inputs - The color object
53
+ * @returns The same color object
38
54
  * @group create
39
55
  * @shortname color rgba 0-255
40
56
  * @drawable false
41
57
  */
42
58
  rgba255Color(inputs: Inputs.Color.Rgba255Dto): Inputs.Base.ColorRGBA;
43
59
  /**
44
- * Creates and returns rgba color object
45
- * @param inputs Color rgba
46
- * @returns color object
60
+ * Passes an `{ r, g, b, a }` color with every channel from 0 to 1 through unchanged, so it can
61
+ * be given a name and reused.
62
+ *
63
+ * Example: { r: 1, g: 0.34, b: 0.2, a: 1 } -> the same object
64
+ * @param inputs - The color object
65
+ * @returns The same color object
47
66
  * @group create
48
67
  * @shortname color rgba 0-1
49
68
  * @drawable false
50
69
  */
51
70
  rgba1Color(inputs: Inputs.Color.Rgba1Dto): Inputs.Base.ColorRGBA;
52
71
  /**
53
- * Creates atomic rgb color object
54
- * @param inputs Color rgb
55
- * @returns color object
72
+ * Builds an `{ r, g, b }` color from three separate channel values from 0 to 255.
73
+ *
74
+ * Example: r 255, g 87, b 51 -> { r: 255, g: 87, b: 51 }
75
+ * @param inputs - The red, green and blue values
76
+ * @returns The color object
56
77
  * @group create
57
78
  * @shortname atomic color rgb 0-255
58
79
  * @drawable false
80
+ * @example
81
+ * ```typescript
82
+ * const orange = bitbybit.color.rgbAtomic255Color({ r: 255, g: 87, b: 51 });
83
+ * ```
59
84
  */
60
85
  rgbAtomic255Color(inputs: Inputs.Color.RgbAttomic255Dto): Inputs.Base.ColorRGB;
61
86
  /**
62
- * Creates atomic rgb color object
63
- * @param inputs Color rgb
64
- * @returns color object
87
+ * Builds an `{ r, g, b }` color from three separate channel values from 0 to 1.
88
+ *
89
+ * Example: r 1, g 0.34, b 0.2 -> { r: 1, g: 0.34, b: 0.2 }
90
+ * @param inputs - The red, green and blue values
91
+ * @returns The color object
65
92
  * @group create
66
93
  * @shortname atomic color rgb 0-1
67
94
  * @drawable false
95
+ * @example
96
+ * ```typescript
97
+ * const orange = bitbybit.color.rgbAtomic1Color({ r: 1, g: 0.34, b: 0.2 });
98
+ * ```
68
99
  */
69
100
  rgbAtomic1Color(inputs: Inputs.Color.RgbAttomic1Dto): Inputs.Base.ColorRGB;
70
101
  /**
71
- * Converts hex color to RGB object with r, g, b values (0-255 range).
72
- * Example: '#FF5733' → {r: 255, g: 87, b: 51}
73
- * @param inputs Color hex
74
- * @returns rgb color
102
+ * Reads a hex color into an `{ r, g, b }` object with channels from 0 to 255.
103
+ *
104
+ * The text may start with or without `#`; anything else than six hex digits throws an error.
105
+ * Example: '#FF5733' -> { r: 255, g: 87, b: 51 }
106
+ * @param inputs - The hex color
107
+ * @returns The color object with channels from 0 to 255
75
108
  * @group convert
76
109
  * @shortname hex to rgb
77
110
  * @drawable false
111
+ * @example
112
+ * ```typescript
113
+ * const rgb = bitbybit.color.hexToRgb({ color: "#ff5733" });
114
+ * ```
78
115
  */
79
116
  hexToRgb(inputs: Inputs.Color.HexDto): Inputs.Base.ColorRGB;
80
117
  /**
81
- * Converts RGB values to hex color string (supports custom min/max ranges, auto-remaps to 0-255).
82
- * Example: r=255, g=87, b=51 with range [0,255] → '#ff5733'
83
- * Example: r=1, g=0.5, b=0.2 with range [0,1] → '#ff7f33'
84
- * @param inputs Color hext
85
- * @returns hex color
118
+ * Writes three channel values as a hex color.
119
+ *
120
+ * `min` and `max` say which range the values use; a range other than 0 to 255 is remapped
121
+ * first, so channels from 0 to 1 work as well.
122
+ * Example: r 255, g 87, b 51 in [0,255] -> '#ff5733'; r 1, g 0.5, b 0.2 in [0,1] -> '#ff8033'
123
+ * @param inputs - The red, green and blue values and their range
124
+ * @returns The hex color
86
125
  * @group convert
87
126
  * @shortname rgb to hex
88
127
  * @drawable false
128
+ * @example
129
+ * ```typescript
130
+ * const hex = bitbybit.color.rgbToHex({ r: 1, g: 0.5, b: 0.2, min: 0, max: 1 });
131
+ * ```
89
132
  */
90
133
  rgbToHex(inputs: Inputs.Color.RGBMinMaxDto): Inputs.Base.Color;
91
134
  /**
92
- * Converts RGB object to hex color string (supports custom min/max ranges).
93
- * Example: {r: 1, g: 0.5, b: 0.2} with range [0,1] → '#ff7f33'
94
- * @param inputs Color hext
95
- * @returns hex color string
135
+ * Writes an `{ r, g, b }` color as a hex color.
136
+ *
137
+ * `min` and `max` say which range the channels use; a range other than 0 to 255 is remapped
138
+ * first.
139
+ * Example: { r: 1, g: 0.5, b: 0.2 } in [0,1] -> '#ff8033'
140
+ * @param inputs - The color object and the range its channels use
141
+ * @returns The hex color
96
142
  * @group convert
97
143
  * @shortname rgb obj to hex
98
144
  * @drawable false
145
+ * @example
146
+ * ```typescript
147
+ * const hex = bitbybit.color.rgbObjToHex({ rgb: { r: 1, g: 0.5, b: 0.2 }, min: 0, max: 1 });
148
+ * ```
99
149
  */
100
150
  rgbObjToHex(inputs: Inputs.Color.RGBObjectMaxDto): Inputs.Base.Color;
101
151
  /**
102
- * Converts hex color to RGB and remaps values to a custom range.
103
- * Example: '#FF5733' mapped to [0,1] → {r: 1, g: 0.341, b: 0.2}
104
- * Example: '#FF5733' mapped to [0,100] → {r: 100, g: 34.1, b: 20}
105
- * @param inputs Color hext
106
- * @returns rgb color
152
+ * Reads a hex color into an `{ r, g, b }` object with the channels remapped to a range of your
153
+ * choice.
154
+ *
155
+ * Example: '#FF5733' mapped to [0,1] -> { r: 1, g: 0.341, b: 0.2 }
156
+ * @param inputs - The hex color and the range to map the channels to
157
+ * @returns The color object with channels in that range
107
158
  * @group convert
108
159
  * @shortname hex to rgb mapped
109
160
  * @drawable false
161
+ * @example
162
+ * ```typescript
163
+ * const rgb = bitbybit.color.hexToRgbMapped({ color: "#ff5733", from: 0, to: 1 });
164
+ * ```
110
165
  */
111
166
  hexToRgbMapped(inputs: Inputs.Color.HexDtoMapped): Inputs.Base.ColorRGB;
112
167
  /**
113
- * Extracts the red channel value from hex color (can be mapped to custom range).
114
- * Example: '#FF5733' with range [0,1] → 1
115
- * @param inputs Color hext
116
- * @returns rgb color
168
+ * Reads the red channel of a hex color, remapped to a range of your choice.
169
+ *
170
+ * Example: '#FF5733' in [0,1] -> 1
171
+ * @param inputs - The hex color and the range to map the channel to
172
+ * @returns The red channel in that range
117
173
  * @group hex to
118
174
  * @shortname red
119
175
  * @drawable false
176
+ * @example
177
+ * ```typescript
178
+ * const red = bitbybit.color.getRedParam({ color: "#ff5733", from: 0, to: 1 });
179
+ * ```
120
180
  */
121
181
  getRedParam(inputs: Inputs.Color.HexDtoMapped): number;
122
182
  /**
123
- * Extracts the green channel value from hex color (can be mapped to custom range).
124
- * Example: '#FF5733' with range [0,1] → 0.341
125
- * @param inputs Color hext
126
- * @returns rgb color
183
+ * Reads the green channel of a hex color, remapped to a range of your choice.
184
+ *
185
+ * Example: '#FF5733' in [0,1] -> 0.341
186
+ * @param inputs - The hex color and the range to map the channel to
187
+ * @returns The green channel in that range
127
188
  * @group hex to
128
189
  * @shortname green
129
190
  * @drawable false
191
+ * @example
192
+ * ```typescript
193
+ * const green = bitbybit.color.getGreenParam({ color: "#ff5733", from: 0, to: 1 });
194
+ * ```
130
195
  */
131
196
  getGreenParam(inputs: Inputs.Color.HexDtoMapped): number;
132
197
  /**
133
- * Extracts the blue channel value from hex color (can be mapped to custom range).
134
- * Example: '#FF5733' with range [0,1] → 0.2
135
- * @param inputs Color hext
136
- * @returns blue param
198
+ * Reads the blue channel of a hex color, remapped to a range of your choice.
199
+ *
200
+ * Example: '#FF5733' in [0,1] -> 0.2
201
+ * @param inputs - The hex color and the range to map the channel to
202
+ * @returns The blue channel in that range
137
203
  * @group hex to
138
204
  * @shortname blue
139
205
  * @drawable false
206
+ * @example
207
+ * ```typescript
208
+ * const blue = bitbybit.color.getBlueParam({ color: "#ff5733", from: 0, to: 1 });
209
+ * ```
140
210
  */
141
211
  getBlueParam(inputs: Inputs.Color.HexDtoMapped): number;
142
212
  /**
143
- * Extracts the red channel value from RGB object.
144
- * Example: {r: 255, g: 87, b: 51} → 255
145
- * @param inputs Color rgb
146
- * @returns red param
147
- * @group rgb to
213
+ * Reads the red channel of an `{ r, g, b }` color.
214
+ *
215
+ * Example: { r: 255, g: 87, b: 51 } -> 255
216
+ * @param inputs - The color object
217
+ * @returns The red channel, in whatever range the object uses
218
+ * @group rgb to
148
219
  * @shortname red
149
220
  * @drawable false
150
221
  */
151
222
  rgbToRed(inputs: Inputs.Color.RGBObjectDto): number;
152
223
  /**
153
- * Extracts the green channel value from RGB object.
154
- * Example: {r: 255, g: 87, b: 51} → 87
155
- * @param inputs Color rgb
156
- * @returns green param
224
+ * Reads the green channel of an `{ r, g, b }` color.
225
+ *
226
+ * Example: { r: 255, g: 87, b: 51 } -> 87
227
+ * @param inputs - The color object
228
+ * @returns The green channel, in whatever range the object uses
157
229
  * @group rgb to
158
230
  * @shortname green
159
231
  * @drawable false
160
232
  */
161
233
  rgbToGreen(inputs: Inputs.Color.RGBObjectDto): number;
162
234
  /**
163
- * Extracts the blue channel value from RGB object.
164
- * Example: {r: 255, g: 87, b: 51} → 51
165
- * @param inputs Color rgb
166
- * @returns blue param
235
+ * Reads the blue channel of an `{ r, g, b }` color.
236
+ *
237
+ * Example: { r: 255, g: 87, b: 51 } -> 51
238
+ * @param inputs - The color object
239
+ * @returns The blue channel, in whatever range the object uses
167
240
  * @group rgb to
168
241
  * @shortname blue
169
242
  * @drawable false
170
243
  */
171
244
  rgbToBlue(inputs: Inputs.Color.RGBObjectDto): number;
172
245
  /**
173
- * Inverts a hex color (flips RGB channels: 255-r, 255-g, 255-b).
174
- * With blackAndWhite=true → returns '#000000' or '#ffffff' based on brightness.
175
- * Example: '#FF5733' → '#00a8cc', '#FF5733' with blackAndWhite=true → '#ffffff'
176
- * @param inputs hex color and black and white option
177
- * @returns inverted color
246
+ * Inverts a hex color, turning each channel into its opposite: 255 minus the value.
247
+ *
248
+ * With `blackAndWhite` on, the result is plain black for a light color or white for a dark
249
+ * one, which suits text on a colored background.
250
+ * Example: '#FF5733' -> '#00a8cc'; with blackAndWhite -> '#ffffff'
251
+ * @param inputs - The hex color and whether to reduce the result to black or white
252
+ * @returns The inverted hex color
178
253
  * @group hex to
179
254
  * @shortname invert color
180
255
  * @drawable false
256
+ * @example
257
+ * ```typescript
258
+ * const textColor = bitbybit.color.invert({ color: "#ff5733", blackAndWhite: true });
259
+ * ```
181
260
  */
182
261
  invert(inputs: Inputs.Color.InvertHexDto): Inputs.Base.Color;
183
262
  }