feat: implement support for context-fill and context-stroke color

This commit is contained in:
Mikael Sand
2019-10-03 14:15:04 +03:00
parent 2af5b6cf29
commit f9a72381b7
8 changed files with 147 additions and 0 deletions
+10
View File
@@ -4,6 +4,8 @@ import { Color } from './types';
const urlIdPattern = /^url\(#(.+)\)$/;
const currentColorBrush = [2];
const contextFillBrush = [3];
const contextStrokeBrush = [4];
export default function extractBrush(color?: Color) {
if (typeof color === 'number') {
@@ -20,6 +22,14 @@ export default function extractBrush(color?: Color) {
return currentColorBrush;
}
if (color === 'context-fill') {
return contextFillBrush;
}
if (color === 'context-stroke') {
return contextStrokeBrush;
}
const brush = typeof color === 'string' && color.match(urlIdPattern);
if (brush) {
return [1, brush[1]];