mirror of
https://github.com/zoriya/react-native-svg.git
synced 2026-06-02 14:50:43 +00:00
fix text context and complete gradient js code
This commit is contained in:
@@ -11,26 +11,7 @@ import {LINEAR_GRADIENT} from '../lib/extract/extractBrush';
|
||||
import insertColorStopsIntoArray from '../lib/insertProcessor';
|
||||
|
||||
function LinearGradientGenerator(stops, x1, y1, x2, y2) {
|
||||
var type = LINEAR_GRADIENT;
|
||||
|
||||
if (arguments.length < 5) {
|
||||
var angle = ((x1 == null) ? 270 : x1) * Math.PI / 180;
|
||||
|
||||
var x = Math.cos(angle);
|
||||
var y = -Math.sin(angle);
|
||||
var l = (Math.abs(x) + Math.abs(y)) / 2;
|
||||
|
||||
x *= l; y *= l;
|
||||
|
||||
x1 = 0.5 - x;
|
||||
x2 = 0.5 + x;
|
||||
y1 = 0.5 - y;
|
||||
y2 = 0.5 + y;
|
||||
this._bb = true;
|
||||
} else {
|
||||
this._bb = false;
|
||||
}
|
||||
var brushData = [type, +x1, +y1, +x2, +y2];
|
||||
var brushData = [LINEAR_GRADIENT, x1, y1, x2, y2];
|
||||
insertColorStopsIntoArray(stops, brushData, 5);
|
||||
this._brush = brushData;
|
||||
}
|
||||
@@ -53,20 +34,9 @@ class LinearGradient extends Gradient{
|
||||
x2,
|
||||
y2
|
||||
} = this.props;
|
||||
let gradientProps = [x1, y1, x2, y2];
|
||||
return super.render(
|
||||
gradientProps,
|
||||
function (factories, stops, boundingBox, opacity) {
|
||||
return new LinearGradientGenerator(
|
||||
stopsOpacity(stops, opacity),
|
||||
factories[0](boundingBox.width),
|
||||
factories[1](boundingBox.height),
|
||||
factories[2](boundingBox.width),
|
||||
factories[3](boundingBox.height)
|
||||
);
|
||||
},
|
||||
function (stops, opacity) {
|
||||
return new LinearGradientGenerator(stopsOpacity(stops, opacity), ...gradientProps);
|
||||
(stops, opacity) => {
|
||||
return new LinearGradientGenerator(stopsOpacity(stops, opacity), ...[x1, y1, x2, y2]);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user