mirror of
https://github.com/scratchfoundation/scratch-paint.git
synced 2025-03-13 22:50:01 -04:00
Merge pull request #510 from paulkaplan/fix-bit-brush-touch
Fix bit brush on touch devices
This commit is contained in:
commit
38f2371e2d
3 changed files with 9 additions and 2 deletions
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue