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:
adroitwhiz 2020-07-09 17:05:43 -04:00
parent c81853b1b7
commit f625109c67

View file

@ -561,7 +561,9 @@ const styleCursorPreview = function (path, options) {
const styleShape = function (path, options) { const styleShape = function (path, options) {
for (const colorKey of ['fillColor', 'strokeColor']) { 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; path[colorKey] = options[colorKey].primary;
} else { } else {
const {primary, secondary, gradientType} = options[colorKey]; 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 { export {