mirror of
https://github.com/zoriya/react-native-svg.git
synced 2025-12-06 07:06:11 +00:00
perf: optimize passing of colors to native
This commit is contained in:
@@ -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`);
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user