From f138c9b1aba568ac3ac0c272af1d62811519f526 Mon Sep 17 00:00:00 2001 From: Mikael Sand Date: Sat, 18 Jan 2020 05:01:55 +0200 Subject: [PATCH] perf: optimize passing of colors to native --- src/lib/extract/extractBrush.ts | 4 ++-- src/lib/extract/extractFill.ts | 6 ++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/lib/extract/extractBrush.ts b/src/lib/extract/extractBrush.ts index 3903107d..1bb7e3a3 100644 --- a/src/lib/extract/extractBrush.ts +++ b/src/lib/extract/extractBrush.ts @@ -10,7 +10,7 @@ const contextStrokeBrush = [4]; export default function extractBrush(color?: Color) { if (typeof color === 'number') { if (color >>> 0 === color && color >= 0 && color <= 0xffffffff) { - return [0, integerColor(color)]; + return integerColor(color); } } @@ -37,7 +37,7 @@ export default function extractBrush(color?: Color) { const int32ARGBColor = extractColor(color); if (typeof int32ARGBColor === 'number') { - return [0, int32ARGBColor]; + return int32ARGBColor; } console.warn(`"${color}" is not a valid color or brush`); diff --git a/src/lib/extract/extractFill.ts b/src/lib/extract/extractFill.ts index 13730eb1..c34163e1 100644 --- a/src/lib/extract/extractFill.ts +++ b/src/lib/extract/extractFill.ts @@ -1,6 +1,6 @@ import extractBrush from './extractBrush'; import extractOpacity from './extractOpacity'; -import { colorNames, integerColor } from './extractColor'; +import { colorNames } from './extractColor'; import { FillProps } from './types'; const fillRules: { evenodd: number; nonzero: number } = { @@ -8,9 +8,7 @@ const fillRules: { evenodd: number; nonzero: number } = { nonzero: 1, }; -// default fill is black -const black = colorNames.black; -const defaultFill = [0, integerColor(black as number)]; +const defaultFill = colorNames.black; export default function extractFill( props: FillProps,