mirror of
https://github.com/zoriya/react-native-svg.git
synced 2025-12-20 05:55:10 +00:00
34 lines
754 B
JavaScript
34 lines
754 B
JavaScript
import rgba from '../rgba';
|
|
import extractBrush from './extractBrush';
|
|
import patterns from './patterns';
|
|
|
|
const fillRules = {
|
|
evenodd: 0,
|
|
nonzero: 1
|
|
};
|
|
|
|
function fillFilter(props) {
|
|
let {fill} = props;
|
|
let fillOpacity = +props.fillOpacity;
|
|
|
|
if (fill === 'none') {
|
|
return null;
|
|
} else if (fill) {
|
|
return patterns(fill, fillOpacity, props.svgId);
|
|
} else if (props.fill === undefined) {
|
|
return rgba('#000', isNaN(fillOpacity) ? 1 : fillOpacity).rgbaString();
|
|
} else {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
export default function(props) {
|
|
let fill = extractBrush(fillFilter(props), props);
|
|
let fillRule = fillRules[props.fillRule] === 0 ? 0 : 1;
|
|
|
|
return {
|
|
fill,
|
|
fillRule
|
|
};
|
|
}
|