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.
- package/README.md +1 -0
- package/dist/index.esm.js +139 -33
- package/dist/index.esm.js.map +1 -1
- package/dist/index.esm.min.js +1 -1
- package/dist/index.esm.min.js.map +1 -1
- package/dist/plotboilerplate.browser.min.js +1 -1
- package/dist/plotboilerplate.browser.min.js.map +1 -1
- package/dist/plotboilerplate.js +139 -33
- package/dist/plotboilerplate.min.js +1 -1
- package/package.json +1 -1
- package/src/cjs/Bounds.d.ts +79 -25
- package/src/cjs/Bounds.js +102 -29
- package/src/cjs/Bounds.js.map +1 -1
- package/src/cjs/CircleSector.d.ts +3 -0
- package/src/cjs/CircleSector.js +28 -1
- package/src/cjs/CircleSector.js.map +1 -1
- package/src/cjs/drawutilssvg.d.ts +2 -1
- package/src/cjs/drawutilssvg.js +9 -3
- package/src/cjs/drawutilssvg.js.map +1 -1
- package/src/cjs/utils/LissajousFigure.d.ts +34 -0
- package/src/cjs/utils/LissajousFigure.js +100 -0
- package/src/cjs/utils/LissajousFigure.js.map +1 -0
- package/src/cjs/utils/PerlinNoise.d.ts +19 -0
- package/src/cjs/utils/PerlinNoise.js +352 -0
- package/src/cjs/utils/PerlinNoise.js.map +1 -0
- package/src/cjs/utils/SVGPathUtils.d.ts +22 -0
- package/src/cjs/utils/SVGPathUtils.js +45 -0
- package/src/cjs/utils/SVGPathUtils.js.map +1 -0
- package/src/cjs/utils/algorithms/pixelCornersToRoundPaths.d.ts +23 -0
- package/src/cjs/utils/algorithms/pixelCornersToRoundPaths.js +270 -0
- package/src/cjs/utils/algorithms/pixelCornersToRoundPaths.js.map +1 -0
- package/src/cjs/utils/datastructures/DataGrid2d.d.ts +6 -0
- package/src/cjs/utils/datastructures/DataGrid2dArrayMatrix.d.ts +88 -0
- package/src/cjs/utils/datastructures/DataGrid2dArrayMatrix.js +155 -0
- package/src/cjs/utils/datastructures/DataGrid2dArrayMatrix.js.map +1 -0
- package/src/cjs/utils/datastructures/DataGrid2dListAdapter.d.ts +1 -7
- package/src/cjs/utils/datastructures/DataGrid2dListAdapter.js +3 -3
- package/src/cjs/utils/datastructures/DataGrid2dListAdapter.js.map +1 -1
- package/src/cjs/utils/datastructures/GeometryMesh.d.ts +49 -0
- package/src/cjs/utils/datastructures/GeometryMesh.js +58 -0
- package/src/cjs/utils/datastructures/GeometryMesh.js.map +1 -0
- package/src/cjs/utils/detectDarkMode.js +16 -7
- package/src/cjs/utils/detectDarkMode.js.map +1 -1
- package/src/cjs/utils/dom/components/ColorGradientPicker.d.ts +4 -3
- package/src/cjs/utils/dom/components/ColorGradientPicker.js +8 -8
- package/src/cjs/utils/dom/components/ColorGradientPicker.js.map +1 -1
- package/src/cjs/utils/dom/components/ColorGradientSelector.d.ts +1 -0
- package/src/cjs/utils/dom/components/ColorGradientSelector.js +4 -2
- package/src/cjs/utils/dom/components/ColorGradientSelector.js.map +1 -1
- package/src/cjs/utils/parsers/svg/types.d.ts +8 -8
- package/src/esm/Bounds.d.ts +79 -25
- package/src/esm/Bounds.js +102 -29
- package/src/esm/Bounds.js.map +1 -1
- package/src/esm/CircleSector.d.ts +3 -0
- package/src/esm/CircleSector.js +28 -1
- package/src/esm/CircleSector.js.map +1 -1
- package/src/esm/drawutilssvg.d.ts +2 -1
- package/src/esm/drawutilssvg.js +9 -3
- package/src/esm/drawutilssvg.js.map +1 -1
- package/src/esm/utils/LissajousFigure.d.ts +34 -0
- package/src/esm/utils/LissajousFigure.js +95 -0
- package/src/esm/utils/LissajousFigure.js.map +1 -0
- package/src/esm/utils/PerlinNoise.d.ts +19 -0
- package/src/esm/utils/PerlinNoise.js +346 -0
- package/src/esm/utils/PerlinNoise.js.map +1 -0
- package/src/esm/utils/SVGPathUtils.d.ts +22 -0
- package/src/esm/utils/SVGPathUtils.js +42 -0
- package/src/esm/utils/SVGPathUtils.js.map +1 -0
- package/src/esm/utils/algorithms/pixelCornersToRoundPaths.d.ts +23 -0
- package/src/esm/utils/algorithms/pixelCornersToRoundPaths.js +266 -0
- package/src/esm/utils/algorithms/pixelCornersToRoundPaths.js.map +1 -0
- package/src/esm/utils/datastructures/DataGrid2d.d.ts +6 -0
- package/src/esm/utils/datastructures/DataGrid2dArrayMatrix.d.ts +88 -0
- package/src/esm/utils/datastructures/DataGrid2dArrayMatrix.js +150 -0
- package/src/esm/utils/datastructures/DataGrid2dArrayMatrix.js.map +1 -0
- package/src/esm/utils/datastructures/DataGrid2dListAdapter.d.ts +1 -7
- package/src/esm/utils/datastructures/DataGrid2dListAdapter.js +3 -3
- package/src/esm/utils/datastructures/DataGrid2dListAdapter.js.map +1 -1
- package/src/esm/utils/datastructures/GeometryMesh.d.ts +49 -0
- package/src/esm/utils/datastructures/GeometryMesh.js +53 -0
- package/src/esm/utils/datastructures/GeometryMesh.js.map +1 -0
- package/src/esm/utils/detectDarkMode.js +16 -7
- package/src/esm/utils/detectDarkMode.js.map +1 -1
- package/src/esm/utils/dom/components/ColorGradientPicker.d.ts +4 -3
- package/src/esm/utils/dom/components/ColorGradientPicker.js +18 -7
- package/src/esm/utils/dom/components/ColorGradientPicker.js.map +1 -1
- package/src/esm/utils/dom/components/ColorGradientSelector.d.ts +1 -0
- package/src/esm/utils/dom/components/ColorGradientSelector.js +9 -2
- package/src/esm/utils/dom/components/ColorGradientSelector.js.map +1 -1
- package/src/esm/utils/parsers/svg/types.d.ts +8 -8
- package/src/ts/Bounds.ts +107 -22
- package/src/ts/CircleSector.ts +39 -6
- package/src/ts/drawutilssvg.ts +8 -3
- package/src/ts/utils/LissajousFigure.ts +110 -0
- package/src/ts/utils/PerlinNoise.ts +368 -0
- package/src/ts/utils/SVGPathUtils.ts +55 -0
- package/src/ts/utils/algorithms/pixelCornersToRoundPaths.ts +379 -0
- package/src/ts/utils/datastructures/DataGrid2d.ts +7 -0
- package/src/ts/utils/datastructures/DataGrid2dArrayMatrix.ts +182 -0
- package/src/ts/utils/datastructures/DataGrid2dListAdapter.ts +4 -11
- package/src/ts/utils/datastructures/GeometryMesh.ts +79 -0
- package/src/ts/utils/detectDarkMode.ts +17 -8
- package/src/ts/utils/dom/components/ColorGradientPicker.tsx +18 -6
- package/src/ts/utils/dom/components/ColorGradientSelector.tsx +9 -2
- package/src/ts/utils/parsers/svg/types.ts +8 -8
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* A script to convert any boolean matrix to rounded paths.
|
|
4
|
+
*
|
|
5
|
+
* @author Ikaros Kappler
|
|
6
|
+
* @date 2025-10-17 (ported to Typescript from a demo-script)
|
|
7
|
+
* @version 1.0.0
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.pixelCornersToRoundPaths = void 0;
|
|
11
|
+
var Bounds_1 = require("../../Bounds");
|
|
12
|
+
var DataGrid2dArrayMatrix_1 = require("../datastructures/DataGrid2dArrayMatrix");
|
|
13
|
+
var LEFT_BORDER = 0;
|
|
14
|
+
var TOP_BORDER = 1;
|
|
15
|
+
var RIGHT_BORDER = 2;
|
|
16
|
+
var BOTTOM_BORDER = 3;
|
|
17
|
+
/**
|
|
18
|
+
* Computes an array of paths from the given boolean matrix.
|
|
19
|
+
*
|
|
20
|
+
* @param {DataGrid2dArrayMatrix<boolean>} matrix
|
|
21
|
+
* @param {PixelCornerPathOptions} options
|
|
22
|
+
* @returns
|
|
23
|
+
*/
|
|
24
|
+
var pixelCornersToRoundPaths = function (matrix, options) {
|
|
25
|
+
var paths = [];
|
|
26
|
+
var visitedLeftBorderMatrix = new DataGrid2dArrayMatrix_1.DataGrid2dArrayMatrix(matrix.xSegmentCount, matrix.ySegmentCount, false);
|
|
27
|
+
var origin = options && options.origin ? options.origin : { x: 0, y: 0 };
|
|
28
|
+
var squareSize = options && typeof options.squareSize === "number" ? options.squareSize : 10;
|
|
29
|
+
var gapSize = options && typeof options.gapSize === "number" ? options.gapSize : 2;
|
|
30
|
+
var curveFactor = options && typeof options.curveFactor === "number" ? options.curveFactor : 0.666;
|
|
31
|
+
// Find an unvisited pixel with a free left neighbour
|
|
32
|
+
var condition = function (value, x, y, _matrix) {
|
|
33
|
+
return (value === true &&
|
|
34
|
+
visitedLeftBorderMatrix.get(x, y) === false &&
|
|
35
|
+
// is left neighbour free?
|
|
36
|
+
(x - 1 < 0 || _matrix.get(x - 1, y) === false));
|
|
37
|
+
};
|
|
38
|
+
// Just to be sure the while loop terminates after a maximum number of iterations.
|
|
39
|
+
var safetyLimit = matrix.xSegmentCount * matrix.ySegmentCount + 1;
|
|
40
|
+
// The next unvisited pixel position.
|
|
41
|
+
var nonVisitedPosition;
|
|
42
|
+
var i = 0;
|
|
43
|
+
while ((nonVisitedPosition = matrix.find(condition)) && i++ < safetyLimit) {
|
|
44
|
+
// console.log("nonVisitedPosition", nonVisitedPosition);
|
|
45
|
+
// Condition: if a point was found then its left neighbour is empty.
|
|
46
|
+
// So by this the current pixel's left bound is definitely a path start.
|
|
47
|
+
var squareBox = getSquareBox(origin, squareSize, gapSize, nonVisitedPosition.xIndex, nonVisitedPosition.yIndex);
|
|
48
|
+
var west = squareBox.getWestPoint();
|
|
49
|
+
// A starting point was found: Initialize the next path.
|
|
50
|
+
var pathData = [
|
|
51
|
+
// Start point
|
|
52
|
+
"M",
|
|
53
|
+
west.x,
|
|
54
|
+
west.y
|
|
55
|
+
];
|
|
56
|
+
// Now from this point starting (left pixel corner) construct the next sequence of path commands.
|
|
57
|
+
__constructPath(pathData, matrix, visitedLeftBorderMatrix, nonVisitedPosition, LEFT_BORDER, origin, squareSize, gapSize, curveFactor);
|
|
58
|
+
paths.push(pathData);
|
|
59
|
+
// console.log("pathData", pathData);
|
|
60
|
+
}
|
|
61
|
+
return paths;
|
|
62
|
+
};
|
|
63
|
+
exports.pixelCornersToRoundPaths = pixelCornersToRoundPaths;
|
|
64
|
+
/**
|
|
65
|
+
* Construct a bounding box representing the visual square bounds for the given pixel.
|
|
66
|
+
*
|
|
67
|
+
* @param {XYCoords} origin - The origin to build the paths from (upper left corner of the graphics).
|
|
68
|
+
* @param {number} squareSize - The number of pixels to use to represent a pixel square.
|
|
69
|
+
* @param {number} gapSize - The number of pixels to use for gaps between squares.
|
|
70
|
+
* @param {number} x - The x position inside the data grid (matrix offset).
|
|
71
|
+
* @param {number} y - They position inside the data grid (matrix offset).
|
|
72
|
+
* @returns
|
|
73
|
+
*/
|
|
74
|
+
var getSquareBox = function (origin, squareSize, gapSize, x, y) {
|
|
75
|
+
return new Bounds_1.Bounds({
|
|
76
|
+
x: origin.x + x * (squareSize + gapSize),
|
|
77
|
+
y: origin.y + y * (squareSize + gapSize)
|
|
78
|
+
}, {
|
|
79
|
+
x: origin.x + x * (squareSize + gapSize) + squareSize,
|
|
80
|
+
y: origin.y + y * (squareSize + gapSize) + squareSize
|
|
81
|
+
});
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* Lerp between these two numbers using the passed lerp amount (usually a value in 0.0-1.0).
|
|
85
|
+
*
|
|
86
|
+
* @param {number} a
|
|
87
|
+
* @param {number} b
|
|
88
|
+
* @param {number} lerpFactor
|
|
89
|
+
* @returns {number}
|
|
90
|
+
*/
|
|
91
|
+
var lerp = function (a, b, lerpFactor) {
|
|
92
|
+
return a + (b - a) * lerpFactor;
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* Construct a path command for a cubic Bézier curve.
|
|
96
|
+
*
|
|
97
|
+
* @param {SVGPathParams} pathData
|
|
98
|
+
* @param {XYCoords} start
|
|
99
|
+
* @param {XYCoords} controlA
|
|
100
|
+
* @param {XYCoords} controlB
|
|
101
|
+
* @param {XYCoords} end
|
|
102
|
+
* @param {number} curveFactor
|
|
103
|
+
*/
|
|
104
|
+
var addRoundCorner = function (pathData, start, controlA, controlB, end, curveFactor) {
|
|
105
|
+
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);
|
|
106
|
+
};
|
|
107
|
+
/**
|
|
108
|
+
* Construct a new path command for a straight line.
|
|
109
|
+
*
|
|
110
|
+
* @param {SVGPathParams} pathData
|
|
111
|
+
* @param {XYCoords} target
|
|
112
|
+
*/
|
|
113
|
+
var addStraightLine = function (pathData, target) {
|
|
114
|
+
pathData.push("L", target.x, target.y);
|
|
115
|
+
};
|
|
116
|
+
/**
|
|
117
|
+
* A helper function for constructing the next path, beginning at the passed matrix position.
|
|
118
|
+
*
|
|
119
|
+
* Note the path will be created at the left border of the given 'pixel', constructe
|
|
120
|
+
* in clockwise order.
|
|
121
|
+
*
|
|
122
|
+
* @param {SVGPathParams} pathData
|
|
123
|
+
* @param {DataGrid2dArrayMatrix<boolean>} matrix - The data matrix to use.
|
|
124
|
+
* @param {DataGrid2dArrayMatrix<boolean>} visitedLeftBordersMatrix - A helper matrix to keep track of visited pixels.
|
|
125
|
+
* @param {RasterPosition} startingPosition
|
|
126
|
+
* @param {number} startingBorderDirection
|
|
127
|
+
* @param {XYCoords} origin
|
|
128
|
+
* @param {number} squareSize
|
|
129
|
+
* @param {number} gapSize
|
|
130
|
+
* @param {number} curveFactor
|
|
131
|
+
*/
|
|
132
|
+
var __constructPath = function (pathData, matrix, visitedLeftBordersMatrix, startingPosition, startingBorderDirection, origin, squareSize, gapSize, curveFactor) {
|
|
133
|
+
// Pre: position's neighbour pixel at ehe given border direction is unset.
|
|
134
|
+
var isPathComplete = false;
|
|
135
|
+
var maxInterations = matrix.xSegmentCount * matrix.ySegmentCount * 4 + 1;
|
|
136
|
+
var i = 0;
|
|
137
|
+
var position = startingPosition;
|
|
138
|
+
var borderDirection = startingBorderDirection;
|
|
139
|
+
while (!isPathComplete && i++ < maxInterations) {
|
|
140
|
+
var x = position.xIndex;
|
|
141
|
+
var y = position.yIndex;
|
|
142
|
+
// console.log("x", x, "y", y, "borderDirection", borderDirection);
|
|
143
|
+
// Get the pixel's box bounds.
|
|
144
|
+
var squareBox = getSquareBox(origin, squareSize, gapSize, x, y);
|
|
145
|
+
// Find next step when walking 'clockwise'
|
|
146
|
+
if (borderDirection === LEFT_BORDER) {
|
|
147
|
+
// Only track visits on left borders. By this we can detect non-visited holes :)
|
|
148
|
+
visitedLeftBordersMatrix.set(x, y, true);
|
|
149
|
+
// We want to expand the left border
|
|
150
|
+
var west = squareBox.getWestPoint();
|
|
151
|
+
// Pixel in the north?
|
|
152
|
+
if (y - 1 < 0 || matrix.get(x, y - 1) === false) {
|
|
153
|
+
// Northwise pixel is empty
|
|
154
|
+
// -> construct round corner to right
|
|
155
|
+
addRoundCorner(pathData, west, squareBox.getNorthWestPoint(), squareBox.getNorthWestPoint(), squareBox.getNorthPoint(), curveFactor);
|
|
156
|
+
borderDirection = TOP_BORDER;
|
|
157
|
+
// Keep pixel position unchanged
|
|
158
|
+
}
|
|
159
|
+
else if (x - 1 >= 0 && matrix.get(x - 1, y - 1) === true) {
|
|
160
|
+
// Top neighbour pixel is set AND top-left pixel is set too.
|
|
161
|
+
// -> construct rounded edge to top-left.
|
|
162
|
+
var squareBoxNW = getSquareBox(origin, squareSize, gapSize, x - 1, y - 1);
|
|
163
|
+
addRoundCorner(pathData, west, squareBox.getNorthWestPoint(), squareBoxNW.getSouthEastPoint(), squareBoxNW.getSouthPoint(), curveFactor);
|
|
164
|
+
borderDirection = BOTTOM_BORDER;
|
|
165
|
+
position = { xIndex: x - 1, yIndex: y - 1 };
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
// Straight to top
|
|
169
|
+
var squareBoxN = getSquareBox(origin, squareSize, gapSize, x, y - 1);
|
|
170
|
+
addStraightLine(pathData, squareBoxN.getWestPoint());
|
|
171
|
+
position = { xIndex: x, yIndex: y - 1 };
|
|
172
|
+
// Keep borderDirection: LEFT_BORDER
|
|
173
|
+
// isPathComplete = true; // TODO
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
else if (borderDirection === TOP_BORDER) {
|
|
177
|
+
// North pixel is definitely empty.
|
|
178
|
+
var north = squareBox.getNorthPoint();
|
|
179
|
+
if (x + 1 >= matrix.xSegmentCount || matrix.get(x + 1, y) === false) {
|
|
180
|
+
// Top border and right pixel is empty
|
|
181
|
+
// --> create rounded corner to right south
|
|
182
|
+
addRoundCorner(pathData, north, squareBox.getNorthEastPoint(), squareBox.getNorthEastPoint(), squareBox.getEastPoint(), curveFactor);
|
|
183
|
+
borderDirection = RIGHT_BORDER;
|
|
184
|
+
// Keep pixel position unchanged
|
|
185
|
+
}
|
|
186
|
+
else if (y - 1 < 0 || matrix.get(x + 1, y - 1) === false) {
|
|
187
|
+
// Top border and right pixel is set, and north-east pixel is clear.
|
|
188
|
+
// -> linear path to right
|
|
189
|
+
var squareBoxE = getSquareBox(origin, squareSize, gapSize, x + 1, y);
|
|
190
|
+
addStraightLine(pathData, squareBoxE.getNorthPoint());
|
|
191
|
+
position = { xIndex: x + 1, yIndex: y };
|
|
192
|
+
// Keep borderDirection TOP
|
|
193
|
+
}
|
|
194
|
+
else {
|
|
195
|
+
// Last case: right neighbour is set and north-east pixel is set
|
|
196
|
+
//-> construct a rounded corner to east-north.
|
|
197
|
+
var squareBoxNE = getSquareBox(origin, squareSize, gapSize, x + 1, y - 1);
|
|
198
|
+
addRoundCorner(pathData, north, squareBox.getNorthEastPoint(), squareBoxNE.getSouthWestPoint(), squareBoxNE.getWestPoint(), curveFactor);
|
|
199
|
+
borderDirection = LEFT_BORDER;
|
|
200
|
+
position = { xIndex: x + 1, yIndex: y - 1 };
|
|
201
|
+
// isPathComplete = true; // TODO!!!
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
else if (borderDirection === RIGHT_BORDER) {
|
|
205
|
+
// East pixel is definitely empty.
|
|
206
|
+
var east = squareBox.getEastPoint();
|
|
207
|
+
if (y + 1 >= matrix.ySegmentCount || matrix.get(x, y + 1) === false) {
|
|
208
|
+
// South pixel is empty.
|
|
209
|
+
// -> construct rounded corner to south-east
|
|
210
|
+
addRoundCorner(pathData, east, squareBox.getSouthEastPoint(), squareBox.getSouthEastPoint(), squareBox.getSouthPoint(), curveFactor);
|
|
211
|
+
borderDirection = BOTTOM_BORDER;
|
|
212
|
+
// Keep pixel position unchanged
|
|
213
|
+
}
|
|
214
|
+
else if (x + 1 < matrix.xSegmentCount && y + 1 < matrix.ySegmentCount && matrix.get(x + 1, y + 1) === true) {
|
|
215
|
+
// South pixel is set AND right lower pixel is set, too.
|
|
216
|
+
// -> construct round corner to south-east.
|
|
217
|
+
var squareBoxSE = getSquareBox(origin, squareSize, gapSize, x + 1, y + 1);
|
|
218
|
+
addRoundCorner(pathData, east, squareBox.getSouthEastPoint(), squareBoxSE.getNorthWestPoint(), squareBoxSE.getNorthPoint(), curveFactor);
|
|
219
|
+
borderDirection = TOP_BORDER;
|
|
220
|
+
position = { xIndex: x + 1, yIndex: y + 1 };
|
|
221
|
+
}
|
|
222
|
+
else {
|
|
223
|
+
// South pixel is set and south-east pixel is clear.
|
|
224
|
+
// -> construct linear connection to south
|
|
225
|
+
var squareBoxS = getSquareBox(origin, squareSize, gapSize, x, y + 1);
|
|
226
|
+
addStraightLine(pathData, squareBoxS.getEastPoint());
|
|
227
|
+
position = { xIndex: x, yIndex: y + 1 };
|
|
228
|
+
// Keep borderDirection RIGHT
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
else if (borderDirection === BOTTOM_BORDER) {
|
|
232
|
+
// Pre: south pixel is definitely empty
|
|
233
|
+
var south = squareBox.getSouthPoint();
|
|
234
|
+
if (x - 1 < 0 || matrix.get(x - 1, y) === false) {
|
|
235
|
+
// Left pixel is empty
|
|
236
|
+
// -> construct round corner to west-north
|
|
237
|
+
addRoundCorner(pathData, south, squareBox.getSouthWestPoint(), squareBox.getSouthWestPoint(), squareBox.getWestPoint(), curveFactor);
|
|
238
|
+
borderDirection = LEFT_BORDER;
|
|
239
|
+
}
|
|
240
|
+
else if (x - 1 >= 0 && y + 1 < matrix.ySegmentCount && matrix.get(x - 1, y + 1) === true) {
|
|
241
|
+
// Left pixel AND left lower pixel are set
|
|
242
|
+
// -> construct rounded edge to south-west
|
|
243
|
+
var squareBoxSW = getSquareBox(origin, squareSize, gapSize, x - 1, y + 1);
|
|
244
|
+
addRoundCorner(pathData, south, squareBox.getSouthWestPoint(), squareBoxSW.getNorthEastPoint(), squareBoxSW.getEastPoint(), curveFactor);
|
|
245
|
+
borderDirection = RIGHT_BORDER;
|
|
246
|
+
position = { xIndex: x - 1, yIndex: y + 1 };
|
|
247
|
+
}
|
|
248
|
+
else {
|
|
249
|
+
// Left pixel is set AND south pixel is empty
|
|
250
|
+
// -> construct linear edge to left neighbour.
|
|
251
|
+
var squareBoxW = getSquareBox(origin, squareSize, gapSize, x - 1, y);
|
|
252
|
+
addStraightLine(pathData, squareBoxW.getSouthPoint());
|
|
253
|
+
position = { xIndex: x - 1, yIndex: y };
|
|
254
|
+
// Keep borderDirection BOTTOM
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
else {
|
|
258
|
+
console.warn("[Error] Cannot construct full rounded path; 'borderDirection' has wrong value (".concat(borderDirection, ")."));
|
|
259
|
+
isPathComplete = true;
|
|
260
|
+
}
|
|
261
|
+
// End condition reached?
|
|
262
|
+
if (startingPosition.xIndex === position.xIndex &&
|
|
263
|
+
startingPosition.yIndex === position.yIndex &&
|
|
264
|
+
startingBorderDirection === borderDirection) {
|
|
265
|
+
pathData.push("Z");
|
|
266
|
+
isPathComplete = true;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
};
|
|
270
|
+
//# 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,uCAAsC;AAGtC,iFAAgF;AAEhF,IAAM,WAAW,GAAW,CAAC,CAAC;AAC9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ex: 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,155 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* A DataGrid2d implementation on 2 dimensional arrays.
|
|
4
|
+
*
|
|
5
|
+
* @author Ikaros Kappler
|
|
6
|
+
* @date 2025-10-16
|
|
7
|
+
* @modified 2025-10-28 Added `DataGrid2dArrayMatrix.setAll(function)`.
|
|
8
|
+
* @modified 2025-10-28 Fixed a bug in the `DataGrid2dArrayMatrix.toString()` method.
|
|
9
|
+
* @version 1.0.0
|
|
10
|
+
**/
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.DataGrid2dArrayMatrix = void 0;
|
|
13
|
+
var arrayFill_1 = require("../algorithms/arrayFill");
|
|
14
|
+
var DataGrid2dArrayMatrix = /** @class */ (function () {
|
|
15
|
+
/**
|
|
16
|
+
* Create a new DataGrid2d from the given
|
|
17
|
+
* @throws Error if xSegmentCount*ySegmentCount is larger than the capacity of the array/list.
|
|
18
|
+
* @param list
|
|
19
|
+
* @param xSegmentCount
|
|
20
|
+
* @param ySegmentCount
|
|
21
|
+
*/
|
|
22
|
+
function DataGrid2dArrayMatrix(xSegmentCount, ySegmentCount, initialValue) {
|
|
23
|
+
if (xSegmentCount <= 0) {
|
|
24
|
+
throw "Cannot create DataGrid2dArray, xSegmentCount (".concat(xSegmentCount, ") must be > 0.");
|
|
25
|
+
}
|
|
26
|
+
if (ySegmentCount <= 0) {
|
|
27
|
+
throw "Cannot create DataGrid2dArray, ySegmentCount (".concat(ySegmentCount, ") must be > 0.");
|
|
28
|
+
}
|
|
29
|
+
// this.canvas = document.getElementById(canvasId);
|
|
30
|
+
this.xSegmentCount = xSegmentCount;
|
|
31
|
+
this.ySegmentCount = ySegmentCount;
|
|
32
|
+
this._matrix = [];
|
|
33
|
+
for (var i = 0; i < ySegmentCount; i++) {
|
|
34
|
+
this._matrix.push((0, arrayFill_1.arrayFill)(xSegmentCount, initialValue));
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Set the matrix value at the given (x,y) position to a new value.
|
|
39
|
+
*
|
|
40
|
+
* @param {number} xIndex - The horizontal matrix position to set.
|
|
41
|
+
* @param {number} yIndex - The vertical matrix position to set.
|
|
42
|
+
* @param {T} value - The new value.
|
|
43
|
+
*/
|
|
44
|
+
DataGrid2dArrayMatrix.prototype.set = function (xIndex, yIndex, value) {
|
|
45
|
+
this._matrix[yIndex][xIndex] = value;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Getthe matrix value at the given (x,y) position.
|
|
49
|
+
*
|
|
50
|
+
* @param {number} xIndex - The horizontal matrix position to set.
|
|
51
|
+
* @param {number} yIndex - The vertical matrix position to set.
|
|
52
|
+
* @return {T} value - The new value.
|
|
53
|
+
*/
|
|
54
|
+
DataGrid2dArrayMatrix.prototype.get = function (xIndex, yIndex) {
|
|
55
|
+
return this.getDataValueAt(xIndex, yIndex);
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Set all matrix values. The passed factory function must accept respective (x,y) positions.
|
|
59
|
+
*
|
|
60
|
+
* @param {Function} factory - The factory function to determine the new values to set.
|
|
61
|
+
* @return {DataGrid2dArrayMatrix<T>} this - for chaning.
|
|
62
|
+
*/
|
|
63
|
+
DataGrid2dArrayMatrix.prototype.setAll = function (factory) {
|
|
64
|
+
for (var x = 0; x < this.xSegmentCount; x++) {
|
|
65
|
+
for (var y = 0; y < this.ySegmentCount; y++) {
|
|
66
|
+
this.set(x, y, factory(x, y));
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return this;
|
|
70
|
+
};
|
|
71
|
+
DataGrid2dArrayMatrix.prototype.find = function (condition) {
|
|
72
|
+
for (var x = 0; x < this.xSegmentCount; x++) {
|
|
73
|
+
for (var y = 0; y < this.ySegmentCount; y++) {
|
|
74
|
+
if (condition(this.get(x, y), x, y, this)) {
|
|
75
|
+
return {
|
|
76
|
+
xIndex: x,
|
|
77
|
+
yIndex: y,
|
|
78
|
+
xRel: x / this.xSegmentCount,
|
|
79
|
+
yRel: y / this.ySegmentCount
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return null;
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* @override
|
|
88
|
+
*/
|
|
89
|
+
DataGrid2dArrayMatrix.prototype.getMinDataValue = function () {
|
|
90
|
+
return this.minDataValue;
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* @override
|
|
94
|
+
*/
|
|
95
|
+
DataGrid2dArrayMatrix.prototype.getMaxDataValue = function () {
|
|
96
|
+
return this.maxDataValue;
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
99
|
+
* @override
|
|
100
|
+
*/
|
|
101
|
+
DataGrid2dArrayMatrix.prototype.getDataValueAt = function (xIndex, yIndex, isDebug) {
|
|
102
|
+
return this._matrix[yIndex][xIndex];
|
|
103
|
+
};
|
|
104
|
+
/**
|
|
105
|
+
* @override
|
|
106
|
+
*/
|
|
107
|
+
DataGrid2dArrayMatrix.prototype.getDataFace4At = function (xIndex, yIndex, buffer) {
|
|
108
|
+
// buffer: array[2][2]
|
|
109
|
+
buffer[0][0] = this.getDataValueAt(xIndex, yIndex);
|
|
110
|
+
buffer[1][0] = this.getDataValueAt(xIndex + 1, yIndex);
|
|
111
|
+
buffer[1][1] = this.getDataValueAt(xIndex + 1, yIndex + 1);
|
|
112
|
+
buffer[0][1] = this.getDataValueAt(xIndex, yIndex + 1);
|
|
113
|
+
};
|
|
114
|
+
/**
|
|
115
|
+
* A helper method to convert a boolean matrix to a parsable string.
|
|
116
|
+
*
|
|
117
|
+
* @param {DataGrid2dArrayMatrix<boolean>} matrix
|
|
118
|
+
* @returns {string}
|
|
119
|
+
*/
|
|
120
|
+
DataGrid2dArrayMatrix.toString = function (matrix) {
|
|
121
|
+
var buffer = [];
|
|
122
|
+
for (var y = 0; y < matrix.ySegmentCount; y++) {
|
|
123
|
+
for (var x = 0; x < matrix.xSegmentCount; x++) {
|
|
124
|
+
buffer.push(matrix.get(x, y) ? "X" : ".");
|
|
125
|
+
}
|
|
126
|
+
buffer.push("\n");
|
|
127
|
+
}
|
|
128
|
+
return buffer.join("");
|
|
129
|
+
};
|
|
130
|
+
/**
|
|
131
|
+
* Simple way to parse a data matrix from a string. `false` should be coded as '.' character,
|
|
132
|
+
* `true` must be coded as 'X' character.
|
|
133
|
+
*
|
|
134
|
+
* @param {string} str - The input string.
|
|
135
|
+
* @param {number} width - The desired width of the matrix (xSegmentCount).
|
|
136
|
+
* @param {number} height - The desired height of the matrix (ySegmentCount).
|
|
137
|
+
* @returns {DataGrid2dArrayMatrix<boolean>}
|
|
138
|
+
*/
|
|
139
|
+
DataGrid2dArrayMatrix.parseBooleanMatrix = function (str, width, height) {
|
|
140
|
+
var matrix = new DataGrid2dArrayMatrix(width, height, false);
|
|
141
|
+
var lines = str.trim().split("\n");
|
|
142
|
+
for (var y = 0; y < lines.length && y < height; y++) {
|
|
143
|
+
lines[y] = lines[y].trim();
|
|
144
|
+
for (var x = 0; x < lines[y].length && x < width; x++) {
|
|
145
|
+
if (y < height && x < width && lines[y].charAt(x) === "X") {
|
|
146
|
+
matrix.set(x, y, true);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return matrix;
|
|
151
|
+
};
|
|
152
|
+
return DataGrid2dArrayMatrix;
|
|
153
|
+
}());
|
|
154
|
+
exports.DataGrid2dArrayMatrix = DataGrid2dArrayMatrix;
|
|
155
|
+
//# 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,qDAAoD;AAGpD;IAiBE;;;;;;OAMG;IACH,+BAAY,aAAqB,EAAE,aAAqB,EAAE,YAAe;QACvE,IAAI,aAAa,IAAI,CAAC,EAAE,CAAC;YACvB,MAAM,wDAAiD,aAAa,mBAAgB,CAAC;QACvF,CAAC;QACD,IAAI,aAAa,IAAI,CAAC,EAAE,CAAC;YACvB,MAAM,wDAAiD,aAAa,mBAAgB,CAAC;QACvF,CAAC;QAED,mDAAmD;QACnD,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QAEnC,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;QAClB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,aAAa,EAAE,CAAC,EAAE,EAAE,CAAC;YACvC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAA,qBAAS,EAAC,aAAa,EAAE,YAAY,CAAC,CAAC,CAAC;QAC5D,CAAC;IACH,CAAC;IAED;;;;;;OAMG;IACI,mCAAG,GAAV,UAAW,MAAc,EAAE,MAAc,EAAE,KAAQ;QACjD,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC;IACvC,CAAC;IAED;;;;;;OAMG;IACI,mCAAG,GAAV,UAAW,MAAc,EAAE,MAAc;QACvC,OAAO,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7C,CAAC;IAED;;;;;OAKG;IACI,sCAAM,GAAb,UAAc,OAA8C;QAC1D,KAA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AA0B,GAAW,EAAE,KAAa,EAAE,MAAc;QAClE,IAAM,MAAM,GAAG,IAAI,qBAAqB,CAAU,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;QACxE,IAAM,KAAK,GAAa,GAAG,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC/C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,IAAI,CAAC,GAAG,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACpD,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,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;IACH,4BAAC;AAAD,CAAC,AAxKD,IAwKC;AAxKY,sDAAqB"}
|
|
@@ -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
|
|
@@ -57,9 +57,9 @@ var DataGrid2dListAdapter = /** @class */ (function () {
|
|
|
57
57
|
DataGrid2dListAdapter.prototype.getDataValueAt = function (xIndex, yIndex, isDebug) {
|
|
58
58
|
// var bufferIndex = yIndex * this.xSegmentCount + xIndex;
|
|
59
59
|
var bufferIndex = this.coordinateIndicesToBufferIndex(xIndex, yIndex);
|
|
60
|
-
if (isDebug) {
|
|
61
|
-
|
|
62
|
-
}
|
|
60
|
+
// if (isDebug) {
|
|
61
|
+
// console.log("xIndex", xIndex, "yIndex", yIndex, "bufferIndex", bufferIndex);
|
|
62
|
+
// }
|
|
63
63
|
if (bufferIndex > this._dataList.length) {
|
|
64
64
|
console.error("ERR buffer index is out of bounds! xIndex", xIndex, "yIndex", yIndex, "bufferIndex", bufferIndex);
|
|
65
65
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataGrid2dListAdapter.js","sourceRoot":"","sources":["../../../ts/utils/datastructures/DataGrid2dListAdapter.ts"],"names":[],"mappings":";AAAA;;;;;;;IAOI;;;
|
|
1
|
+
{"version":3,"file":"DataGrid2dListAdapter.js","sourceRoot":"","sources":["../../../ts/utils/datastructures/DataGrid2dListAdapter.ts"],"names":[],"mappings":";AAAA;;;;;;;IAOI;;;AAUJ;IAmBE;;;;;;OAMG;IACH,+BAAY,IAAuB,EAAE,aAAqB,EAAE,aAAqB;QAC/E,IAAI,aAAa,GAAG,aAAa,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;YAChD,MAAM,gEAAyD,IAAI,CAAC,MAAM,iDAAuC,aAAa,cAAI,aAAa,uBAAoB,CAAC;QACtK,CAAC;QAED,mDAAmD;QACnD,IA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D 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
|
+
}
|