@rxflow/manhattan 0.0.1-alpha.7 → 0.0.1-alpha.9
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/cjs/getManHattanPath.d.ts.map +1 -1
- package/cjs/getManHattanPath.js +20 -18
- package/cjs/options/defaults.js +1 -1
- package/cjs/utils/grid.d.ts.map +1 -1
- package/cjs/utils/grid.js +3 -17
- package/esm/getManHattanPath.d.ts.map +1 -1
- package/esm/getManHattanPath.js +28 -26
- package/esm/options/defaults.js +1 -1
- package/esm/utils/grid.d.ts.map +1 -1
- package/esm/utils/grid.js +3 -17
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getManHattanPath.d.ts","sourceRoot":"","sources":["../src/getManHattanPath.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,QAAQ,EAAE,MAAM,eAAe,CAAA;AAG3D,OAAO,KAAK,EAAE,sBAAsB,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AAMnE;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC;;OAEG;IACH,YAAY,EAAE,MAAM,CAAA;IAEpB;;OAEG;IACH,YAAY,EAAE,MAAM,CAAC;IAErB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAEhB,cAAc,EAAE,QAAQ,CAAC;IACzB,cAAc,EAAE,QAAQ,CAAC;IACzB;;OAEG;IACH,UAAU,EAAE,UAAU,CAAA;IAEtB;;OAEG;IACH,OAAO,CAAC,EAAE,sBAAsB,CAAA;CACjC;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,sBAAsB,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"getManHattanPath.d.ts","sourceRoot":"","sources":["../src/getManHattanPath.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,QAAQ,EAAE,MAAM,eAAe,CAAA;AAG3D,OAAO,KAAK,EAAE,sBAAsB,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AAMnE;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC;;OAEG;IACH,YAAY,EAAE,MAAM,CAAA;IAEpB;;OAEG;IACH,YAAY,EAAE,MAAM,CAAC;IAErB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAEhB,cAAc,EAAE,QAAQ,CAAC;IACzB,cAAc,EAAE,QAAQ,CAAC;IACzB;;OAEG;IACH,UAAU,EAAE,UAAU,CAAA;IAEtB;;OAEG;IACH,OAAO,CAAC,EAAE,sBAAsB,CAAA;CACjC;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,sBAAsB,GAAG,MAAM,CAwRvE"}
|
package/cjs/getManHattanPath.js
CHANGED
|
@@ -161,7 +161,9 @@ function getManHattanPath(params) {
|
|
|
161
161
|
}
|
|
162
162
|
|
|
163
163
|
// Insert extension point at source - always extend away from node edge by fixed step distance
|
|
164
|
+
// Add borderRadius to extension distance to account for rounded corners
|
|
164
165
|
if (route.length > 0) {
|
|
166
|
+
const extensionDistance = step + options.borderRadius;
|
|
165
167
|
const firstPoint = route[0];
|
|
166
168
|
|
|
167
169
|
// Determine which edge the source anchor is on
|
|
@@ -172,8 +174,8 @@ function getManHattanPath(params) {
|
|
|
172
174
|
|
|
173
175
|
// Insert extension point and corner point to ensure orthogonal path
|
|
174
176
|
if (onRight) {
|
|
175
|
-
// Anchor on right edge - extend right by
|
|
176
|
-
const extendX = sourceAnchor.x +
|
|
177
|
+
// Anchor on right edge - extend right by step + borderRadius
|
|
178
|
+
const extendX = sourceAnchor.x + extensionDistance;
|
|
177
179
|
const extensionPoint = new _geometry.Point(extendX, sourceAnchor.y);
|
|
178
180
|
// Check if we need a corner point
|
|
179
181
|
if (Math.abs(extensionPoint.y - firstPoint.y) > tolerance) {
|
|
@@ -182,8 +184,8 @@ function getManHattanPath(params) {
|
|
|
182
184
|
route.unshift(extensionPoint); // Extension point (fixed distance)
|
|
183
185
|
console.log('[getManHattanPath] Inserted source extension (right):', `(${extendX}, ${sourceAnchor.y})`);
|
|
184
186
|
} else if (onLeft) {
|
|
185
|
-
// Anchor on left edge - extend left by
|
|
186
|
-
const extendX = sourceAnchor.x -
|
|
187
|
+
// Anchor on left edge - extend left by step + borderRadius
|
|
188
|
+
const extendX = sourceAnchor.x - extensionDistance;
|
|
187
189
|
const extensionPoint = new _geometry.Point(extendX, sourceAnchor.y);
|
|
188
190
|
if (Math.abs(extensionPoint.y - firstPoint.y) > tolerance) {
|
|
189
191
|
route.unshift(new _geometry.Point(extendX, firstPoint.y));
|
|
@@ -191,8 +193,8 @@ function getManHattanPath(params) {
|
|
|
191
193
|
route.unshift(extensionPoint);
|
|
192
194
|
console.log('[getManHattanPath] Inserted source extension (left):', `(${extendX}, ${sourceAnchor.y})`);
|
|
193
195
|
} else if (onBottom) {
|
|
194
|
-
// Anchor on bottom edge - extend down by
|
|
195
|
-
const extendY = sourceAnchor.y +
|
|
196
|
+
// Anchor on bottom edge - extend down by step + borderRadius
|
|
197
|
+
const extendY = sourceAnchor.y + extensionDistance;
|
|
196
198
|
const extensionPoint = new _geometry.Point(sourceAnchor.x, extendY);
|
|
197
199
|
if (Math.abs(extensionPoint.x - firstPoint.x) > tolerance) {
|
|
198
200
|
route.unshift(new _geometry.Point(firstPoint.x, extendY));
|
|
@@ -200,8 +202,8 @@ function getManHattanPath(params) {
|
|
|
200
202
|
route.unshift(extensionPoint);
|
|
201
203
|
console.log('[getManHattanPath] Inserted source extension (down):', `(${sourceAnchor.x}, ${extendY})`);
|
|
202
204
|
} else if (onTop) {
|
|
203
|
-
// Anchor on top edge - extend up by
|
|
204
|
-
const extendY = sourceAnchor.y -
|
|
205
|
+
// Anchor on top edge - extend up by step + borderRadius
|
|
206
|
+
const extendY = sourceAnchor.y - extensionDistance;
|
|
205
207
|
const extensionPoint = new _geometry.Point(sourceAnchor.x, extendY);
|
|
206
208
|
if (Math.abs(extensionPoint.x - firstPoint.x) > tolerance) {
|
|
207
209
|
route.unshift(new _geometry.Point(firstPoint.x, extendY));
|
|
@@ -212,9 +214,9 @@ function getManHattanPath(params) {
|
|
|
212
214
|
}
|
|
213
215
|
|
|
214
216
|
// Insert extension point at target - always extend away from node edge by fixed step distance
|
|
217
|
+
// Add borderRadius to extension distance to account for rounded corners
|
|
215
218
|
if (route.length > 0) {
|
|
216
|
-
const
|
|
217
|
-
const tolerance = 1;
|
|
219
|
+
const extensionDistance = step + options.borderRadius;
|
|
218
220
|
const lastPoint = route[route.length - 1];
|
|
219
221
|
|
|
220
222
|
// Determine which edge the target anchor is on
|
|
@@ -225,8 +227,8 @@ function getManHattanPath(params) {
|
|
|
225
227
|
|
|
226
228
|
// Insert extension point and corner point to ensure orthogonal path
|
|
227
229
|
if (onLeft) {
|
|
228
|
-
// Anchor on left edge - extend left by
|
|
229
|
-
const extendX = targetAnchor.x -
|
|
230
|
+
// Anchor on left edge - extend left by step + borderRadius
|
|
231
|
+
const extendX = targetAnchor.x - extensionDistance;
|
|
230
232
|
const extensionPoint = new _geometry.Point(extendX, targetAnchor.y);
|
|
231
233
|
if (Math.abs(extensionPoint.y - lastPoint.y) > tolerance) {
|
|
232
234
|
route.push(new _geometry.Point(extendX, lastPoint.y)); // Corner point
|
|
@@ -234,8 +236,8 @@ function getManHattanPath(params) {
|
|
|
234
236
|
route.push(extensionPoint); // Extension point (fixed distance)
|
|
235
237
|
console.log('[getManHattanPath] Inserted target extension (left):', `(${extendX}, ${targetAnchor.y})`);
|
|
236
238
|
} else if (onRight) {
|
|
237
|
-
// Anchor on right edge - extend right by
|
|
238
|
-
const extendX = targetAnchor.x +
|
|
239
|
+
// Anchor on right edge - extend right by step + borderRadius
|
|
240
|
+
const extendX = targetAnchor.x + extensionDistance;
|
|
239
241
|
const extensionPoint = new _geometry.Point(extendX, targetAnchor.y);
|
|
240
242
|
if (Math.abs(extensionPoint.y - lastPoint.y) > tolerance) {
|
|
241
243
|
route.push(new _geometry.Point(extendX, lastPoint.y));
|
|
@@ -243,8 +245,8 @@ function getManHattanPath(params) {
|
|
|
243
245
|
route.push(extensionPoint);
|
|
244
246
|
console.log('[getManHattanPath] Inserted target extension (right):', `(${extendX}, ${targetAnchor.y})`);
|
|
245
247
|
} else if (onTop) {
|
|
246
|
-
// Anchor on top edge - extend up by
|
|
247
|
-
const extendY = targetAnchor.y -
|
|
248
|
+
// Anchor on top edge - extend up by step + borderRadius
|
|
249
|
+
const extendY = targetAnchor.y - extensionDistance;
|
|
248
250
|
const extensionPoint = new _geometry.Point(targetAnchor.x, extendY);
|
|
249
251
|
if (Math.abs(extensionPoint.x - lastPoint.x) > tolerance) {
|
|
250
252
|
route.push(new _geometry.Point(lastPoint.x, extendY));
|
|
@@ -252,8 +254,8 @@ function getManHattanPath(params) {
|
|
|
252
254
|
route.push(extensionPoint);
|
|
253
255
|
console.log('[getManHattanPath] Inserted target extension (up):', `(${targetAnchor.x}, ${extendY})`);
|
|
254
256
|
} else if (onBottom) {
|
|
255
|
-
// Anchor on bottom edge - extend down by
|
|
256
|
-
const extendY = targetAnchor.y +
|
|
257
|
+
// Anchor on bottom edge - extend down by step + borderRadius
|
|
258
|
+
const extendY = targetAnchor.y + extensionDistance;
|
|
257
259
|
const extensionPoint = new _geometry.Point(targetAnchor.x, extendY);
|
|
258
260
|
if (Math.abs(extensionPoint.x - lastPoint.x) > tolerance) {
|
|
259
261
|
route.push(new _geometry.Point(lastPoint.x, extendY));
|
package/cjs/options/defaults.js
CHANGED
package/cjs/utils/grid.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grid.d.ts","sourceRoot":"","sources":["../../src/utils/grid.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAEnC;;GAEG;AACH,MAAM,WAAW,IAAI;IACnB,MAAM,EAAE,KAAK,CAAA;IACb,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;CACV;
|
|
1
|
+
{"version":3,"file":"grid.d.ts","sourceRoot":"","sources":["../../src/utils/grid.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAEnC;;GAEG;AACH,MAAM,WAAW,IAAI;IACnB,MAAM,EAAE,KAAK,CAAA;IACb,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;CACV;AAWD;;GAEG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,GAAG,IAAI,CAMxE;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAElE;AAYD;;GAEG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,GAAG,KAAK,CAExE;AAED;;GAEG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,GAAG,KAAK,CAE5D"}
|
package/cjs/utils/grid.js
CHANGED
|
@@ -16,23 +16,9 @@ var _geometry = require("../geometry");
|
|
|
16
16
|
* Get grid dimension for a single axis
|
|
17
17
|
*/
|
|
18
18
|
function getGridDimension(diff, step) {
|
|
19
|
-
//
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
const abs = Math.abs(diff);
|
|
24
|
-
const count = Math.round(abs / step);
|
|
25
|
-
|
|
26
|
-
// Return abs if less than one step apart
|
|
27
|
-
if (!count) {
|
|
28
|
-
return abs;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// Otherwise, return corrected step
|
|
32
|
-
const roundedDiff = count * step;
|
|
33
|
-
const remainder = abs - roundedDiff;
|
|
34
|
-
const correction = remainder / count;
|
|
35
|
-
return step + correction;
|
|
19
|
+
// Always return fixed step size to maintain consistent padding
|
|
20
|
+
// This ensures paths stay at least 'padding' distance from obstacles
|
|
21
|
+
return step;
|
|
36
22
|
}
|
|
37
23
|
|
|
38
24
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getManHattanPath.d.ts","sourceRoot":"","sources":["../src/getManHattanPath.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,QAAQ,EAAE,MAAM,eAAe,CAAA;AAG3D,OAAO,KAAK,EAAE,sBAAsB,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AAMnE;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC;;OAEG;IACH,YAAY,EAAE,MAAM,CAAA;IAEpB;;OAEG;IACH,YAAY,EAAE,MAAM,CAAC;IAErB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAEhB,cAAc,EAAE,QAAQ,CAAC;IACzB,cAAc,EAAE,QAAQ,CAAC;IACzB;;OAEG;IACH,UAAU,EAAE,UAAU,CAAA;IAEtB;;OAEG;IACH,OAAO,CAAC,EAAE,sBAAsB,CAAA;CACjC;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,sBAAsB,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"getManHattanPath.d.ts","sourceRoot":"","sources":["../src/getManHattanPath.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,QAAQ,EAAE,MAAM,eAAe,CAAA;AAG3D,OAAO,KAAK,EAAE,sBAAsB,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AAMnE;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC;;OAEG;IACH,YAAY,EAAE,MAAM,CAAA;IAEpB;;OAEG;IACH,YAAY,EAAE,MAAM,CAAC;IAErB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAEhB,cAAc,EAAE,QAAQ,CAAC;IACzB,cAAc,EAAE,QAAQ,CAAC;IACzB;;OAEG;IACH,UAAU,EAAE,UAAU,CAAA;IAEtB;;OAEG;IACH,OAAO,CAAC,EAAE,sBAAsB,CAAA;CACjC;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,sBAAsB,GAAG,MAAM,CAwRvE"}
|
package/esm/getManHattanPath.js
CHANGED
|
@@ -169,7 +169,9 @@ export function getManHattanPath(params) {
|
|
|
169
169
|
}
|
|
170
170
|
|
|
171
171
|
// Insert extension point at source - always extend away from node edge by fixed step distance
|
|
172
|
+
// Add borderRadius to extension distance to account for rounded corners
|
|
172
173
|
if (route.length > 0) {
|
|
174
|
+
var extensionDistance = step + options.borderRadius;
|
|
173
175
|
var _firstPoint = route[0];
|
|
174
176
|
|
|
175
177
|
// Determine which edge the source anchor is on
|
|
@@ -180,8 +182,8 @@ export function getManHattanPath(params) {
|
|
|
180
182
|
|
|
181
183
|
// Insert extension point and corner point to ensure orthogonal path
|
|
182
184
|
if (_onRight2) {
|
|
183
|
-
// Anchor on right edge - extend right by
|
|
184
|
-
var extendX = sourceAnchor.x +
|
|
185
|
+
// Anchor on right edge - extend right by step + borderRadius
|
|
186
|
+
var extendX = sourceAnchor.x + extensionDistance;
|
|
185
187
|
var extensionPoint = new Point(extendX, sourceAnchor.y);
|
|
186
188
|
// Check if we need a corner point
|
|
187
189
|
if (Math.abs(extensionPoint.y - _firstPoint.y) > tolerance) {
|
|
@@ -190,8 +192,8 @@ export function getManHattanPath(params) {
|
|
|
190
192
|
route.unshift(extensionPoint); // Extension point (fixed distance)
|
|
191
193
|
console.log('[getManHattanPath] Inserted source extension (right):', "(".concat(extendX, ", ").concat(sourceAnchor.y, ")"));
|
|
192
194
|
} else if (_onLeft2) {
|
|
193
|
-
// Anchor on left edge - extend left by
|
|
194
|
-
var _extendX = sourceAnchor.x -
|
|
195
|
+
// Anchor on left edge - extend left by step + borderRadius
|
|
196
|
+
var _extendX = sourceAnchor.x - extensionDistance;
|
|
195
197
|
var _extensionPoint = new Point(_extendX, sourceAnchor.y);
|
|
196
198
|
if (Math.abs(_extensionPoint.y - _firstPoint.y) > tolerance) {
|
|
197
199
|
route.unshift(new Point(_extendX, _firstPoint.y));
|
|
@@ -199,8 +201,8 @@ export function getManHattanPath(params) {
|
|
|
199
201
|
route.unshift(_extensionPoint);
|
|
200
202
|
console.log('[getManHattanPath] Inserted source extension (left):', "(".concat(_extendX, ", ").concat(sourceAnchor.y, ")"));
|
|
201
203
|
} else if (_onBottom2) {
|
|
202
|
-
// Anchor on bottom edge - extend down by
|
|
203
|
-
var extendY = sourceAnchor.y +
|
|
204
|
+
// Anchor on bottom edge - extend down by step + borderRadius
|
|
205
|
+
var extendY = sourceAnchor.y + extensionDistance;
|
|
204
206
|
var _extensionPoint2 = new Point(sourceAnchor.x, extendY);
|
|
205
207
|
if (Math.abs(_extensionPoint2.x - _firstPoint.x) > tolerance) {
|
|
206
208
|
route.unshift(new Point(_firstPoint.x, extendY));
|
|
@@ -208,8 +210,8 @@ export function getManHattanPath(params) {
|
|
|
208
210
|
route.unshift(_extensionPoint2);
|
|
209
211
|
console.log('[getManHattanPath] Inserted source extension (down):', "(".concat(sourceAnchor.x, ", ").concat(extendY, ")"));
|
|
210
212
|
} else if (_onTop2) {
|
|
211
|
-
// Anchor on top edge - extend up by
|
|
212
|
-
var _extendY = sourceAnchor.y -
|
|
213
|
+
// Anchor on top edge - extend up by step + borderRadius
|
|
214
|
+
var _extendY = sourceAnchor.y - extensionDistance;
|
|
213
215
|
var _extensionPoint3 = new Point(sourceAnchor.x, _extendY);
|
|
214
216
|
if (Math.abs(_extensionPoint3.x - _firstPoint.x) > tolerance) {
|
|
215
217
|
route.unshift(new Point(_firstPoint.x, _extendY));
|
|
@@ -220,50 +222,50 @@ export function getManHattanPath(params) {
|
|
|
220
222
|
}
|
|
221
223
|
|
|
222
224
|
// Insert extension point at target - always extend away from node edge by fixed step distance
|
|
225
|
+
// Add borderRadius to extension distance to account for rounded corners
|
|
223
226
|
if (route.length > 0) {
|
|
224
|
-
var
|
|
225
|
-
var _tolerance = 1;
|
|
227
|
+
var _extensionDistance = step + options.borderRadius;
|
|
226
228
|
var _lastPoint = route[route.length - 1];
|
|
227
229
|
|
|
228
230
|
// Determine which edge the target anchor is on
|
|
229
|
-
var _onLeft3 = Math.abs(targetAnchor.x - targetBBox.x) <
|
|
230
|
-
var _onRight3 = Math.abs(targetAnchor.x - (targetBBox.x + targetBBox.width)) <
|
|
231
|
-
var _onTop3 = Math.abs(targetAnchor.y - targetBBox.y) <
|
|
232
|
-
var _onBottom3 = Math.abs(targetAnchor.y - (targetBBox.y + targetBBox.height)) <
|
|
231
|
+
var _onLeft3 = Math.abs(targetAnchor.x - targetBBox.x) < tolerance;
|
|
232
|
+
var _onRight3 = Math.abs(targetAnchor.x - (targetBBox.x + targetBBox.width)) < tolerance;
|
|
233
|
+
var _onTop3 = Math.abs(targetAnchor.y - targetBBox.y) < tolerance;
|
|
234
|
+
var _onBottom3 = Math.abs(targetAnchor.y - (targetBBox.y + targetBBox.height)) < tolerance;
|
|
233
235
|
|
|
234
236
|
// Insert extension point and corner point to ensure orthogonal path
|
|
235
237
|
if (_onLeft3) {
|
|
236
|
-
// Anchor on left edge - extend left by
|
|
237
|
-
var _extendX2 = targetAnchor.x -
|
|
238
|
+
// Anchor on left edge - extend left by step + borderRadius
|
|
239
|
+
var _extendX2 = targetAnchor.x - _extensionDistance;
|
|
238
240
|
var _extensionPoint4 = new Point(_extendX2, targetAnchor.y);
|
|
239
|
-
if (Math.abs(_extensionPoint4.y - _lastPoint.y) >
|
|
241
|
+
if (Math.abs(_extensionPoint4.y - _lastPoint.y) > tolerance) {
|
|
240
242
|
route.push(new Point(_extendX2, _lastPoint.y)); // Corner point
|
|
241
243
|
}
|
|
242
244
|
route.push(_extensionPoint4); // Extension point (fixed distance)
|
|
243
245
|
console.log('[getManHattanPath] Inserted target extension (left):', "(".concat(_extendX2, ", ").concat(targetAnchor.y, ")"));
|
|
244
246
|
} else if (_onRight3) {
|
|
245
|
-
// Anchor on right edge - extend right by
|
|
246
|
-
var _extendX3 = targetAnchor.x +
|
|
247
|
+
// Anchor on right edge - extend right by step + borderRadius
|
|
248
|
+
var _extendX3 = targetAnchor.x + _extensionDistance;
|
|
247
249
|
var _extensionPoint5 = new Point(_extendX3, targetAnchor.y);
|
|
248
|
-
if (Math.abs(_extensionPoint5.y - _lastPoint.y) >
|
|
250
|
+
if (Math.abs(_extensionPoint5.y - _lastPoint.y) > tolerance) {
|
|
249
251
|
route.push(new Point(_extendX3, _lastPoint.y));
|
|
250
252
|
}
|
|
251
253
|
route.push(_extensionPoint5);
|
|
252
254
|
console.log('[getManHattanPath] Inserted target extension (right):', "(".concat(_extendX3, ", ").concat(targetAnchor.y, ")"));
|
|
253
255
|
} else if (_onTop3) {
|
|
254
|
-
// Anchor on top edge - extend up by
|
|
255
|
-
var _extendY2 = targetAnchor.y -
|
|
256
|
+
// Anchor on top edge - extend up by step + borderRadius
|
|
257
|
+
var _extendY2 = targetAnchor.y - _extensionDistance;
|
|
256
258
|
var _extensionPoint6 = new Point(targetAnchor.x, _extendY2);
|
|
257
|
-
if (Math.abs(_extensionPoint6.x - _lastPoint.x) >
|
|
259
|
+
if (Math.abs(_extensionPoint6.x - _lastPoint.x) > tolerance) {
|
|
258
260
|
route.push(new Point(_lastPoint.x, _extendY2));
|
|
259
261
|
}
|
|
260
262
|
route.push(_extensionPoint6);
|
|
261
263
|
console.log('[getManHattanPath] Inserted target extension (up):', "(".concat(targetAnchor.x, ", ").concat(_extendY2, ")"));
|
|
262
264
|
} else if (_onBottom3) {
|
|
263
|
-
// Anchor on bottom edge - extend down by
|
|
264
|
-
var _extendY3 = targetAnchor.y +
|
|
265
|
+
// Anchor on bottom edge - extend down by step + borderRadius
|
|
266
|
+
var _extendY3 = targetAnchor.y + _extensionDistance;
|
|
265
267
|
var _extensionPoint7 = new Point(targetAnchor.x, _extendY3);
|
|
266
|
-
if (Math.abs(_extensionPoint7.x - _lastPoint.x) >
|
|
268
|
+
if (Math.abs(_extensionPoint7.x - _lastPoint.x) > tolerance) {
|
|
267
269
|
route.push(new Point(_lastPoint.x, _extendY3));
|
|
268
270
|
}
|
|
269
271
|
route.push(_extensionPoint7);
|
package/esm/options/defaults.js
CHANGED
package/esm/utils/grid.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grid.d.ts","sourceRoot":"","sources":["../../src/utils/grid.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAEnC;;GAEG;AACH,MAAM,WAAW,IAAI;IACnB,MAAM,EAAE,KAAK,CAAA;IACb,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;CACV;
|
|
1
|
+
{"version":3,"file":"grid.d.ts","sourceRoot":"","sources":["../../src/utils/grid.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAEnC;;GAEG;AACH,MAAM,WAAW,IAAI;IACnB,MAAM,EAAE,KAAK,CAAA;IACb,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;CACV;AAWD;;GAEG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,GAAG,IAAI,CAMxE;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAElE;AAYD;;GAEG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,GAAG,KAAK,CAExE;AAED;;GAEG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,GAAG,KAAK,CAE5D"}
|
package/esm/utils/grid.js
CHANGED
|
@@ -8,23 +8,9 @@ import { Point } from "../geometry";
|
|
|
8
8
|
* Get grid dimension for a single axis
|
|
9
9
|
*/
|
|
10
10
|
function getGridDimension(diff, step) {
|
|
11
|
-
//
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
var abs = Math.abs(diff);
|
|
16
|
-
var count = Math.round(abs / step);
|
|
17
|
-
|
|
18
|
-
// Return abs if less than one step apart
|
|
19
|
-
if (!count) {
|
|
20
|
-
return abs;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
// Otherwise, return corrected step
|
|
24
|
-
var roundedDiff = count * step;
|
|
25
|
-
var remainder = abs - roundedDiff;
|
|
26
|
-
var correction = remainder / count;
|
|
27
|
-
return step + correction;
|
|
11
|
+
// Always return fixed step size to maintain consistent padding
|
|
12
|
+
// This ensures paths stay at least 'padding' distance from obstacles
|
|
13
|
+
return step;
|
|
28
14
|
}
|
|
29
15
|
|
|
30
16
|
/**
|