Files
react-native-svg/lib/extract/extractFill.js
2016-07-20 14:44:19 +08:00

34 lines
741 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);
} 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
};
}