mirror of
https://github.com/scratchfoundation/scratch-paint.git
synced 2025-01-08 13:42:00 -05:00
clean up and add comment
This commit is contained in:
parent
720f83605d
commit
e4f1a5ad28
1 changed files with 8 additions and 9 deletions
|
@ -50,9 +50,12 @@ class Blobbiness {
|
||||||
* @param {?number} options.strokeWidth Width of the brush outline.
|
* @param {?number} options.strokeWidth Width of the brush outline.
|
||||||
*/
|
*/
|
||||||
setOptions (options) {
|
setOptions (options) {
|
||||||
const oldFillColor = this.options ? this.options.fillColor : null;
|
const oldFillColor = this.options ? this.options.fillColor : 'black';
|
||||||
const oldStrokeColor = this.options ? this.options.strokeColor : null;
|
const oldStrokeColor = this.options ? this.options.strokeColor : null;
|
||||||
const oldStrokeWidth = this.options ? this.options.strokeWidth : null;
|
const oldStrokeWidth = this.options ? this.options.strokeWidth : null;
|
||||||
|
// If values are mixed, it means the color was set by a selection contained multiple values.
|
||||||
|
// In this case keep drawing with the previous values if any. (For stroke width, null indicates)
|
||||||
|
// mixed, because stroke width is required to be a number)
|
||||||
this.options = {
|
this.options = {
|
||||||
...options,
|
...options,
|
||||||
fillColor: options.fillColor === MIXED ? oldFillColor : options.fillColor,
|
fillColor: options.fillColor === MIXED ? oldFillColor : options.fillColor,
|
||||||
|
@ -163,8 +166,8 @@ class Blobbiness {
|
||||||
|
|
||||||
if (this.cursorPreview &&
|
if (this.cursorPreview &&
|
||||||
this.brushSize === this.options.brushSize &&
|
this.brushSize === this.options.brushSize &&
|
||||||
(this.options.fillColor === MIXED || this.fillColor === this.options.fillColor) &&
|
this.fillColor === this.options.fillColor &&
|
||||||
(this.options.strokeColor === MIXED || this.strokeColor === this.options.strokeColor)) {
|
this.strokeColor === this.options.strokeColor) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const newPreview = new paper.Path.Circle({
|
const newPreview = new paper.Path.Circle({
|
||||||
|
@ -175,12 +178,8 @@ class Blobbiness {
|
||||||
this.cursorPreview.remove();
|
this.cursorPreview.remove();
|
||||||
}
|
}
|
||||||
this.brushSize = this.options.brushSize;
|
this.brushSize = this.options.brushSize;
|
||||||
if (this.options.fillColor !== MIXED) {
|
this.fillColor = this.options.fillColor;
|
||||||
this.fillColor = this.options.fillColor;
|
this.strokeColor = this.options.strokeColor;
|
||||||
}
|
|
||||||
if (this.options.strokeColor !== MIXED) {
|
|
||||||
this.strokeColor = this.options.strokeColor;
|
|
||||||
}
|
|
||||||
this.cursorPreview = newPreview;
|
this.cursorPreview = newPreview;
|
||||||
styleCursorPreview(this.cursorPreview, this.options);
|
styleCursorPreview(this.cursorPreview, this.options);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue