mirror of
https://github.com/scratchfoundation/scratch-paint.git
synced 2024-12-23 05:52:42 -05:00
Make styleShape more flexible
Now, you can pass null in for a color instead of {primary: null, secondary: null, gradientType: GradientTypes.SOLID} and it'll still clear the color. Passing strokeWidth is also optional now.
This commit is contained in:
parent
c81853b1b7
commit
f625109c67
1 changed files with 4 additions and 2 deletions
|
@ -561,7 +561,9 @@ const styleCursorPreview = function (path, options) {
|
|||
|
||||
const styleShape = function (path, options) {
|
||||
for (const colorKey of ['fillColor', 'strokeColor']) {
|
||||
if (options[colorKey].gradientType === GradientTypes.SOLID) {
|
||||
if (options[colorKey] === null) {
|
||||
path[colorKey] = null;
|
||||
} else if (options[colorKey].gradientType === GradientTypes.SOLID) {
|
||||
path[colorKey] = options[colorKey].primary;
|
||||
} else {
|
||||
const {primary, secondary, gradientType} = options[colorKey];
|
||||
|
@ -569,7 +571,7 @@ const styleShape = function (path, options) {
|
|||
}
|
||||
}
|
||||
|
||||
path.strokeWidth = options.strokeWidth;
|
||||
if (options.hasOwnProperty('strokeWidth')) path.strokeWidth = options.strokeWidth;
|
||||
};
|
||||
|
||||
export {
|
||||
|
|
Loading…
Reference in a new issue