microboard-temp 0.5.73 → 0.5.75

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.
@@ -36767,17 +36767,62 @@ function createGrid(start, end, toVisitPoints = []) {
36767
36767
  };
36768
36768
  const horizontalLines = [];
36769
36769
  const verticalLines = [];
36770
+ if (start.pointType !== "Board") {
36771
+ const itemMbr = start.item.getMbr();
36772
+ verticalLines.push(itemMbr.left - ITEM_OFFSET, itemMbr.left, itemMbr.right, itemMbr.right + ITEM_OFFSET);
36773
+ horizontalLines.push(itemMbr.top - ITEM_OFFSET, itemMbr.top, itemMbr.bottom, itemMbr.bottom + ITEM_OFFSET);
36774
+ }
36775
+ if (end.pointType !== "Board") {
36776
+ const itemMbr = end.item.getMbr();
36777
+ verticalLines.push(itemMbr.left - ITEM_OFFSET, itemMbr.left, itemMbr.right, itemMbr.right + ITEM_OFFSET);
36778
+ horizontalLines.push(itemMbr.top - ITEM_OFFSET, itemMbr.top, itemMbr.bottom, itemMbr.bottom + ITEM_OFFSET);
36779
+ }
36780
+ const tempStart = start;
36781
+ const tempEnd = end;
36782
+ const middle = new Point((tempStart.x + tempEnd.x) / 2, (tempStart.y + tempEnd.y) / 2);
36783
+ horizontalLines.push(middle.y, tempStart.y, tempEnd.y);
36784
+ verticalLines.push(middle.x, tempStart.x, tempEnd.x);
36785
+ toVisitPoints.forEach((p3) => {
36786
+ horizontalLines.push(p3.y);
36787
+ verticalLines.push(p3.x);
36788
+ });
36789
+ const uniqueHorizontalLines = Array.from(new Set(horizontalLines)).sort((a2, b) => a2 - b);
36790
+ const uniqueVerticalLines = Array.from(new Set(verticalLines)).sort((a2, b) => a2 - b);
36770
36791
  let newStart;
36771
36792
  let newEnd;
36772
36793
  const processPoint = (point5, dir2) => {
36773
36794
  const itemMbr = point5.item.getMbr();
36774
- const mbrFloored = new Mbr(Math.floor(itemMbr.left), Math.floor(itemMbr.top), Math.floor(itemMbr.right), Math.floor(itemMbr.bottom));
36775
- const pointOnMbr = mbrFloored.getLines()[revertMapDir[dir2]].getNearestPointOnLineSegment(point5);
36795
+ const pointOnMbr = itemMbr.getLines()[revertMapDir[dir2]].getNearestPointOnLineSegment(point5);
36776
36796
  const newPoint = Object.create(Object.getPrototypeOf(point5), Object.getOwnPropertyDescriptors(point5));
36777
- newPoint.x = pointOnMbr.x + offsetMap[dir2].x;
36778
- newPoint.y = pointOnMbr.y + offsetMap[dir2].y;
36779
- verticalLines.push(mbrFloored.left - ITEM_OFFSET, mbrFloored.left, pointOnMbr.x, mbrFloored.right, mbrFloored.right + ITEM_OFFSET);
36780
- horizontalLines.push(mbrFloored.top - ITEM_OFFSET, mbrFloored.top, pointOnMbr.y, mbrFloored.bottom, mbrFloored.bottom + ITEM_OFFSET);
36797
+ if (dir2 === "top") {
36798
+ const currentYIndex = uniqueHorizontalLines.findIndex((y) => Math.abs(y - pointOnMbr.y) < 0.01);
36799
+ const nextYIndex = currentYIndex - 1;
36800
+ if (nextYIndex >= 0) {
36801
+ newPoint.y = uniqueHorizontalLines[nextYIndex];
36802
+ newPoint.x = pointOnMbr.x;
36803
+ }
36804
+ } else if (dir2 === "bottom") {
36805
+ const currentYIndex = uniqueHorizontalLines.findIndex((y) => Math.abs(y - pointOnMbr.y) < 0.01);
36806
+ const nextYIndex = currentYIndex + 1;
36807
+ if (nextYIndex < uniqueHorizontalLines.length) {
36808
+ newPoint.y = uniqueHorizontalLines[nextYIndex];
36809
+ newPoint.x = pointOnMbr.x;
36810
+ }
36811
+ } else if (dir2 === "left") {
36812
+ const currentXIndex = uniqueVerticalLines.findIndex((x) => Math.abs(x - pointOnMbr.x) < 0.01);
36813
+ const nextXIndex = currentXIndex - 1;
36814
+ if (nextXIndex >= 0) {
36815
+ newPoint.x = uniqueVerticalLines[nextXIndex];
36816
+ newPoint.y = pointOnMbr.y;
36817
+ }
36818
+ } else if (dir2 === "right") {
36819
+ const currentXIndex = uniqueVerticalLines.findIndex((x) => Math.abs(x - pointOnMbr.x) < 0.01);
36820
+ const nextXIndex = currentXIndex + 1;
36821
+ if (nextXIndex < uniqueVerticalLines.length) {
36822
+ newPoint.x = uniqueVerticalLines[nextXIndex];
36823
+ newPoint.y = pointOnMbr.y;
36824
+ }
36825
+ }
36781
36826
  return newPoint;
36782
36827
  };
