Skip to content

Commit 7da63b3

Browse files
authored
broad-brush-helper.js -- constraint mouse up
1 parent 97e8f58 commit 7da63b3

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

src/helper/blob-tools/broad-brush-helper.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ class BroadBrushHelper {
256256
if (options.simplifySize > 0 && this.finalPath.segments) this.simplify(options.simplifySize);
257257
return this.finalPath;
258258
}
259+
259260
let delta = this.lastVec;
260261

261262
// If the mouse up is at the same point as the mouse drag event then we need
@@ -264,6 +265,18 @@ class BroadBrushHelper {
264265
// The given event.delta is the difference between the mouse down coords and the mouse up coords,
265266
// but we want the difference between the last mouse drag coords and the mouse up coords.
266267
delta = event.point.subtract(this.lastPoint);
268+
269+
if (event.modifiers.shift) {
270+
// 45 degree movement
271+
delta = snapDeltaToAngle(delta, Math.PI / 4);
272+
} else if (event.modifiers.alt) {
273+
// vertical movement
274+
delta = new paper.Point(0, delta.y);
275+
} else if (event.modifiers.control || event.modifiers.meta) {
276+
// horizontal movement
277+
delta = new paper.Point(delta.x, 0);
278+
}
279+
267280
const step = delta.normalize(options.brushSize / 2);
268281
step.angle += 90;
269282

0 commit comments

Comments
 (0)