Skip to content

Commit

Permalink
perf: optimize passing of colors to native
Browse files Browse the repository at this point in the history
  • Loading branch information
msand committed Jan 18, 2020
1 parent c12cd1e commit f138c9b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/lib/extract/extractBrush.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand All @@ -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`);
Expand Down
6 changes: 2 additions & 4 deletions src/lib/extract/extractFill.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
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 } = {
evenodd: 0,
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,
Expand Down

0 comments on commit f138c9b

Please sign in to comment.