Skip to content

Commit b67366b

Browse files
authored
constraint bitmap brush attempt 2
1 parent c8169ef commit b67366b

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

src/helper/bit-tools/brush-tool.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ class BrushTool extends paper.Tool {
8888
this.lastSize = this.size;
8989
this.lastColor = this.color;
9090
}
91-
constrainPoint(delta, lastPoint, modifiers) {
91+
constrainPoint(currentPoint, lastPoint, modifiers) {
92+
let delta = currentPoint.subtract(lastPoint);
9293
if (modifiers.shift) {
9394
// 45 degree movement
9495
delta = snapDeltaToAngle(delta, Math.PI / 4);
@@ -129,21 +130,21 @@ class BrushTool extends paper.Tool {
129130
}
130131
}
131132

132-
const point = this.constrainPoint(event.delta, event.point, event.modifiers);
133+
const point = event.point;
133134
this.drawNextLine(point, point);
134135
this.lastPoint = point;
135136
}
136137
handleMouseDrag (event) {
137138
if (event.event.button > 0 || !this.active) return; // only first mouse button
138139

139-
const point = this.constrainPoint(event.delta, event.point, event.modifiers);
140+
const point = this.constrainPoint(event.point, this.lastPoint, event.modifiers);
140141
this.drawNextLine(this.lastPoint, point);
141142
this.lastPoint = point;
142143
}
143144
handleMouseUp (event) {
144145
if (event.event.button > 0 || !this.active) return; // only first mouse button
145146

146-
const point = this.constrainPoint(event.delta, event.point, event.modifiers);
147+
const point = this.constrainPoint(event.point, this.lastPoint, event.modifiers);
147148
this.drawNextLine(this.lastPoint, point);
148149
if (!this.isEraser) {
149150
getRaster().drawImage(this.drawTarget.canvas, new paper.Point(0, 0));

0 commit comments

Comments
 (0)