@fieldnotes/core 0.31.0 → 0.31.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/README.md CHANGED
@@ -439,7 +439,7 @@ new Viewport(container, {
439
439
 
440
440
  ```typescript
441
441
  new PencilTool({ color: '#ff0000', width: 3, smoothing: 1.5 });
442
- new EraserTool({ radius: 30 }); // mode: 'partial' (default) splits strokes at the erased span; mode: 'stroke' deletes the whole stroke
442
+ new EraserTool({ radius: 30 }); // radius is screen pixels (converted to world units per zoom); mode: 'partial' (default) splits strokes at the erased span; mode: 'stroke' deletes the whole stroke
443
443
  new ArrowTool({ color: '#333', width: 2 });
444
444
  ```
445
445
 
package/dist/index.cjs CHANGED
@@ -6457,11 +6457,12 @@ var EraserTool = class {
6457
6457
  }
6458
6458
  eraseAt(state, ctx) {
6459
6459
  const world = ctx.camera.screenToWorld({ x: state.x, y: state.y });
6460
+ const worldRadius = this.radius / ctx.camera.zoom;
6460
6461
  const queryBounds = {
6461
- x: world.x - this.radius,
6462
- y: world.y - this.radius,
6463
- w: this.radius * 2,
6464
- h: this.radius * 2
6462
+ x: world.x - worldRadius,
6463
+ y: world.y - worldRadius,
6464
+ w: worldRadius * 2,
6465
+ h: worldRadius * 2
6465
6466
  };
6466
6467
  const candidates = ctx.store.queryRect(queryBounds);
6467
6468
  let erased = false;
@@ -6469,14 +6470,14 @@ var EraserTool = class {
6469
6470
  if (el.type !== "stroke") continue;
6470
6471
  if (ctx.isLayerVisible && !ctx.isLayerVisible(el.layerId)) continue;
6471
6472
  if (ctx.isLayerLocked && ctx.isLayerLocked(el.layerId)) continue;
6472
- if (!this.strokeIntersects(el, world)) continue;
6473
+ if (!this.strokeIntersects(el, world, worldRadius)) continue;
6473
6474
  if (this.mode === "stroke") {
6474
6475
  ctx.store.remove(el.id);
6475
6476
  erased = true;
6476
6477
  continue;
6477
6478
  }
6478
6479
  const localEraser = { x: world.x - el.position.x, y: world.y - el.position.y };
6479
- const runs = erasePoints(el.points, localEraser, this.radius);
6480
+ const runs = erasePoints(el.points, localEraser, worldRadius);
6480
6481
  if (runs === null) continue;
6481
6482
  ctx.store.remove(el.id);
6482
6483
  for (const run of runs) {
@@ -6496,8 +6497,8 @@ var EraserTool = class {
6496
6497
  }
6497
6498
  if (erased) ctx.requestRender();
6498
6499
  }
6499
- strokeIntersects(stroke, point) {
6500
- return hitTestStroke(stroke, point, this.radius);
6500
+ strokeIntersects(stroke, point, worldRadius) {
6501
+ return hitTestStroke(stroke, point, worldRadius);
6501
6502
  }
6502
6503
  };
6503
6504
 
@@ -8104,7 +8105,7 @@ var TemplateTool = class {
8104
8105
  };
8105
8106
 
8106
8107
  // src/index.ts
8107
- var VERSION = "0.31.0";
8108
+ var VERSION = "0.31.1";
8108
8109
  // Annotate the CommonJS export names for ESM import in node:
8109
8110
  0 && (module.exports = {
8110
8111
  ArrowTool,