@tsdraw/core 0.8.0 → 0.8.1

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/dist/index.cjs CHANGED
@@ -603,6 +603,7 @@ var ToolManager = class {
603
603
  getCurrentState() {
604
604
  return this.currentState;
605
605
  }
606
+ // Transition between states within the same tool (ex. pen_idle -> pen_drawing)
606
607
  transition(stateId, info) {
607
608
  const next = this.states.get(stateId);
608
609
  if (!next) return;
@@ -1129,6 +1130,7 @@ var GeometricDrawingState = class extends StateNode {
1129
1130
  });
1130
1131
  this.currentShapeId = nextShapeId;
1131
1132
  }
1133
+ // Shift key switches between constrained and unconstrained bounds
1132
1134
  onPointerMove() {
1133
1135
  const activeShape = this.getActiveShape();
1134
1136
  if (!activeShape) return;
@@ -1162,6 +1164,8 @@ var GeometricDrawingState = class extends StateNode {
1162
1164
  onKeyUp() {
1163
1165
  this.onPointerMove();
1164
1166
  }
1167
+ // If user dragged, use the drag extents for the final shape
1168
+ // If they just clicked without dragging, use default-sized shape
1165
1169
  completeShape() {
1166
1170
  const activeShape = this.getActiveShape();
1167
1171
  const config = this.getConfig();
@@ -1482,6 +1486,8 @@ var EraserErasingState = class extends StateNode {
1482
1486
  onCancel() {
1483
1487
  this.ctx.transition("eraser_idle");
1484
1488
  }
1489
+ // On every pointer move, test the line from previous pointer position to current one against nearby shapes
1490
+ // Only select shapes whose bounding box overlaps the sweep area to avoid testing all shapes
1485
1491
  sweep() {
1486
1492
  const zoom = this.editor.getZoomLevel();
1487
1493
  const tolerance = ERASER_MARGIN / zoom;
@@ -1500,6 +1506,7 @@ var EraserErasingState = class extends StateNode {
1500
1506
  this._marked = [...hitIds];
1501
1507
  this.editor.setErasingShapes(this._marked);
1502
1508
  }
1509
+ // Delete marked shapes and reset, then go back to idle
1503
1510
  finish() {
1504
1511
  const ids = this.editor.getErasingShapeIds();
1505
1512
  if (ids.length > 0) {