plotboilerplate 1.25.0 → 1.26.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 (105) hide show
  1. package/README.md +1 -0
  2. package/dist/index.esm.js +139 -33
  3. package/dist/index.esm.js.map +1 -1
  4. package/dist/index.esm.min.js +1 -1
  5. package/dist/index.esm.min.js.map +1 -1
  6. package/dist/plotboilerplate.browser.min.js +1 -1
  7. package/dist/plotboilerplate.browser.min.js.map +1 -1
  8. package/dist/plotboilerplate.js +139 -33
  9. package/dist/plotboilerplate.min.js +1 -1
  10. package/package.json +1 -1
  11. package/src/cjs/Bounds.d.ts +79 -25
  12. package/src/cjs/Bounds.js +102 -29
  13. package/src/cjs/Bounds.js.map +1 -1
  14. package/src/cjs/CircleSector.d.ts +3 -0
  15. package/src/cjs/CircleSector.js +28 -1
  16. package/src/cjs/CircleSector.js.map +1 -1
  17. package/src/cjs/drawutilssvg.d.ts +2 -1
  18. package/src/cjs/drawutilssvg.js +9 -3
  19. package/src/cjs/drawutilssvg.js.map +1 -1
  20. package/src/cjs/utils/LissajousFigure.d.ts +34 -0
  21. package/src/cjs/utils/LissajousFigure.js +100 -0
  22. package/src/cjs/utils/LissajousFigure.js.map +1 -0
  23. package/src/cjs/utils/PerlinNoise.d.ts +19 -0
  24. package/src/cjs/utils/PerlinNoise.js +352 -0
  25. package/src/cjs/utils/PerlinNoise.js.map +1 -0
  26. package/src/cjs/utils/SVGPathUtils.d.ts +22 -0
  27. package/src/cjs/utils/SVGPathUtils.js +45 -0
  28. package/src/cjs/utils/SVGPathUtils.js.map +1 -0
  29. package/src/cjs/utils/algorithms/pixelCornersToRoundPaths.d.ts +23 -0
  30. package/src/cjs/utils/algorithms/pixelCornersToRoundPaths.js +270 -0
  31. package/src/cjs/utils/algorithms/pixelCornersToRoundPaths.js.map +1 -0
  32. package/src/cjs/utils/datastructures/DataGrid2d.d.ts +6 -0
  33. package/src/cjs/utils/datastructures/DataGrid2dArrayMatrix.d.ts +88 -0
  34. package/src/cjs/utils/datastructures/DataGrid2dArrayMatrix.js +155 -0
  35. package/src/cjs/utils/datastructures/DataGrid2dArrayMatrix.js.map +1 -0
  36. package/src/cjs/utils/datastructures/DataGrid2dListAdapter.d.ts +1 -7
  37. package/src/cjs/utils/datastructures/DataGrid2dListAdapter.js +3 -3
  38. package/src/cjs/utils/datastructures/DataGrid2dListAdapter.js.map +1 -1
  39. package/src/cjs/utils/datastructures/GeometryMesh.d.ts +49 -0
  40. package/src/cjs/utils/datastructures/GeometryMesh.js +58 -0
  41. package/src/cjs/utils/datastructures/GeometryMesh.js.map +1 -0
  42. package/src/cjs/utils/detectDarkMode.js +16 -7
  43. package/src/cjs/utils/detectDarkMode.js.map +1 -1
  44. package/src/cjs/utils/dom/components/ColorGradientPicker.d.ts +4 -3
  45. package/src/cjs/utils/dom/components/ColorGradientPicker.js +8 -8
  46. package/src/cjs/utils/dom/components/ColorGradientPicker.js.map +1 -1
  47. package/src/cjs/utils/dom/components/ColorGradientSelector.d.ts +1 -0
  48. package/src/cjs/utils/dom/components/ColorGradientSelector.js +4 -2
  49. package/src/cjs/utils/dom/components/ColorGradientSelector.js.map +1 -1
  50. package/src/cjs/utils/parsers/svg/types.d.ts +8 -8
  51. package/src/esm/Bounds.d.ts +79 -25
  52. package/src/esm/Bounds.js +102 -29
  53. package/src/esm/Bounds.js.map +1 -1
  54. package/src/esm/CircleSector.d.ts +3 -0
  55. package/src/esm/CircleSector.js +28 -1
  56. package/src/esm/CircleSector.js.map +1 -1
  57. package/src/esm/drawutilssvg.d.ts +2 -1
  58. package/src/esm/drawutilssvg.js +9 -3
  59. package/src/esm/drawutilssvg.js.map +1 -1
  60. package/src/esm/utils/LissajousFigure.d.ts +34 -0
  61. package/src/esm/utils/LissajousFigure.js +95 -0
  62. package/src/esm/utils/LissajousFigure.js.map +1 -0
  63. package/src/esm/utils/PerlinNoise.d.ts +19 -0
  64. package/src/esm/utils/PerlinNoise.js +346 -0
  65. package/src/esm/utils/PerlinNoise.js.map +1 -0
  66. package/src/esm/utils/SVGPathUtils.d.ts +22 -0
  67. package/src/esm/utils/SVGPathUtils.js +42 -0
  68. package/src/esm/utils/SVGPathUtils.js.map +1 -0
  69. package/src/esm/utils/algorithms/pixelCornersToRoundPaths.d.ts +23 -0
  70. package/src/esm/utils/algorithms/pixelCornersToRoundPaths.js +266 -0
  71. package/src/esm/utils/algorithms/pixelCornersToRoundPaths.js.map +1 -0
  72. package/src/esm/utils/datastructures/DataGrid2d.d.ts +6 -0
  73. package/src/esm/utils/datastructures/DataGrid2dArrayMatrix.d.ts +88 -0
  74. package/src/esm/utils/datastructures/DataGrid2dArrayMatrix.js +150 -0
  75. package/src/esm/utils/datastructures/DataGrid2dArrayMatrix.js.map +1 -0
  76. package/src/esm/utils/datastructures/DataGrid2dListAdapter.d.ts +1 -7
  77. package/src/esm/utils/datastructures/DataGrid2dListAdapter.js +3 -3
  78. package/src/esm/utils/datastructures/DataGrid2dListAdapter.js.map +1 -1
  79. package/src/esm/utils/datastructures/GeometryMesh.d.ts +49 -0
  80. package/src/esm/utils/datastructures/GeometryMesh.js +53 -0
  81. package/src/esm/utils/datastructures/GeometryMesh.js.map +1 -0
  82. package/src/esm/utils/detectDarkMode.js +16 -7
  83. package/src/esm/utils/detectDarkMode.js.map +1 -1
  84. package/src/esm/utils/dom/components/ColorGradientPicker.d.ts +4 -3
  85. package/src/esm/utils/dom/components/ColorGradientPicker.js +18 -7
  86. package/src/esm/utils/dom/components/ColorGradientPicker.js.map +1 -1
  87. package/src/esm/utils/dom/components/ColorGradientSelector.d.ts +1 -0
  88. package/src/esm/utils/dom/components/ColorGradientSelector.js +9 -2
  89. package/src/esm/utils/dom/components/ColorGradientSelector.js.map +1 -1
  90. package/src/esm/utils/parsers/svg/types.d.ts +8 -8
  91. package/src/ts/Bounds.ts +107 -22
  92. package/src/ts/CircleSector.ts +39 -6
  93. package/src/ts/drawutilssvg.ts +8 -3
  94. package/src/ts/utils/LissajousFigure.ts +110 -0
  95. package/src/ts/utils/PerlinNoise.ts +368 -0
  96. package/src/ts/utils/SVGPathUtils.ts +55 -0
  97. package/src/ts/utils/algorithms/pixelCornersToRoundPaths.ts +379 -0
  98. package/src/ts/utils/datastructures/DataGrid2d.ts +7 -0
  99. package/src/ts/utils/datastructures/DataGrid2dArrayMatrix.ts +182 -0
  100. package/src/ts/utils/datastructures/DataGrid2dListAdapter.ts +4 -11
  101. package/src/ts/utils/datastructures/GeometryMesh.ts +79 -0
  102. package/src/ts/utils/detectDarkMode.ts +17 -8
  103. package/src/ts/utils/dom/components/ColorGradientPicker.tsx +18 -6
  104. package/src/ts/utils/dom/components/ColorGradientSelector.tsx +9 -2
  105. package/src/ts/utils/parsers/svg/types.ts +8 -8
