mirror of
https://github.com/scratchfoundation/scratch-paint.git
synced 2025-01-25 05:39:52 -05:00
Merge pull request #185 from fsih/betterCursorPreview
Improve cursor preview efficiency
This commit is contained in:
commit
4924caec89
1 changed files with 15 additions and 17 deletions
|
@ -163,32 +163,30 @@ class Blobbiness {
|
||||||
if (!this.options) {
|
if (!this.options) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof point === 'undefined') {
|
|
||||||
point = this.cursorPreviewLastPoint;
|
|
||||||
} else {
|
|
||||||
this.cursorPreviewLastPoint = point;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.cursorPreview && this.cursorPreview.parent &&
|
if (this.cursorPreview && this.cursorPreview.parent &&
|
||||||
this.brushSize === this.options.brushSize &&
|
this.brushSize === this.options.brushSize &&
|
||||||
this.fillColor === this.options.fillColor &&
|
this.fillColor === this.options.fillColor &&
|
||||||
this.strokeColor === this.options.strokeColor) {
|
this.strokeColor === this.options.strokeColor &&
|
||||||
|
this.cursorPreviewLastPoint.equals(point)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const newPreview = new paper.Path.Circle({
|
if (typeof point !== 'undefined') {
|
||||||
center: point,
|
this.cursorPreviewLastPoint = point;
|
||||||
radius: this.options.brushSize / 2
|
|
||||||
});
|
|
||||||
newPreview.parent = getGuideLayer();
|
|
||||||
newPreview.data.isHelperItem = true;
|
|
||||||
if (this.cursorPreview) {
|
|
||||||
this.cursorPreview.remove();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!this.cursorPreview) {
|
||||||
|
this.cursorPreview = new paper.Shape.Ellipse({
|
||||||
|
point: this.cursorPreviewLastPoint,
|
||||||
|
size: this.options.brushSize / 2
|
||||||
|
});
|
||||||
|
this.cursorPreview.parent = getGuideLayer();
|
||||||
|
this.cursorPreview.data.isHelperItem = true;
|
||||||
|
}
|
||||||
|
this.cursorPreview.position = this.cursorPreviewLastPoint;
|
||||||
|
this.cursorPreview.radius = this.options.brushSize / 2;
|
||||||
this.brushSize = this.options.brushSize;
|
this.brushSize = this.options.brushSize;
|
||||||
this.fillColor = this.options.fillColor;
|
this.fillColor = this.options.fillColor;
|
||||||
this.strokeColor = this.options.strokeColor;
|
this.strokeColor = this.options.strokeColor;
|
||||||
this.cursorPreview = newPreview;
|
|
||||||
styleCursorPreview(this.cursorPreview, this.options);
|
styleCursorPreview(this.cursorPreview, this.options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue