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