@@ -0,0 +1,266 @@
1
+ /**
2
+ * A script to convert any boolean matrix to rounded paths.
3
+ *
4
+ * @author Ikaros Kappler
5
+ * @date 2025-10-17 (ported to Typescript from a demo-script)
6
+ * @version 1.0.0
7
+ */
8
+ import { Bounds } from "../../Bounds";
9
+ import { DataGrid2dArrayMatrix } from "../datastructures/DataGrid2dArrayMatrix";
10
+ const LEFT_BORDER = 0;
11
+ const TOP_BORDER = 1;
12
+ const RIGHT_BORDER = 2;
13
+ const BOTTOM_BORDER = 3;
14
+ /**
15
+ * Computes an array of paths from the given boolean matrix.
16
+ *
17
+ * @param {DataGrid2dArrayMatrix<boolean>} matrix
18
+ * @param {PixelCornerPathOptions} options
19
+ * @returns
20
+ */
21
+ export const pixelCornersToRoundPaths = (matrix, options) => {
22
+ const paths = [];
23
+ const visitedLeftBorderMatrix = new DataGrid2dArrayMatrix(matrix.xSegmentCount, matrix.ySegmentCount, false);
24
+ const origin = options && options.origin ? options.origin : { x: 0, y: 0 };
25
+ const squareSize = options && typeof options.squareSize === "number" ? options.squareSize : 10;
26
+ const gapSize = options && typeof options.gapSize === "number" ? options.gapSize : 2;
27
+ const curveFactor = options && typeof options.curveFactor === "number" ? options.curveFactor : 0.666;
28
+ // Find an unvisited pixel with a free left neighbour
29
+ const condition = (value, x, y, _matrix) => {
30
+ return (value === true &&
31
+ visitedLeftBorderMatrix.get(x, y) === false &&
32
+ // is left neighbour free?
33
+ (x - 1 < 0 || _matrix.get(x - 1, y) === false));
34
+ };
35
+ // Just to be sure the while loop terminates after a maximum number of iterations.
36
+ const safetyLimit = matrix.xSegmentCount * matrix.ySegmentCount + 1;
37
+ // The next unvisited pixel position.
38
+ var nonVisitedPosition;
39
+ var i = 0;
40
+ while ((nonVisitedPosition = matrix.find(condition)) && i++ < safetyLimit) {
41
+ // console.log("nonVisitedPosition", nonVisitedPosition);
42
+ // Condition: if a point was found then its left neighbour is empty.
43
+ // So by this the current pixel's left bound is definitely a path start.
44
+ const squareBox = getSquareBox(origin, squareSize, gapSize, nonVisitedPosition.xIndex, nonVisitedPosition.yIndex);
45
+ const west = squareBox.getWestPoint();
46
+ // A starting point was found: Initialize the next path.
47
+ var pathData = [
48
+ // Start point
49
+ "M",
50
+ west.x,
51
+ west.y
52
+ ];
53
+ // Now from this point starting (left pixel corner) construct the next sequence of path commands.
54
+ __constructPath(pathData, matrix, visitedLeftBorderMatrix, nonVisitedPosition, LEFT_BORDER, origin, squareSize, gapSize, curveFactor);
55
+ paths.push(pathData);
56
+ // console.log("pathData", pathData);
57
+ }
58
+ return paths;
59
+ };
60
+ /**
61
+ * Construct a bounding box representing the visual square bounds for the given pixel.
62
+ *
63
+ * @param {XYCoords} origin - The origin to build the paths from (upper left corner of the graphics).
64
+ * @param {number} squareSize - The number of pixels to use to represent a pixel square.
65
+ * @param {number} gapSize - The number of pixels to use for gaps between squares.
66
+ * @param {number} x - The x position inside the data grid (matrix offset).
67
+ * @param {number} y - They position inside the data grid (matrix offset).
68
+ * @returns
69
+ */
70
+ const getSquareBox = (origin, squareSize, gapSize, x, y) => {
71
+ return new Bounds({
72
+ x: origin.x + x * (squareSize + gapSize),
73
+ y: origin.y + y * (squareSize + gapSize)
74
+ }, {
75
+ x: origin.x + x * (squareSize + gapSize) + squareSize,
76
+ y: origin.y + y * (squareSize + gapSize) + squareSize
77
+ });
78
+ };
79
+ /**
80
+ * Lerp between these two numbers using the passed lerp amount (usually a value in 0.0-1.0).
81
+ *
82
+ * @param {number} a
83
+ * @param {number} b
84
+ * @param {number} lerpFactor
85
+ * @returns {number}
86
+ */
87
+ const lerp = (a, b, lerpFactor) => {
88
+ return a + (b - a) * lerpFactor;
89
+ };
90
+ /**
91
+ * Construct a path command for a cubic Bézier curve.
92
+ *
93
+ * @param {SVGPathParams} pathData
94
+ * @param {XYCoords} start
95
+ * @param {XYCoords} controlA
96
+ * @param {XYCoords} controlB
97
+ * @param {XYCoords} end
98
+ * @param {number} curveFactor
99
+ */
100
+ const addRoundCorner = (pathData, start, controlA, controlB, end, curveFactor) => {
101
+ pathData.push("C", lerp(start.x, controlA.x, curveFactor), lerp(start.y, controlA.y, curveFactor), lerp(end.x, controlB.x, curveFactor), lerp(end.y, controlB.y, curveFactor), end.x, end.y);
102
+ };
103
+ /**
104
+ * Construct a new path command for a straight line.
105
+ *
106
+ * @param {SVGPathParams} pathData
107
+ * @param {XYCoords} target
108
+ */
109
+ const addStraightLine = (pathData, target) => {
110
+ pathData.push("L", target.x, target.y);
111
+ };
112
+ /**
113
+ * A helper function for constructing the next path, beginning at the passed matrix position.
114
+ *
115
+ * Note the path will be created at the left border of the given 'pixel', constructe
116
+ * in clockwise order.
117
+ *
118
+ * @param {SVGPathParams} pathData
119
+ * @param {DataGrid2dArrayMatrix<boolean>} matrix - The data matrix to use.
120
+ * @param {DataGrid2dArrayMatrix<boolean>} visitedLeftBordersMatrix - A helper matrix to keep track of visited pixels.
121
+ * @param {RasterPosition} startingPosition
122
+ * @param {number} startingBorderDirection
123
+ * @param {XYCoords} origin
124
+ * @param {number} squareSize
125
+ * @param {number} gapSize
126
+ * @param {number} curveFactor
127
+ */
128
+ const __constructPath = (pathData, matrix, visitedLeftBordersMatrix, startingPosition, startingBorderDirection, origin, squareSize, gapSize, curveFactor) => {
129
+ // Pre: position's neighbour pixel at ehe given border direction is unset.
130
+ var isPathComplete = false;
131
+ const maxInterations = matrix.xSegmentCount * matrix.ySegmentCount * 4 + 1;
132
+ var i = 0;
133
+ var position = startingPosition;
134
+ var borderDirection = startingBorderDirection;
135
+ while (!isPathComplete && i++ < maxInterations) {
136
+ var x = position.xIndex;
137
+ var y = position.yIndex;
138
+ // console.log("x", x, "y", y, "borderDirection", borderDirection);
139
+ // Get the pixel's box bounds.
140
+ const squareBox = getSquareBox(origin, squareSize, gapSize, x, y);
141
+ // Find next step when walking 'clockwise'
142
+ if (borderDirection === LEFT_BORDER) {
143
+ // Only track visits on left borders. By this we can detect non-visited holes :)
144
+ visitedLeftBordersMatrix.set(x, y, true);
145
+ // We want to expand the left border
146
+ const west = squareBox.getWestPoint();
147
+ // Pixel in the north?
148
+ if (y - 1 < 0 || matrix.get(x, y - 1) === false) {
149
+ // Northwise pixel is empty
150
+ // -> construct round corner to right
151
+ addRoundCorner(pathData, west, squareBox.getNorthWestPoint(), squareBox.getNorthWestPoint(), squareBox.getNorthPoint(), curveFactor);
152
+ borderDirection = TOP_BORDER;
153
+ // Keep pixel position unchanged
154
+ }
155
+ else if (x - 1 >= 0 && matrix.get(x - 1, y - 1) === true) {
156
+ // Top neighbour pixel is set AND top-left pixel is set too.
157
+ // -> construct rounded edge to top-left.
158
+ const squareBoxNW = getSquareBox(origin, squareSize, gapSize, x - 1, y - 1);
159
+ addRoundCorner(pathData, west, squareBox.getNorthWestPoint(), squareBoxNW.getSouthEastPoint(), squareBoxNW.getSouthPoint(), curveFactor);
160
+ borderDirection = BOTTOM_BORDER;
161
+ position = { xIndex: x - 1, yIndex: y - 1 };
162
+ }
163
+ else {
164
+ // Straight to top
165
+ const squareBoxN = getSquareBox(origin, squareSize, gapSize, x, y - 1);
166
+ addStraightLine(pathData, squareBoxN.getWestPoint());
167
+ position = { xIndex: x, yIndex: y - 1 };
168
+ // Keep borderDirection: LEFT_BORDER
169
+ // isPathComplete = true; // TODO
170
+ }
171
+ }
172
+ else if (borderDirection === TOP_BORDER) {
173
+ // North pixel is definitely empty.
174
+ const north = squareBox.getNorthPoint();
175
+ if (x + 1 >= matrix.xSegmentCount || matrix.get(x + 1, y) === false) {
176
+ // Top border and right pixel is empty
177
+ // --> create rounded corner to right south
178
+ addRoundCorner(pathData, north, squareBox.getNorthEastPoint(), squareBox.getNorthEastPoint(), squareBox.getEastPoint(), curveFactor);
179
+ borderDirection = RIGHT_BORDER;
180
+ // Keep pixel position unchanged
181
+ }
182
+ else if (y - 1 < 0 || matrix.get(x + 1, y - 1) === false) {
183
+ // Top border and right pixel is set, and north-east pixel is clear.
184
+ // -> linear path to right
185
+ const squareBoxE = getSquareBox(origin, squareSize, gapSize, x + 1, y);
186
+ addStraightLine(pathData, squareBoxE.getNorthPoint());
187
+ position = { xIndex: x + 1, yIndex: y };
188
+ // Keep borderDirection TOP
189
+ }
190
+ else {
191
+ // Last case: right neighbour is set and north-east pixel is set
192
+ //-> construct a rounded corner to east-north.
193
+ const squareBoxNE = getSquareBox(origin, squareSize, gapSize, x + 1, y - 1);
194
+ addRoundCorner(pathData, north, squareBox.getNorthEastPoint(), squareBoxNE.getSouthWestPoint(), squareBoxNE.getWestPoint(), curveFactor);
195
+ borderDirection = LEFT_BORDER;
196
+ position = { xIndex: x + 1, yIndex: y - 1 };
197
+ // isPathComplete = true; // TODO!!!
198
+ }
199
+ }
200
+ else if (borderDirection === RIGHT_BORDER) {
201
+ // East pixel is definitely empty.
202
+ var east = squareBox.getEastPoint();
203
+ if (y + 1 >= matrix.ySegmentCount || matrix.get(x, y + 1) === false) {
204
+ // South pixel is empty.
205
+ // -> construct rounded corner to south-east
206
+ addRoundCorner(pathData, east, squareBox.getSouthEastPoint(), squareBox.getSouthEastPoint(), squareBox.getSouthPoint(), curveFactor);
207
+ borderDirection = BOTTOM_BORDER;
208
+ // Keep pixel position unchanged
209
+ }
210
+ else if (x + 1 < matrix.xSegmentCount && y + 1 < matrix.ySegmentCount && matrix.get(x + 1, y + 1) === true) {
211
+ // South pixel is set AND right lower pixel is set, too.
212
+ // -> construct round corner to south-east.
213
+ const squareBoxSE = getSquareBox(origin, squareSize, gapSize, x + 1, y + 1);
214
+ addRoundCorner(pathData, east, squareBox.getSouthEastPoint(), squareBoxSE.getNorthWestPoint(), squareBoxSE.getNorthPoint(), curveFactor);
215
+ borderDirection = TOP_BORDER;
216
+ position = { xIndex: x + 1, yIndex: y + 1 };
217
+ }
218
+ else {
219
+ // South pixel is set and south-east pixel is clear.
220
+ // -> construct linear connection to south
221
+ const squareBoxS = getSquareBox(origin, squareSize, gapSize, x, y + 1);
222
+ addStraightLine(pathData, squareBoxS.getEastPoint());
223
+ position = { xIndex: x, yIndex: y + 1 };
224
+ // Keep borderDirection RIGHT
225
+ }
226
+ }
227
+ else if (borderDirection === BOTTOM_BORDER) {
228
+ // Pre: south pixel is definitely empty
229
+ const south = squareBox.getSouthPoint();
230
+ if (x - 1 < 0 || matrix.get(x - 1, y) === false) {
231
+ // Left pixel is empty
232
+ // -> construct round corner to west-north
233
+ addRoundCorner(pathData, south, squareBox.getSouthWestPoint(), squareBox.getSouthWestPoint(), squareBox.getWestPoint(), curveFactor);
234
+ borderDirection = LEFT_BORDER;
235
+ }
236
+ else if (x - 1 >= 0 && y + 1 < matrix.ySegmentCount && matrix.get(x - 1, y + 1) === true) {
237
+ // Left pixel AND left lower pixel are set
238
+ // -> construct rounded edge to south-west
239
+ const squareBoxSW = getSquareBox(origin, squareSize, gapSize, x - 1, y + 1);
240
+ addRoundCorner(pathData, south, squareBox.getSouthWestPoint(), squareBoxSW.getNorthEastPoint(), squareBoxSW.getEastPoint(), curveFactor);
241
+ borderDirection = RIGHT_BORDER;
242
+ position = { xIndex: x - 1, yIndex: y + 1 };
243
+ }
244
+ else {
245
+ // Left pixel is set AND south pixel is empty
246
+ // -> construct linear edge to left neighbour.
247
+ const squareBoxW = getSquareBox(origin, squareSize, gapSize, x - 1, y);
248
+ addStraightLine(pathData, squareBoxW.getSouthPoint());
249
+ position = { xIndex: x - 1, yIndex: y };
250
+ // Keep borderDirection BOTTOM
251
+ }
252
+ }
253
+ else {
254
+ console.warn(`[Error] Cannot construct full rounded path; 'borderDirection' has wrong value (${borderDirection}).`);
255
+ isPathComplete = true;
256
+ }
257
+ // End condition reached?
258
+ if (startingPosition.xIndex === position.xIndex &&
259
+ startingPosition.yIndex === position.yIndex &&
260
+ startingBorderDirection === borderDirection) {
261
+ pathData.push("Z");
262
+ isPathComplete = true;
263
+ }
264
+ }
265
+ };
266
+ //# sourceMappingURL=pixelCornersToRoundPaths.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pixelCornersToRoundPaths.js","sourceRoot":"","sources":["../../../ts/utils/algorithms/pixelCornersToRoundPaths.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAGtC,OAAO,EAAE,qBAAqB,EAAE,MAAM,yCAAyC,CAAC;AAEhF,MAAM,WAAW,GAAW,CAAC,CAAC;AAC9B,MAAM,UAAU,GAAW,CAAC,CAAC;AAC7B,MAAM,YAAY,GAAW,CAAC,CAAC;AAC/B,MAAM,aAAa,GAAW,CAAC,CAAC;AAShC;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CACtC,MAAsC,EACtC,OAA+B,EACT,EAAE;IACxB,MAAM,KAAK,GAAyB,EAAE,CAAC;IACvC,MAAM,uBAAuB,GAAG,IAAI,qBAAqB,CAAC,MAAM,CAAC,aAAa,EAAE,MAAM,CAAC,aAAa,EAAE,KAAK,CAAC,CAAC;IAE7G,MAAM,MAAM,GAAa,OAAO,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;IACrF,MAAM,UAAU,GAAW,OAAO,IAAI,OAAO,OA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U,CAAC,aAAa,EAAE,CAAC,CAAC;gBACtD,QAAQ,GAAG,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;gBACxC,8BAA8B;YAChC,CAAC;QACH,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,IAAI,CAAC,kFAAkF,eAAe,IAAI,CAAC,CAAC;YACpH,cAAc,GAAG,IAAI,CAAC;QACxB,CAAC;QAED,yBAAyB;QACzB,IACE,gBAAgB,CAAC,MAAM,KAAK,QAAQ,CAAC,MAAM;YAC3C,gBAAgB,CAAC,MAAM,KAAK,QAAQ,CAAC,MAAM;YAC3C,uBAAuB,KAAK,eAAe,EAC3C,CAAC;YACD,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YACnB,cAAc,GAAG,IAAI,CAAC;QACxB,CAAC;IACH,CAAC;AACH,CAAC,CAAC"}
@@ -16,6 +16,12 @@
16
16
  * @version 1.0.0
