react-native-image-filter-kit
Version:
Various image filters for iOS & Android
33 lines • 2.28 kB
JavaScript
var __rest = (this && this.__rest) || function (s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)
t[p[i]] = s[p[i]];
return t;
};
import invariant from 'invariant';
import { isUnit, unitSupplement } from '../common/util';
export const shapeTransforms = {
ColorGenerator: (config) => (Object.assign({}, config, { name: 'Color' })),
LinearGradientGenerator: (_a) => {
var { colors = ['red', 'blue'], stops = [0, 1], start = { x: 0, y: '0h' }, end = { x: '100w', y: '0h' } } = _a, config = __rest(_a, ["colors", "stops", "start", "end"]);
invariant(isUnit(start.y) && isUnit(end.y), `ImageFilterKit: LinearGradientGenerator props 'start.y' and 'end.y' should have measure ` +
`units.`);
return Object.assign({}, config, { name: 'LinearGradient', colors, locations: stops, x0: start.x, y0: unitSupplement(start.y), x1: end.x, y1: unitSupplement(end.y) });
},
RadialGradientGenerator: (_a) => {
var { colors = ['red', 'blue'], stops = [0, 1], center = { x: '50w', y: '50h' }, radius = '50min' } = _a, config = __rest(_a, ["colors", "stops", "center", "radius"]);
invariant(isUnit(center.y), `ImageFilterKit: RadialGradientGenerator props 'center.y' should have measure unit.`);
return Object.assign({}, config, { name: 'RadialGradient', colors,
stops,
radius, centerX: center.x, centerY: unitSupplement(center.y) });
},
SweepGradientGenerator: (_a) => {
var { colors = ['red', 'blue'], stops = [0, 1], center = { x: '50w', y: '50h' } } = _a, config = __rest(_a, ["colors", "stops", "center"]);
invariant(isUnit(center.y), `ImageFilterKit: SweepGradientGenerator props 'center.y' should have measure unit.`);
return Object.assign({}, config, { name: 'SweepGradient', colors: Array.from(colors).reverse(), positions: stops.map(stop => 1 - stop).reverse(), centerX: center.x, centerY: unitSupplement(center.y) });
}
};
//# sourceMappingURL=shape-transforms.android.js.map