Skip to content

Commit 0069063

Browse files
Path tool: selection improvements
1 parent bcd2f05 commit 0069063

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,9 @@ Create polylines made of straight or curved segments.
3636

3737
**Editing:**
3838

39-
- **Toggle corner/curve:** Click a point to switch between corner and smooth curve (handles will appear).
40-
- **Adjust curvature:**: Drag the handles to refine the shape.
39+
- **Delete points:** Press `Del` or `Backspace` while a point is selected to remove that point from the path.
40+
- **Toggle corner/curve:** Hold `Alt` (or `Option` on Mac) and click a point to switch between corner and smooth curve (handles will appear).
41+
- **Adjust curvature:** Drag the handles to refine the shape.
4142
- **Sharp corner between curves:** Hold `Alt` (or `Option` on Mac) while dragging a handle to move it independently.
4243
- **Re-link handles:** Double-click the point to snap handles back together.
4344

src/path/PathEditor.svelte

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@
6969
7070
/** Determine visible midpoint, if any **/
7171
const onPointerMove = (evt: PointerEvent) => {
72+
if (selectedCorner !== null || !midpoints.some(m => m.visible)) {
73+
visibleMidpoint = undefined;
74+
return;
75+
}
76+
7277
const [px, py] = transform.elementToImage(evt.offsetX, evt.offsetY);
7378
7479
const getDistSq = (pt: number[]) =>
@@ -117,22 +122,21 @@
117122
// Drag, not click
118123
if (performance.now() - lastHandleClick > CLICK_THRESHOLD) return;
119124
120-
// Click on a CORNER instantly selects and converts to curve
121-
const { type } = geom.points[idx];
122-
123-
if (type === 'CORNER') {
124-
selectedCorner = idx;
125+
const isSelected = selectedCorner === idx;
125126
127+
// Clicking on a handle with alt key pressed toggles between corner/curve
128+
if (isAltPressed) {
126129
const polyline = togglePolylineCorner(shape, idx, viewportScale);
127130
dispatch('change', polyline);
131+
132+
// If was not selected, select it now
133+
if (!isSelected) {
134+
selectedCorner = idx;
135+
}
128136
} else {
129-
const isSelected = selectedCorner === idx;
130137
if (isSelected) {
131-
// If already selected, toggle to corner
132-
const polyline = togglePolylineCorner(shape, idx,viewportScale);
133-
dispatch('change', polyline);
138+
selectedCorner = null;
134139
} else {
135-
// Just select
136140
selectedCorner = idx;
137141
}
138142
}
@@ -446,6 +450,7 @@ const onAddPoint = (midpointIdx: number) => async (evt: PointerEvent) => {
446450
x={pt.point[0]}
447451
y={pt.point[1]}
448452
scale={viewportScale}
453+
selected={selectedCorner === idx}
449454
on:dblclick={onDoubleClick(idx)}
450455
on:pointerenter={onEnterHandle}
451456
on:pointerleave={onLeaveHandle}

0 commit comments

Comments
 (0)