17
17
  */
18
18
  export type DataGridFace4<T> = [[T | null, T | null], [T | null, T | null]];
19
+ export type RasterPosition = {
20
+ xIndex: number;
21
+ yIndex: number;
22
+ xRel?: number;
23
+ yRel?: number;
24
+ };
19
25
  export interface IDataGrid2d<T> {
20
26
  readonly xSegmentCount: number;
21
27
  readonly ySegmentCount: number;
@@ -0,0 +1,88 @@
1
+ /**
2
+ * A DataGrid2d implementation on 2 dimensional arrays.
3
+ *
4
+ * @author Ikaros Kappler
5
+ * @date 2025-10-16
6
+ * @modified 2025-10-28 Added `DataGrid2dArrayMatrix.setAll(function)`.
7
+ * @modified 2025-10-28 Fixed a bug in the `DataGrid2dArrayMatrix.toString()` method.
8
+ * @version 1.0.0
9
+ **/
10
+ import { DataGridFace4, IDataGrid2d, RasterPosition } from "./DataGrid2d";
11
+ export declare class DataGrid2dArrayMatrix<T> implements IDataGrid2d<T> {
12
+ /**
13
+ * @override
14
+ */
15
+ readonly xSegmentCount: number;
16
+ /**
17
+ * @override
18
+ */
19
+ readonly ySegmentCount: number;
20
+ minDataValue: T;
21
+ maxDataValue: T;
22
+ private _matrix;
23
+ /**
24
+ * Create a new DataGrid2d from the given
25
+ * @throws Error if xSegmentCount*ySegmentCount is larger than the capacity of the array/list.
26
+ * @param list
27
+ * @param xSegmentCount
28
+ * @param ySegmentCount
29
+ */
30
+ constructor(xSegmentCount: number, ySegmentCount: number, initialValue: T);
31
+ /**
32
+ * Set the matrix value at the given (x,y) position to a new value.
33
+ *
34
+ * @param {number} xIndex - The horizontal matrix position to set.
35
+ * @param {number} yIndex - The vertical matrix position to set.
36
+ * @param {T} value - The new value.
37
+ */
38
+ set(xIndex: number, yIndex: number, value: T): void;
39
+ /**
40
+ * Getthe matrix value at the given (x,y) position.
41
+ *
42
+ * @param {number} xIndex - The horizontal matrix position to set.
43
+ * @param {number} yIndex - The vertical matrix position to set.
44
+ * @return {T} value - The new value.
45
+ */
46
+ get(xIndex: number, yIndex: number): T;
47
+ /**
48
+ * Set all matrix values. The passed factory function must accept respective (x,y) positions.
49
+ *
50
+ * @param {Function} factory - The factory function to determine the new values to set.
51
+ * @return {DataGrid2dArrayMatrix<T>} this - for chaning.
52
+ */
53
+ setAll(factory: (xIndex: number, yIndex: number) => T): DataGrid2dArrayMatrix<T>;
54
+ find(condition: (value: T, xIndex: number, yIndex: number, sourceMatrix: DataGrid2dArrayMatrix<T>) => boolean): RasterPosition;
55
+ /**
56
+ * @override
57
+ */
58
+ getMinDataValue(): T;
59
+ /**
60
+ * @override
61
+ */
62
+ getMaxDataValue(): T;
63
+ /**
64
+ * @override
65
+ */
66
+ getDataValueAt(xIndex: number, yIndex: number, isDebug?: boolean): T | null;
67
+ /**
68
+ * @override
69
+ */
70
+ getDataFace4At(xIndex: number, yIndex: number, buffer: DataGridFace4<T>): void;
71
+ /**
72
+ * A helper method to convert a boolean matrix to a parsable string.
73
+ *
74
+ * @param {DataGrid2dArrayMatrix<boolean>} matrix
75
+ * @returns {string}
76
+ */
77
+ static toString(matrix: DataGrid2dArrayMatrix<boolean>): string;
78
+ /**
79
+ * Simple way to parse a data matrix from a string. `false` should be coded as '.' character,
80
+ * `true` must be coded as 'X' character.
81
+ *
82
+ * @param {string} str - The input string.
83
+ * @param {number} width - The desired width of the matrix (xSegmentCount).
84
+ * @param {number} height - The desired height of the matrix (ySegmentCount).
85
+ * @returns {DataGrid2dArrayMatrix<boolean>}
86
+ */
87
+ static parseBooleanMatrix(str: string, width: number, height: number): DataGrid2dArrayMatrix<boolean>;
88
+ }
@@ -0,0 +1,150 @@
1
+ /**
2
+ * A DataGrid2d implementation on 2 dimensional arrays.
3
+ *
4
+ * @author Ikaros Kappler
5
+ * @date 2025-10-16
6
+ * @modified 2025-10-28 Added `DataGrid2dArrayMatrix.setAll(function)`.
7
+ * @modified 2025-10-28 Fixed a bug in the `DataGrid2dArrayMatrix.toString()` method.
8
+ * @version 1.0.0
9
+ **/
10
+ import { arrayFill } from "../algorithms/arrayFill";
11
+ export class DataGrid2dArrayMatrix {
12
+ /**
13
+ * Create a new DataGrid2d from the given
14
+ * @throws Error if xSegmentCount*ySegmentCount is larger than the capacity of the array/list.
15
+ * @param list
16
+ * @param xSegmentCount
17
+ * @param ySegmentCount
18
+ */
19
+ constructor(xSegmentCount, ySegmentCount, initialValue) {
20
+ if (xSegmentCount <= 0) {
21
+ throw `Cannot create DataGrid2dArray, xSegmentCount (${xSegmentCount}) must be > 0.`;
22
+ }
23
+ if (ySegmentCount <= 0) {
24
+ throw `Cannot create DataGrid2dArray, ySegmentCount (${ySegmentCount}) must be > 0.`;
25
+ }
26
+ // this.canvas = document.getElementById(canvasId);
27
+ this.xSegmentCount = xSegmentCount;
28
+ this.ySegmentCount = ySegmentCount;
29
+ this._matrix = [];
30
+ for (var i = 0; i < ySegmentCount; i++) {
31
+ this._matrix.push(arrayFill(xSegmentCount, initialValue));
32
+ }
33
+ }
34
+ /**
35
+ * Set the matrix value at the given (x,y) position to a new value.
36
+ *
37
+ * @param {number} xIndex - The horizontal matrix position to set.
38
+ * @param {number} yIndex - The vertical matrix position to set.
39
+ * @param {T} value - The new value.
40
+ */
41
+ set(xIndex, yIndex, value) {
42
+ this._matrix[yIndex][xIndex] = value;
43
+ }
44
+ /**
45
+ * Getthe matrix value at the given (x,y) position.
46
+ *
47
+ * @param {number} xIndex - The horizontal matrix position to set.
48
+ * @param {number} yIndex - The vertical matrix position to set.
49
+ * @return {T} value - The new value.
50
+ */
51
+ get(xIndex, yIndex) {
52
+ return this.getDataValueAt(xIndex, yIndex);
53
+ }
54
+ /**
55
+ * Set all matrix values. The passed factory function must accept respective (x,y) positions.
56
+ *
57
+ * @param {Function} factory - The factory function to determine the new values to set.
58
+ * @return {DataGrid2dArrayMatrix<T>} this - for chaning.
59
+ */
60
+ setAll(factory) {
61
+ for (var x = 0; x < this.xSegmentCount; x++) {
62
+ for (var y = 0; y < this.ySegmentCount; y++) {
63
+ this.set(x, y, factory(x, y));
64
+ }
65
+ }
66
+ return this;
67
+ }
68
+ find(condition) {
69
+ for (var x = 0; x < this.xSegmentCount; x++) {
70
+ for (var y = 0; y < this.ySegmentCount; y++) {
71
+ if (condition(this.get(x, y), x, y, this)) {
72
+ return {
73
+ xIndex: x,
74
+ yIndex: y,
75
+ xRel: x / this.xSegmentCount,
76
+ yRel: y / this.ySegmentCount
77
+ };
78
+ }
79
+ }
80
+ }
81
+ return null;
82
+ }
83
+ /**
84
+ * @override
85
+ */
86
+ getMinDataValue() {
87
+ return this.minDataValue;
88
+ }
89
+ /**
90
+ * @override
91
+ */
92
+ getMaxDataValue() {
93
+ return this.maxDataValue;
94
+ }
95
+ /**
96
+ * @override
97
+ */
98
+ getDataValueAt(xIndex, yIndex, isDebug) {
99
+ return this._matrix[yIndex][xIndex];
100
+ }
101
+ /**
102
+ * @override
103
+ */
104
+ getDataFace4At(xIndex, yIndex, buffer) {
105
+ // buffer: array[2][2]
106
+ buffer[0][0] = this.getDataValueAt(xIndex, yIndex);
107
+ buffer[1][0] = this.getDataValueAt(xIndex + 1, yIndex);
108
+ buffer[1][1] = this.getDataValueAt(xIndex + 1, yIndex + 1);
109
+ buffer[0][1] = this.getDataValueAt(xIndex, yIndex + 1);
110
+ }
111
+ /**
112
+ * A helper method to convert a boolean matrix to a parsable string.
113
+ *
114
+ * @param {DataGrid2dArrayMatrix<boolean>} matrix
115
+ * @returns {string}
116
+ */
117
+ static toString(matrix) {
118
+ const buffer = [];
119
+ for (var y = 0; y < matrix.ySegmentCount; y++) {
120
+ for (var x = 0; x < matrix.xSegmentCount; x++) {
121
+ buffer.push(matrix.get(x, y) ? "X" : ".");
122
+ }
123
+ buffer.push("\n");
124
+ }
125
+ return buffer.join("");
126
+ }
127
+ /**
128
+ * Simple way to parse a data matrix from a string. `false` should be coded as '.' character,
129
+ * `true` must be coded as 'X' character.
130
+ *
131
+ * @param {string} str - The input string.
132
+ * @param {number} width - The desired width of the matrix (xSegmentCount).
133
+ * @param {number} height - The desired height of the matrix (ySegmentCount).
134
+ * @returns {DataGrid2dArrayMatrix<boolean>}
135
+ */
136
+ static parseBooleanMatrix(str, width, height) {
137
+ const matrix = new DataGrid2dArrayMatrix(width, height, false);
138
+ const lines = str.trim().split("\n");
139
+ for (var y = 0; y < lines.length && y < height; y++) {
140
+ lines[y] = lines[y].trim();
141
+ for (var x = 0; x < lines[y].length && x < width; x++) {
142
+ if (y < height && x < width && lines[y].charAt(x) === "X") {
143
+ matrix.set(x, y, true);
144
+ }
145
+ }
146
+ }
147
+ return matrix;
148
+ }
149
+ }
150
+ //# sourceMappingURL=DataGrid2dArrayMatrix.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DataGrid2dArrayMatrix.js","sourceRoot":"","sources":["../../../ts/utils/datastructures/DataGrid2dArrayMatrix.ts"],"names":[],"mappings":"AAAA;;;;;;;;IAQI;AAEJ,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAGpD,MAAM,OAAO,qBAAqB;IAiBhC;;;;;;OAMG;IACH,YAAY,aAAqB,EAAE,aAAqB,EAAE,Y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AC,CAAC,CAAC,IAAI,EAAE,CAAC;YAC3B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,GAAG,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC;gBACtD,IAAI,CAAC,GAAG,MAAM,IAAI,CAAC,GAAG,KAAK,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC;oBAC1D,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC;gBACzB,CAAC;YACH,CAAC;QACH,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}
@@ -6,18 +6,12 @@
6
6
  * @modified 2023-11-04 Converted to a Typescript class.
7
7
  * @version 1.0.0
8
8
  **/
9
- import { DataGridFace4, IDataGrid2d } from "./DataGrid2d";
9
+ import { DataGridFace4, IDataGrid2d, RasterPosition } from "./DataGrid2d";
10
10
  type Triplet<T> = {
11
11
  x: T;
12
12
  y: T;
13
13
  z: T;
14
14
  };
15
- type RasterPosition = {
16
- xIndex: number;
17
- yIndex: number;
18
- xRel?: number;
19
- yRel?: number;
20
- };
21
15
  export declare class DataGrid2dListAdapter<T> implements IDataGrid2d<T> {
22
16
  /**
23
17
  * @override
@@ -54,9 +54,9 @@ export class DataGrid2dListAdapter {
54
54
  getDataValueAt(xIndex, yIndex, isDebug) {
55
55
  // var bufferIndex = yIndex * this.xSegmentCount + xIndex;
56
56
  var bufferIndex = this.coordinateIndicesToBufferIndex(xIndex, yIndex);
57
- if (isDebug) {
58
- console.log("xIndex", xIndex, "yIndex", yIndex, "bufferIndex", bufferIndex);
59
- }
57
+ // if (isDebug) {
58
+ // console.log("xIndex", xIndex, "yIndex", yIndex, "bufferIndex", bufferIndex);
59
+ // }
60
60
  if (bufferIndex > this._dataList.length) {
61
61
  console.error("ERR buffer index is out of bounds! xIndex", xIndex, "yIndex", yIndex, "bufferIndex", bufferIndex);
62
62
  }
@@ -1 +1 @@
1
- {"version":3,"file":"DataGrid2dListAdapter.js","sourceRoot":"","sources":["../../../ts/utils/datastructures/DataGrid2dListAdapter.ts"],"names":[],"mappings":"AAAA;;;;;;;IAOI;AAiBJ,MAAM,OAAO,qBAAqB;IAmBhC;;;;;;OAMG;IACH,YAAY,IAAuB,EAAE,aAAqB,EAAE,aAAqB;QAC/E,IAAI,aAAa,GAAG,aAAa,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;YAChD,MAAM,yDAAyD,IAAI,CAAC,MAAM,uCAAuC,aAAa,IAAI,aAAa,oBAAoB,CAAC;QACtK,CAAC;QAED,mDAAmD;QACnD,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QAEnC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;IACxB,CAAC;IAED,yBAAyB,CAAC,WAAmB;QAC3C,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,WAAW,GAAG,IAAI,CAAC,aAAa,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,WAAW,GAAG,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC;IACxH,CAAC;IAED,wBAAwB,CAAC,WAAmB;QAC1C,IAAI,KAAK,GAAG,IAAI,CAAC,yBAAyB,CAAC,WAAW,CAAC,CAAC;QACxD,uGAAuG;QACvG,KAAK,CAAC,IAAI,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,aAAa,GAAG,CAAC,CAAC,CAAC;QACrD,KAAK,CAAC,IAAI,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,aAAa,GAAG,CAAC,CAAC,CAAC;QACrD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,8BAA8B,CAAC,MAAc,EAAE,MAAc;QAC3D,OAAO,MAAM,GAAG,IAAI,CAAC,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CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACtG,CAAC;IAED;;OAEG;IACH,cAAc,CAAC,MAAc,EAAE,MAAc,EAAE,MAAwB;QACrE,sBAAsB;QACtB,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACnD,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE,MAAM,CAAC,CAAC;QACvD,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,CAAC;QAC3D,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,CAAC,CAAC,CAAC;IACzD,CAAC;CACF"}
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Adapted from the 3D geometry datastuctured from demo-33 (depth mesh).
3
+ *
4
+ * Refactored the strucure into a class.
5
+ *
6
+ * @author Ikaros Kappler
7
+ * @date 2025-11-14
8
+ * @modified 2025-11-17 Moved `getBounds` and `normalizeGeometry` from helper functions to this class.
9
+ * @version 1.0.0
10
+ */
11
+ export type Vertex2 = {
12
+ x: number;
13
+ y: number;
14
+ };
15
+ export type Vertex3 = {
16
+ x: number;
17
+ y: number;
18
+ z: number;
19
+ };
20
+ export declare class GeometryMesh<T extends Vertex2 | Vertex3> {
21
+ /**
22
+ * A set (array) of vertices (points) used in this mesh. Can be 2d or 3d.
23
+ *
24
+ * @member {Array<T>}
25
+ * @memberof GeometryMesh
26
+ * @type {Array<T>}
27
+ * @instance
28
+ */
29
+ vertices: Array<T>;
30
+ /**
31
+ * A set (array) of edges used in this mesh.
32
+ * Each edge consist of two indices indicating the vertex position.
33
+ *
34
+ * @member {Array<T>}
35
+ * @memberof GeometryMesh
36
+ * @type {Array<T>}
37
+ * @instance
38
+ */
39
+ edges: Array<[number, number]>;
40
+ constructor(vertices?: Array<T>, edges?: Array<[number, number]>);
41
+ normalize(): void;
42
+ getGeometryBounds(): {
43
+ min: Vertex3;
44
+ max: Vertex3;
45
+ width: number;
46
+ height: number;
47
+ depth: number;
48
+ };
49
+ }