Merge pull request #510 from paulkaplan/fix-bit-brush-touch

Fix bit brush on touch devices
This commit is contained in:
Paul Kaplan 2018-06-13 16:51:44 -04:00 committed by GitHub
commit 38f2371e2d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 2 deletions

View file

@ -17,4 +17,5 @@
background-color: white;
border-radius: 100%;
box-shadow: 0 0 0 4px rgba(0, 0, 0, 0.15);
touch-action: none;
}

View file

@ -35,6 +35,9 @@ class BrushTool extends paper.Tool {
}
// Draw a brush mark at the given point
draw (x, y) {
if (!this.tmpCanvas) {
this.tmpCanvas = getBrushMark(this.size, this.color);
}
const roundedUpRadius = Math.ceil(this.size / 2);
getRaster().drawImage(this.tmpCanvas, new paper.Point(~~x - roundedUpRadius, ~~y - roundedUpRadius));
}

View file

@ -38,6 +38,9 @@ class LineTool extends paper.Tool {
}
// Draw a brush mark at the given point
draw (x, y) {
if (!this.tmpCanvas) {
this.tmpCanvas = getBrushMark(this.size, this.color);
}
const roundedUpRadius = Math.ceil(this.size / 2);
this.drawTarget.drawImage(this.tmpCanvas, new paper.Point(~~x - roundedUpRadius, ~~y - roundedUpRadius));
}
@ -72,8 +75,8 @@ class LineTool extends paper.Tool {
handleMouseDown (event) {
if (event.event.button > 0) return; // only first mouse button
this.active = true;
this.cursorPreview.remove();
if (this.cursorPreview) this.cursorPreview.remove();
const tmpCanvas = document.createElement('canvas');
tmpCanvas.width = ART_BOARD_WIDTH;