mirror of
https://github.com/scratchfoundation/scratch-paint.git
synced 2024-12-23 05:52:42 -05:00
Fix color matching logic in apply stroke color
This commit is contained in:
parent
4580fcc7d8
commit
30e21e5d1c
1 changed files with 8 additions and 6 deletions
|
@ -50,6 +50,11 @@ const applyFillColorToSelection = function (colorString, onUpdateSvg) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const _strokeColorMatch = function (item, incomingColor) {
|
||||||
|
return (!item.strokeColor && !incomingColor) ||
|
||||||
|
(item.strokeColor && incomingColor && item.strokeColor.toCSS() === new paper.Color(incomingColor).toCSS());
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when setting stroke color
|
* Called when setting stroke color
|
||||||
* @param {string} colorString New color, css format
|
* @param {string} colorString New color, css format
|
||||||
|
@ -65,8 +70,7 @@ const applyStrokeColorToSelection = function (colorString, onUpdateSvg) {
|
||||||
if (child.children) {
|
if (child.children) {
|
||||||
for (const path of child.children) {
|
for (const path of child.children) {
|
||||||
if (!path.data.isPGGlyphRect) {
|
if (!path.data.isPGGlyphRect) {
|
||||||
if ((path.strokeColor === null && colorString) ||
|
if (!_strokeColorMatch(path, colorString)) {
|
||||||
path.strokeColor.toCSS() !== new paper.Color(colorString).toCSS()) {
|
|
||||||
changed = true;
|
changed = true;
|
||||||
path.strokeColor = colorString;
|
path.strokeColor = colorString;
|
||||||
}
|
}
|
||||||
|
@ -80,14 +84,12 @@ const applyStrokeColorToSelection = function (colorString, onUpdateSvg) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (!item.data.isPGGlyphRect) {
|
} else if (!item.data.isPGGlyphRect) {
|
||||||
if ((item.strokeColor === null && colorString) ||
|
if (!_strokeColorMatch(item, colorString)) {
|
||||||
item.strokeColor.toCSS() !== new paper.Color(colorString).toCSS()) {
|
|
||||||
changed = true;
|
changed = true;
|
||||||
item.strokeColor = colorString;
|
item.strokeColor = colorString;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if ((item.strokeColor === null && colorString) ||
|
} else if (!_strokeColorMatch(item, colorString)) {
|
||||||
item.strokeColor.toCSS() !== new paper.Color(colorString).toCSS()) {
|
|
||||||
changed = true;
|
changed = true;
|
||||||
item.strokeColor = colorString;
|
item.strokeColor = colorString;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue