diff --git a/src/tool/color.ts b/src/tool/color.ts index bacf1fa9e..a6b54410a 100644 --- a/src/tool/color.ts +++ b/src/tool/color.ts @@ -180,6 +180,13 @@ export function parse(colorStr: string, rgbaArr?: number[]): number[] { return rgbaArr; } + // check for the syntax, + // https://drafts.csswg.org/css-color/#color-syntax + if (/\(\S*\s\S*\s\S*/.test(colorStr)) { + colorStr = colorStr.replace(/\s\/\s/, ' '); + str = colorStr.replace(/ /g, ','); + } + // supports the forms #rgb, #rrggbb, #rgba, #rrggbbaa // #rrggbbaa(use the last pair of digits as alpha) // see https://drafts.csswg.org/css-color/#hex-notation