36783
36828
  if (start.pointType !== "Board" && startDir) {
@@ -36786,17 +36831,6 @@ function createGrid(start, end, toVisitPoints = []) {
36786
36831
  if (end.pointType !== "Board" && endDir) {
36787
36832
  newEnd = processPoint(end, endDir);
36788
36833
  }
36789
- const finalStart = newStart || start;
36790
- const finalEnd = newEnd || end;
36791
- const middle = new Point((finalStart.x + finalEnd.x) / 2, (finalStart.y + finalEnd.y) / 2);
36792
- horizontalLines.push(middle.y, finalStart.y, finalEnd.y);
36793
- verticalLines.push(middle.x, finalStart.x, finalEnd.x);
36794
- toVisitPoints.forEach((p3) => {
36795
- horizontalLines.push(p3.y);
36796
- verticalLines.push(p3.x);
36797
- });
36798
- const uniqueHorizontalLines = Array.from(new Set(horizontalLines)).sort((a2, b) => a2 - b);
36799
- const uniqueVerticalLines = Array.from(new Set(verticalLines)).sort((a2, b) => a2 - b);
36800
36834
  const grid = uniqueVerticalLines.map((x) => uniqueHorizontalLines.map((y) => new Point(x, y)));
36801
36835
  return {
36802
36836
  grid,
package/dist/cjs/index.js CHANGED
@@ -36767,17 +36767,62 @@ function createGrid(start, end, toVisitPoints = []) {
36767
36767
  };
36768
36768
  const horizontalLines = [];
36769
36769
  const verticalLines = [];
36770
+ if (start.pointType !== "Board") {
36771
+ const itemMbr = start.item.getMbr();
36772
+ verticalLines.push(itemMbr.left - ITEM_OFFSET, itemMbr.left, itemMbr.right, itemMbr.right + ITEM_OFFSET);
36773
+ horizontalLines.push(itemMbr.top - ITEM_OFFSET, itemMbr.top, itemMbr.bottom, itemMbr.bottom + ITEM_OFFSET);
36774
+ }
36775
+ if (end.pointType !== "Board") {
36776
+ const itemMbr = end.item.getMbr();
36777
+ verticalLines.push(itemMbr.left - ITEM_OFFSET, itemMbr.left, itemMbr.right, itemMbr.right + ITEM_OFFSET);
36778
+ horizontalLines.push(itemMbr.top - ITEM_OFFSET, itemMbr.top, itemMbr.bottom, itemMbr.bottom + ITEM_OFFSET);
36779
+ }
36780
+ const tempStart = start;
36781
+ const tempEnd = end;
36782
+ const middle = new Point((tempStart.x + tempEnd.x) / 2, (tempStart.y + tempEnd.y) / 2);
36783
+ horizontalLines.push(middle.y, tempStart.y, tempEnd.y);
36784
+ verticalLines.push(middle.x, tempStart.x, tempEnd.x);
36785
+ toVisitPoints.forEach((p3) => {
36786
+ horizontalLines.push(p3.y);
36787
+ verticalLines.push(p3.x);
36788
+ });
36789
+ const uniqueHorizontalLines = Array.from(new Set(horizontalLines)).sort((a2, b) => a2 - b);
36790
+ const uniqueVerticalLines = Array.from(new Set(verticalLines)).sort((a2, b) => a2 - b);
36770
36791
  let newStart;
36771
36792
  let newEnd;
36772
36793
  const processPoint = (point5, dir2) => {
36773
36794
  const itemMbr = point5.item.getMbr();
36774
- const mbrFloored = new Mbr(Math.floor(itemMbr.left), Math.floor(itemMbr.top), Math.floor(itemMbr.right), Math.floor(itemMbr.bottom));
36775
- const pointOnMbr = mbrFloored.getLines()[revertMapDir[dir2]].getNearestPointOnLineSegment(point5);
36795
+ const pointOnMbr = itemMbr.getLines()[revertMapDir[dir2]].getNearestPointOnLineSegment(point5);
36776
36796
  const newPoint = Object.create(Object.getPrototypeOf(point5), Object.getOwnPropertyDescriptors(point5));
36777
- newPoint.x = pointOnMbr.x + offsetMap[dir2].x;
36778
- newPoint.y = pointOnMbr.y + offsetMap[dir2].y;
36779
- verticalLines.push(mbrFloored.left - ITEM_OFFSET, mbrFloored.left, pointOnMbr.x, mbrFloored.right, mbrFloored.right + ITEM_OFFSET);
36780
- horizontalLines.push(mbrFloored.top - ITEM_OFFSET, mbrFloored.top, pointOnMbr.y, mbrFloored.bottom, mbrFloored.bottom + ITEM_OFFSET);
36797
+ if (dir2 === "top") {
36798
+ const currentYIndex = uniqueHorizontalLines.findIndex((y) => Math.abs(y - pointOnMbr.y) < 0.01);
36799
+ const nextYIndex = currentYIndex - 1;
36800
+ if (nextYIndex >= 0) {
36801
+ newPoint.y = uniqueHorizontalLines[nextYIndex];
36802
+ newPoint.x = pointOnMbr.x;
36803
+ }
36804
+ } else if (dir2 === "bottom") {
36805
+ const currentYIndex = uniqueHorizontalLines.findIndex((y) => Math.abs(y - pointOnMbr.y) < 0.01);
36806
+ const nextYIndex = currentYIndex + 1;
36807
+ if (nextYIndex < uniqueHorizontalLines.length) {
36808
+ newPoint.y = uniqueHorizontalLines[nextYIndex];
36809
+ newPoint.x = pointOnMbr.x;
36810
+ }
36811
+ } else if (dir2 === "left") {
36812
+ const currentXIndex = uniqueVerticalLines.findIndex((x) => Math.abs(x - pointOnMbr.x) < 0.01);
36813
+ const nextXIndex = currentXIndex - 1;
36814
+ if (nextXIndex >= 0) {
36815
+ newPoint.x = uniqueVerticalLines[nextXIndex];
36816
+ newPoint.y = pointOnMbr.y;
36817
+ }
36818
+ } else if (dir2 === "right") {
36819
+ const currentXIndex = uniqueVerticalLines.findIndex((x) => Math.abs(x - pointOnMbr.x) < 0.01);
36820
+ const nextXIndex = currentXIndex + 1;
36821
+ if (nextXIndex < uniqueVerticalLines.length) {
36822
+ newPoint.x = uniqueVerticalLines[nextXIndex];
36823
+ newPoint.y = pointOnMbr.y;
36824
+ }
36825
+ }
36781
36826
  return newPoint;
36782
36827
  };
36783
36828
  if (start.pointType !== "Board" && startDir) {
@@ -36786,17 +36831,6 @@ function createGrid(start, end, toVisitPoints = []) {
36786
36831
  if (end.pointType !== "Board" && endDir) {
36787
36832
  newEnd = processPoint(end, endDir);
36788
36833
  }
36789
- const finalStart = newStart || start;
36790
- const finalEnd = newEnd || end;
36791
- const middle = new Point((finalStart.x + finalEnd.x) / 2, (finalStart.y + finalEnd.y) / 2);
36792
- horizontalLines.push(middle.y, finalStart.y, finalEnd.y);
36793
- verticalLines.push(middle.x, finalStart.x, finalEnd.x);
36794
- toVisitPoints.forEach((p3) => {
36795
- horizontalLines.push(p3.y);
36796
- verticalLines.push(p3.x);
36797
- });
36798
- const uniqueHorizontalLines = Array.from(new Set(horizontalLines)).sort((a2, b) => a2 - b);
36799
- const uniqueVerticalLines = Array.from(new Set(verticalLines)).sort((a2, b) => a2 - b);
36800
36834
  const grid = uniqueVerticalLines.map((x) => uniqueHorizontalLines.map((y) => new Point(x, y)));
36801
36835
  return {
36802
36836
  grid,
package/dist/cjs/node.js CHANGED
@@ -39240,17 +39240,62 @@ function createGrid(start, end, toVisitPoints = []) {
39240
39240
  };
39241
39241
  const horizontalLines = [];
39242
39242
  const verticalLines = [];
39243
+ if (start.pointType !== "Board") {
39244
+ const itemMbr = start.item.getMbr();
39245
+ verticalLines.push(itemMbr.left - ITEM_OFFSET, itemMbr.left, itemMbr.right, itemMbr.right + ITEM_OFFSET);
39246
+ horizontalLines.push(itemMbr.top - ITEM_OFFSET, itemMbr.top, itemMbr.bottom, itemMbr.bottom + ITEM_OFFSET);
39247
+ }
39248
+ if (end.pointType !== "Board") {
39249
+ const itemMbr = end.item.getMbr();
39250
+ verticalLines.push(itemMbr.left - ITEM_OFFSET, itemMbr.left, itemMbr.right, itemMbr.right + ITEM_OFFSET);
39251
+ horizontalLines.push(itemMbr.top - ITEM_OFFSET, itemMbr.top, itemMbr.bottom, itemMbr.bottom + ITEM_OFFSET);
39252
+ }
39253
+ const tempStart = start;
39254
+ const tempEnd = end;
39255
+ const middle = new Point((tempStart.x + tempEnd.x) / 2, (tempStart.y + tempEnd.y) / 2);
39256
+ horizontalLines.push(middle.y, tempStart.y, tempEnd.y);
39257
+ verticalLines.push(middle.x, tempStart.x, tempEnd.x);
39258
+ toVisitPoints.forEach((p3) => {
39259
+ horizontalLines.push(p3.y);
39260
+ verticalLines.push(p3.x);
39261
+ });
39262
+ const uniqueHorizontalLines = Array.from(new Set(horizontalLines)).sort((a2, b) => a2 - b);
39263
+ const uniqueVerticalLines = Array.from(new Set(verticalLines)).sort((a2, b) => a2 - b);
39243
39264
  let newStart;
39244
39265
  let newEnd;
39245
39266
  const processPoint = (point5, dir2) => {
39246
39267
  const itemMbr = point5.item.getMbr();
39247
- const mbrFloored = new Mbr(Math.floor(itemMbr.left), Math.floor(itemMbr.top), Math.floor(itemMbr.right), Math.floor(itemMbr.bottom));
39248
- const pointOnMbr = mbrFloored.getLines()[revertMapDir[dir2]].getNearestPointOnLineSegment(point5);
39268
+ const pointOnMbr = itemMbr.getLines()[revertMapDir[dir2]].getNearestPointOnLineSegment(point5);
39249
39269
  const newPoint = Object.create(Object.getPrototypeOf(point5), Object.getOwnPropertyDescriptors(point5));
39250
- newPoint.x = pointOnMbr.x + offsetMap[dir2].x;
39251
- newPoint.y = pointOnMbr.y + offsetMap[dir2].y;
39252
- verticalLines.push(mbrFloored.left - ITEM_OFFSET, mbrFloored.left, pointOnMbr.x, mbrFloored.right, mbrFloored.right + ITEM_OFFSET);
39253
- horizontalLines.push(mbrFloored.top - ITEM_OFFSET, mbrFloored.top, pointOnMbr.y, mbrFloored.bottom, mbrFloored.bottom + ITEM_OFFSET);
39270
+ if (dir2 === "top") {
39271
+ const currentYIndex = uniqueHorizontalLines.findIndex((y) => Math.abs(y - pointOnMbr.y) < 0.01);
39272
+ const nextYIndex = currentYIndex - 1;
39273
+ if (nextYIndex >= 0) {
39274
+ newPoint.y = uniqueHorizontalLines[nextYIndex];
39275
+ newPoint.x = pointOnMbr.x;
39276
+ }
39277
+ } else if (dir2 === "bottom") {
39278
+ const currentYIndex = uniqueHorizontalLines.findIndex((y) => Math.abs(y - pointOnMbr.y) < 0.01);
39279
+ const nextYIndex = currentYIndex + 1;
39280
+ if (nextYIndex < uniqueHorizontalLines.length) {
39281
+ newPoint.y = uniqueHorizontalLines[nextYIndex];
39282
+ newPoint.x = pointOnMbr.x;
39283
+ }
39284
+ } else if (dir2 === "left") {
39285
+ const currentXIndex = uniqueVerticalLines.findIndex((x) => Math.abs(x - pointOnMbr.x) < 0.01);
39286
+ const nextXIndex = currentXIndex - 1;
39287
+ if (nextXIndex >= 0) {
39288
+ newPoint.x = uniqueVerticalLines[nextXIndex];
39289
+ newPoint.y = pointOnMbr.y;
39290
+ }
39291
+ } else if (dir2 === "right") {
39292
+ const currentXIndex = uniqueVerticalLines.findIndex((x) => Math.abs(x - pointOnMbr.x) < 0.01);
39293
+ const nextXIndex = currentXIndex + 1;
39294
+ if (nextXIndex < uniqueVerticalLines.length) {
39295
+ newPoint.x = uniqueVerticalLines[nextXIndex];
39296
+ newPoint.y = pointOnMbr.y;
39297
+ }
39298
+ }
39254
39299
  return newPoint;
39255
39300
  };
39256
39301
  if (start.pointType !== "Board" && startDir) {
@@ -39259,17 +39304,6 @@ function createGrid(start, end, toVisitPoints = []) {
39259
39304
  if (end.pointType !== "Board" && endDir) {
39260
39305
  newEnd = processPoint(end, endDir);
39261
39306
  }
39262
- const finalStart = newStart || start;
39263
- const finalEnd = newEnd || end;
39264
- const middle = new Point((finalStart.x + finalEnd.x) / 2, (finalStart.y + finalEnd.y) / 2);
39265
- horizontalLines.push(middle.y, finalStart.y, finalEnd.y);
39266
- verticalLines.push(middle.x, finalStart.x, finalEnd.x);
39267
- toVisitPoints.forEach((p3) => {
39268
- horizontalLines.push(p3.y);
39269
- verticalLines.push(p3.x);
39270
- });
39271
- const uniqueHorizontalLines = Array.from(new Set(horizontalLines)).sort((a2, b) => a2 - b);
39272
- const uniqueVerticalLines = Array.from(new Set(verticalLines)).sort((a2, b) => a2 - b);
39273
39307
  const grid = uniqueVerticalLines.map((x) => uniqueHorizontalLines.map((y) => new Point(x, y)));
39274
39308
  return {
39275
39309
  grid,
@@ -36612,17 +36612,62 @@ function createGrid(start, end, toVisitPoints = []) {
36612
36612
  };
36613
36613
  const horizontalLines = [];
36614
36614
  const verticalLines = [];
36615
+ if (start.pointType !== "Board") {
36616
+ const itemMbr = start.item.getMbr();
36617
+ verticalLines.push(itemMbr.left - ITEM_OFFSET, itemMbr.left, itemMbr.right, itemMbr.right + ITEM_OFFSET);
36618
+ horizontalLines.push(itemMbr.top - ITEM_OFFSET, itemMbr.top, itemMbr.bottom, itemMbr.bottom + ITEM_OFFSET);
36619
+ }
36620
+ if (end.pointType !== "Board") {
36621
+ const itemMbr = end.item.getMbr();
36622
+ verticalLines.push(itemMbr.left - ITEM_OFFSET, itemMbr.left, itemMbr.right, itemMbr.right + ITEM_OFFSET);
36623
+ horizontalLines.push(itemMbr.top - ITEM_OFFSET, itemMbr.top, itemMbr.bottom, itemMbr.bottom + ITEM_OFFSET);
36624
+ }
36625
+ const tempStart = start;
36626
+ const tempEnd = end;
36627
+ const middle = new Point((tempStart.x + tempEnd.x) / 2, (tempStart.y + tempEnd.y) / 2);
36628
+ horizontalLines.push(middle.y, tempStart.y, tempEnd.y);
36629
+ verticalLines.push(middle.x, tempStart.x, tempEnd.x);
36630
+ toVisitPoints.forEach((p3) => {
36631
+ horizontalLines.push(p3.y);
36632
+ verticalLines.push(p3.x);
36633
+ });
36634
+ const uniqueHorizontalLines = Array.from(new Set(horizontalLines)).sort((a2, b) => a2 - b);
36635
+ const uniqueVerticalLines = Array.from(new Set(verticalLines)).sort((a2, b) => a2 - b);
36615
36636
  let newStart;
36616
36637
  let newEnd;
36617
36638
  const processPoint = (point5, dir2) => {
36618
36639
  const itemMbr = point5.item.getMbr();
36619
- const mbrFloored = new Mbr(Math.floor(itemMbr.left), Math.floor(itemMbr.top), Math.floor(itemMbr.right), Math.floor(itemMbr.bottom));
36620
- const pointOnMbr = mbrFloored.getLines()[revertMapDir[dir2]].getNearestPointOnLineSegment(point5);
36640
+ const pointOnMbr = itemMbr.getLines()[revertMapDir[dir2]].getNearestPointOnLineSegment(point5);
36621
36641
  const newPoint = Object.create(Object.getPrototypeOf(point5), Object.getOwnPropertyDescriptors(point5));
36622
- newPoint.x = pointOnMbr.x + offsetMap[dir2].x;
36623
- newPoint.y = pointOnMbr.y + offsetMap[dir2].y;
36624
- verticalLines.push(mbrFloored.left - ITEM_OFFSET, mbrFloored.left, pointOnMbr.x, mbrFloored.right, mbrFloored.right + ITEM_OFFSET);
36625
- horizontalLines.push(mbrFloored.top - ITEM_OFFSET, mbrFloored.top, pointOnMbr.y, mbrFloored.bottom, mbrFloored.bottom + ITEM_OFFSET);
36642
+ if (dir2 === "top") {
36643
+ const currentYIndex = uniqueHorizontalLines.findIndex((y) => Math.abs(y - pointOnMbr.y) < 0.01);
36644
+ const nextYIndex = currentYIndex - 1;
36645
+ if (nextYIndex >= 0) {
36646
+ newPoint.y = uniqueHorizontalLines[nextYIndex];
36647
+ newPoint.x = pointOnMbr.x;
36648
+ }
36649
+ } else if (dir2 === "bottom") {
36650
+ const currentYIndex = uniqueHorizontalLines.findIndex((y) => Math.abs(y - pointOnMbr.y) < 0.01);
36651
+ const nextYIndex = currentYIndex + 1;
36652
+ if (nextYIndex < uniqueHorizontalLines.length) {
36653
+ newPoint.y = uniqueHorizontalLines[nextYIndex];
36654
+ newPoint.x = pointOnMbr.x;
36655
+ }
36656
+ } else if (dir2 === "left") {
36657
+ const currentXIndex = uniqueVerticalLines.findIndex((x) => Math.abs(x - pointOnMbr.x) < 0.01);
36658
+ const nextXIndex = currentXIndex - 1;
36659
+ if (nextXIndex >= 0) {
36660
+ newPoint.x = uniqueVerticalLines[nextXIndex];
36661
+ newPoint.y = pointOnMbr.y;
36662
+ }
36663
+ } else if (dir2 === "right") {
36664
+ const currentXIndex = uniqueVerticalLines.findIndex((x) => Math.abs(x - pointOnMbr.x) < 0.01);
36665
+ const nextXIndex = currentXIndex + 1;
36666
+ if (nextXIndex < uniqueVerticalLines.length) {
36667
+ newPoint.x = uniqueVerticalLines[nextXIndex];
36668
+ newPoint.y = pointOnMbr.y;
36669
+ }
36670
+ }
36626
36671
  return newPoint;
36627
36672
  };
36628
36673
  if (start.pointType !== "Board" && startDir) {
@@ -36631,17 +36676,6 @@ function createGrid(start, end, toVisitPoints = []) {
36631
36676
  if (end.pointType !== "Board" && endDir) {
36632
36677
  newEnd = processPoint(end, endDir);
36633
36678
  }
36634
- const finalStart = newStart || start;
36635
- const finalEnd = newEnd || end;
36636
- const middle = new Point((finalStart.x + finalEnd.x) / 2, (finalStart.y + finalEnd.y) / 2);
36637
- horizontalLines.push(middle.y, finalStart.y, finalEnd.y);
36638
- verticalLines.push(middle.x, finalStart.x, finalEnd.x);
36639
- toVisitPoints.forEach((p3) => {
36640
- horizontalLines.push(p3.y);
36641
- verticalLines.push(p3.x);
36642
- });
36643
- const uniqueHorizontalLines = Array.from(new Set(horizontalLines)).sort((a2, b) => a2 - b);
36644
- const uniqueVerticalLines = Array.from(new Set(verticalLines)).sort((a2, b) => a2 - b);
36645
36679
  const grid = uniqueVerticalLines.map((x) => uniqueHorizontalLines.map((y) => new Point(x, y)));
36646
36680
  return {
36647
36681
  grid,
package/dist/esm/index.js CHANGED
@@ -36605,17 +36605,62 @@ function createGrid(start, end, toVisitPoints = []) {
36605
36605
  };
36606
36606
  const horizontalLines = [];
36607
36607
  const verticalLines = [];
36608
+ if (start.pointType !== "Board") {
36609
+ const itemMbr = start.item.getMbr();
36610
+ verticalLines.push(itemMbr.left - ITEM_OFFSET, itemMbr.left, itemMbr.right, itemMbr.right + ITEM_OFFSET);
36611
+ horizontalLines.push(itemMbr.top - ITEM_OFFSET, itemMbr.top, itemMbr.bottom, itemMbr.bottom + ITEM_OFFSET);
36612
+ }
36613
+ if (end.pointType !== "Board") {
36614
+ const itemMbr = end.item.getMbr();
36615
+ verticalLines.push(itemMbr.left - ITEM_OFFSET, itemMbr.left, itemMbr.right, itemMbr.right + ITEM_OFFSET);
36616
+ horizontalLines.push(itemMbr.top - ITEM_OFFSET, itemMbr.top, itemMbr.bottom, itemMbr.bottom + ITEM_OFFSET);
36617
+ }
36618
+ const tempStart = start;
36619
+ const tempEnd = end;
36620
+ const middle = new Point((tempStart.x + tempEnd.x) / 2, (tempStart.y + tempEnd.y) / 2);
36621
+ horizontalLines.push(middle.y, tempStart.y, tempEnd.y);
36622
+ verticalLines.push(middle.x, tempStart.x, tempEnd.x);
36623
+ toVisitPoints.forEach((p3) => {
36624
+ horizontalLines.push(p3.y);
36625
+ verticalLines.push(p3.x);
36626
+ });
36627
+ const uniqueHorizontalLines = Array.from(new Set(horizontalLines)).sort((a2, b) => a2 - b);
36628
+ const uniqueVerticalLines = Array.from(new Set(verticalLines)).sort((a2, b) => a2 - b);
36608
36629
  let newStart;
36609
36630
  let newEnd;
36610
36631
  const processPoint = (point5, dir2) => {
36611
36632
  const itemMbr = point5.item.getMbr();
36612
- const mbrFloored = new Mbr(Math.floor(itemMbr.left), Math.floor(itemMbr.top), Math.floor(itemMbr.right), Math.floor(itemMbr.bottom));
36613
- const pointOnMbr = mbrFloored.getLines()[revertMapDir[dir2]].getNearestPointOnLineSegment(point5);
36633
+ const pointOnMbr = itemMbr.getLines()[revertMapDir[dir2]].getNearestPointOnLineSegment(point5);
36614
36634
  const newPoint = Object.create(Object.getPrototypeOf(point5), Object.getOwnPropertyDescriptors(point5));
36615
- newPoint.x = pointOnMbr.x + offsetMap[dir2].x;
36616
- newPoint.y = pointOnMbr.y + offsetMap[dir2].y;
36617
- verticalLines.push(mbrFloored.left - ITEM_OFFSET, mbrFloored.left, pointOnMbr.x, mbrFloored.right, mbrFloored.right + ITEM_OFFSET);
36618
- horizontalLines.push(mbrFloored.top - ITEM_OFFSET, mbrFloored.top, pointOnMbr.y, mbrFloored.bottom, mbrFloored.bottom + ITEM_OFFSET);
36635
+ if (dir2 === "top") {
36636
+ const currentYIndex = uniqueHorizontalLines.findIndex((y) => Math.abs(y - pointOnMbr.y) < 0.01);
36637
+ const nextYIndex = currentYIndex - 1;
36638
+ if (nextYIndex >= 0) {
36639
+ newPoint.y = uniqueHorizontalLines[nextYIndex];
36640
+ newPoint.x = pointOnMbr.x;
36641
+ }
36642
+ } else if (dir2 === "bottom") {
36643
+ const currentYIndex = uniqueHorizontalLines.findIndex((y) => Math.abs(y - pointOnMbr.y) < 0.01);
36644
+ const nextYIndex = currentYIndex + 1;
36645
+ if (nextYIndex < uniqueHorizontalLines.length) {
36646
+ newPoint.y = uniqueHorizontalLines[nextYIndex];
36647
+ newPoint.x = pointOnMbr.x;
36648
+ }
36649
+ } else if (dir2 === "left") {
36650
+ const currentXIndex = uniqueVerticalLines.findIndex((x) => Math.abs(x - pointOnMbr.x) < 0.01);
36651
+ const nextXIndex = currentXIndex - 1;
36652
+ if (nextXIndex >= 0) {
36653
+ newPoint.x = uniqueVerticalLines[nextXIndex];
36654
+ newPoint.y = pointOnMbr.y;
36655
+ }
36656
+ } else if (dir2 === "right") {
36657
+ const currentXIndex = uniqueVerticalLines.findIndex((x) => Math.abs(x - pointOnMbr.x) < 0.01);
36658
+ const nextXIndex = currentXIndex + 1;
36659
+ if (nextXIndex < uniqueVerticalLines.length) {
36660
+ newPoint.x = uniqueVerticalLines[nextXIndex];
36661
+ newPoint.y = pointOnMbr.y;
36662
+ }
36663
+ }
36619
36664
  return newPoint;
36620
36665
  };
36621
36666
  if (start.pointType !== "Board" && startDir) {
@@ -36624,17 +36669,6 @@ function createGrid(start, end, toVisitPoints = []) {
36624
36669
  if (end.pointType !== "Board" && endDir) {
36625
36670
  newEnd = processPoint(end, endDir);
36626
36671
  }
36627
- const finalStart = newStart || start;
36628
- const finalEnd = newEnd || end;
36629
- const middle = new Point((finalStart.x + finalEnd.x) / 2, (finalStart.y + finalEnd.y) / 2);
36630
- horizontalLines.push(middle.y, finalStart.y, finalEnd.y);
36631
- verticalLines.push(middle.x, finalStart.x, finalEnd.x);
36632
- toVisitPoints.forEach((p3) => {
36633
- horizontalLines.push(p3.y);
36634
- verticalLines.push(p3.x);
36635
- });
36636
- const uniqueHorizontalLines = Array.from(new Set(horizontalLines)).sort((a2, b) => a2 - b);
36637
- const uniqueVerticalLines = Array.from(new Set(verticalLines)).sort((a2, b) => a2 - b);
36638
36672
  const grid = uniqueVerticalLines.map((x) => uniqueHorizontalLines.map((y) => new Point(x, y)));
36639
36673
  return {
36640
36674
  grid,
package/dist/esm/node.js CHANGED
@@ -39073,17 +39073,62 @@ function createGrid(start, end, toVisitPoints = []) {
39073
39073
  };
39074
39074
  const horizontalLines = [];
39075
39075
  const verticalLines = [];
39076
+ if (start.pointType !== "Board") {
39077
+ const itemMbr = start.item.getMbr();
39078
+ verticalLines.push(itemMbr.left - ITEM_OFFSET, itemMbr.left, itemMbr.right, itemMbr.right + ITEM_OFFSET);
39079
+ horizontalLines.push(itemMbr.top - ITEM_OFFSET, itemMbr.top, itemMbr.bottom, itemMbr.bottom + ITEM_OFFSET);
39080
+ }
39081
+ if (end.pointType !== "Board") {
39082
+ const itemMbr = end.item.getMbr();
39083
+ verticalLines.push(itemMbr.left - ITEM_OFFSET, itemMbr.left, itemMbr.right, itemMbr.right + ITEM_OFFSET);
39084
+ horizontalLines.push(itemMbr.top - ITEM_OFFSET, itemMbr.top, itemMbr.bottom, itemMbr.bottom + ITEM_OFFSET);
39085
+ }
39086
+ const tempStart = start;
39087
+ const tempEnd = end;
39088
+ const middle = new Point((tempStart.x + tempEnd.x) / 2, (tempStart.y + tempEnd.y) / 2);
39089
+ horizontalLines.push(middle.y, tempStart.y, tempEnd.y);
39090
+ verticalLines.push(middle.x, tempStart.x, tempEnd.x);
39091
+ toVisitPoints.forEach((p3) => {
39092
+ horizontalLines.push(p3.y);
39093
+ verticalLines.push(p3.x);
39094
+ });
39095
+ const uniqueHorizontalLines = Array.from(new Set(horizontalLines)).sort((a2, b) => a2 - b);
39096
+ const uniqueVerticalLines = Array.from(new Set(verticalLines)).sort((a2, b) => a2 - b);
39076
39097
  let newStart;
39077
39098
  let newEnd;
39078
39099
  const processPoint = (point5, dir2) => {
39079
39100
  const itemMbr = point5.item.getMbr();
39080
- const mbrFloored = new Mbr(Math.floor(itemMbr.left), Math.floor(itemMbr.top), Math.floor(itemMbr.right), Math.floor(itemMbr.bottom));
39081
- const pointOnMbr = mbrFloored.getLines()[revertMapDir[dir2]].getNearestPointOnLineSegment(point5);
39101
+ const pointOnMbr = itemMbr.getLines()[revertMapDir[dir2]].getNearestPointOnLineSegment(point5);
39082
39102
  const newPoint = Object.create(Object.getPrototypeOf(point5), Object.getOwnPropertyDescriptors(point5));
39083
- newPoint.x = pointOnMbr.x + offsetMap[dir2].x;
39084
- newPoint.y = pointOnMbr.y + offsetMap[dir2].y;
39085
- verticalLines.push(mbrFloored.left - ITEM_OFFSET, mbrFloored.left, pointOnMbr.x, mbrFloored.right, mbrFloored.right + ITEM_OFFSET);
39086
- horizontalLines.push(mbrFloored.top - ITEM_OFFSET, mbrFloored.top, pointOnMbr.y, mbrFloored.bottom, mbrFloored.bottom + ITEM_OFFSET);
39103
+ if (dir2 === "top") {
39104
+ const currentYIndex = uniqueHorizontalLines.findIndex((y) => Math.abs(y - pointOnMbr.y) < 0.01);
39105
+ const nextYIndex = currentYIndex - 1;
39106
+ if (nextYIndex >= 0) {
39107
+ newPoint.y = uniqueHorizontalLines[nextYIndex];
39108
+ newPoint.x = pointOnMbr.x;
39109
+ }
39110
+ } else if (dir2 === "bottom") {
39111
+ const currentYIndex = uniqueHorizontalLines.findIndex((y) => Math.abs(y - pointOnMbr.y) < 0.01);
39112
+ const nextYIndex = currentYIndex + 1;
39113
+ if (nextYIndex < uniqueHorizontalLines.length) {
39114
+ newPoint.y = uniqueHorizontalLines[nextYIndex];
39115
+ newPoint.x = pointOnMbr.x;
39116
+ }
39117
+ } else if (dir2 === "left") {
39118
+ const currentXIndex = uniqueVerticalLines.findIndex((x) => Math.abs(x - pointOnMbr.x) < 0.01);
39119
+ const nextXIndex = currentXIndex - 1;
39120
+ if (nextXIndex >= 0) {
39121
+ newPoint.x = uniqueVerticalLines[nextXIndex];
39122
+ newPoint.y = pointOnMbr.y;
39123
+ }
39124
+ } else if (dir2 === "right") {
39125
+ const currentXIndex = uniqueVerticalLines.findIndex((x) => Math.abs(x - pointOnMbr.x) < 0.01);
39126
+ const nextXIndex = currentXIndex + 1;
39127
+ if (nextXIndex < uniqueVerticalLines.length) {
39128
+ newPoint.x = uniqueVerticalLines[nextXIndex];
39129
+ newPoint.y = pointOnMbr.y;
39130
+ }
39131
+ }
39087
39132
  return newPoint;
39088
39133
  };
39089
39134
  if (start.pointType !== "Board" && startDir) {
@@ -39092,17 +39137,6 @@ function createGrid(start, end, toVisitPoints = []) {
39092
39137
  if (end.pointType !== "Board" && endDir) {
39093
39138
  newEnd = processPoint(end, endDir);
39094
39139
  }
39095
- const finalStart = newStart || start;
39096
- const finalEnd = newEnd || end;
39097
- const middle = new Point((finalStart.x + finalEnd.x) / 2, (finalStart.y + finalEnd.y) / 2);
39098
- horizontalLines.push(middle.y, finalStart.y, finalEnd.y);
39099
- verticalLines.push(middle.x, finalStart.x, finalEnd.x);
39100
- toVisitPoints.forEach((p3) => {
39101
- horizontalLines.push(p3.y);
39102
- verticalLines.push(p3.x);
39103
- });
39104
- const uniqueHorizontalLines = Array.from(new Set(horizontalLines)).sort((a2, b) => a2 - b);
39105
- const uniqueVerticalLines = Array.from(new Set(verticalLines)).sort((a2, b) => a2 - b);
39106
39140
  const grid = uniqueVerticalLines.map((x) => uniqueHorizontalLines.map((y) => new Point(x, y)));
39107
39141
  return {
39108
39142
  grid,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "microboard-temp",
3
- "version": "0.5.73",
3
+ "version": "0.5.75",
4
4
  "description": "A flexible interactive whiteboard library",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",