polymorphic eraser

how to test

  1. Select tool: box-select or click, move items
  2. Draw on top of existing
  3. Erase
  4. Select and move erased items
  • Verify box-select works
  • Verify click-to-select works

open questions

  • LSP-compliant across all overrides? Yes
  • Works with unerasables? (likely yes)
  • Needs good docs:
    • paper.js undocumented inheritance mechanism
    • Warn: LSP violations render it unusable

why it works

  • Per-item destination-out compositing of stored strokes
  • Polymorphic _draw override—unofficial but public API; ignore scary _ prefix, it's the idiomatic final render step which bakes in all transformations, styles, etc.
  • Respects per-item undo, fits existing concepts
  • Orders-of-magnitude faster than Boolean Operations, much less brittle

how it works

  1. Override _draw per Item (Path, Raster, PointText)
  2. Record stroke as [width, points]
  3. Pick targets on pointer down, keep stable until up
  4. Store in local coords via globalToLocal(p)
  5. _eraseDraft for preview; commit on pointer up
  6. Draw item, then destination-out erasures
  7. applyMatrix=false so erasures follow items
  8. Hit-test: reject if dist < width/2 + tolerance