mirror of
https://github.com/zoriya/react-native-svg.git
synced 2025-12-19 21:45:10 +00:00
23 lines
548 B
JavaScript
23 lines
548 B
JavaScript
import Color from 'color';
|
|
import _ from 'lodash';
|
|
import patternReg from './patternReg';
|
|
|
|
export default function (colorOrBrush) {
|
|
if (colorOrBrush === 'none') {
|
|
return null;
|
|
} else if (_.isNil(colorOrBrush)) {
|
|
colorOrBrush = '#000';
|
|
}
|
|
|
|
let matched = colorOrBrush.match(patternReg);
|
|
|
|
// brush
|
|
if (matched) {
|
|
return [1, matched[1]];
|
|
//todo:
|
|
} else { // solid color
|
|
let c = new Color(colorOrBrush).rgbaArray();
|
|
return [0, c[0] / 255, c[1] / 255, c[2] / 255, c[3]];
|
|
}
|
|
}
|