mirror of
https://github.com/zoriya/react-native-svg.git
synced 2026-06-06 16:32:24 +00:00
fix rgba fill and stroke bug
This commit is contained in:
@@ -9,17 +9,14 @@ const fillRules = {
|
|||||||
|
|
||||||
function fillFilter(props) {
|
function fillFilter(props) {
|
||||||
let {fill} = props;
|
let {fill} = props;
|
||||||
|
let fillOpacity = +props.fillOpacity;
|
||||||
|
|
||||||
if (fill === 'none') {
|
if (fill === 'none') {
|
||||||
return null;
|
return null;
|
||||||
} else if (fill) {
|
} else if (fill) {
|
||||||
return patterns(fill, +props.fillOpacity, props.svgId);
|
return patterns(fill, fillOpacity, props.svgId);
|
||||||
} else if (props.fill === undefined) {
|
} else if (props.fill === undefined) {
|
||||||
let fillOpacity = +props.fillOpacity;
|
return rgba('#000', isNaN(fillOpacity) ? 1 : fillOpacity).rgbaString();
|
||||||
if (isNaN(fillOpacity)) {
|
|
||||||
fillOpacity = 1;
|
|
||||||
}
|
|
||||||
return rgba('#000', fillOpacity).rgbaString();
|
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,10 +28,6 @@ export default function(patternSting, opacity, svgId) {
|
|||||||
return patternSting;
|
return patternSting;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isNaN(opacity)) {
|
|
||||||
opacity = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 尝试匹配 "url(#pattern)"
|
// 尝试匹配 "url(#pattern)"
|
||||||
let matched = patternSting.match(patternReg);
|
let matched = patternSting.match(patternReg);
|
||||||
|
|
||||||
|
|||||||
+7
-2
@@ -1,9 +1,14 @@
|
|||||||
import Color from 'color';
|
import Color from 'color';
|
||||||
let noneFill = ['transparent', 'none'];
|
let noneFill = ['transparent', 'none'];
|
||||||
export default function (color, opacity = 1) {
|
export default function (color, opacity) {
|
||||||
if (noneFill.indexOf(color) !== -1 || !color) {
|
if (noneFill.indexOf(color) !== -1 || !color) {
|
||||||
return Color('#000');
|
return Color('#000');
|
||||||
} else {
|
} else {
|
||||||
return Color(color).alpha(+opacity);
|
let c = Color(color);
|
||||||
|
|
||||||
|
if (!isNaN(opacity)) {
|
||||||
|
c = c.alpha(opacity);
|
||||||
|
}
|
||||||
|
return c;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-1
@@ -1,5 +1,8 @@
|
|||||||
import _ from 'lodash';
|
|
||||||
export default function (stops, opacity) {
|
export default function (stops, opacity) {
|
||||||
|
if (isNaN(opacity)) {
|
||||||
|
opacity = 1;
|
||||||
|
}
|
||||||
|
|
||||||
return _.reduce(stops, (ret, color, key) => {
|
return _.reduce(stops, (ret, color, key) => {
|
||||||
ret[key] = color.alpha(color.alpha() * opacity).rgbaString();
|
ret[key] = color.alpha(color.alpha() * opacity).rgbaString();
|
||||||
return ret;
|
return ret;
|
||||||
|
|||||||
Reference in New Issue
Block a user