mirror of
https://github.com/zoriya/react-native-svg.git
synced 2025-12-20 14:05:09 +00:00
27 lines
624 B
JavaScript
27 lines
624 B
JavaScript
import SerializablePath from 'react-native/Libraries/ART/ARTSerializablePath';
|
|
import clipReg from './patternReg';
|
|
|
|
const clipRules = {
|
|
evenodd: 0,
|
|
nonzero: 1
|
|
};
|
|
|
|
export default function (props) {
|
|
let {clipPath, clipRule} = props;
|
|
let clippingProps = {};
|
|
|
|
if (clipPath) {
|
|
clippingProps.clipRule = clipRules[clipRule] === 0 ? 0 : 1;
|
|
|
|
let matched = clipPath.match(clipReg);
|
|
|
|
if (matched) {
|
|
clippingProps.clipPathRef = matched[1];
|
|
} else {
|
|
clippingProps.clipPath = new SerializablePath(clipPath).toJSON();
|
|
}
|
|
}
|
|
|
|
return clippingProps;
|
|
}
|