| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- 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 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
- t[p[i]] = s[p[i]];
- }
- return t;
- };
- import { Image as GImage } from '@antv/g';
- import { applyStyle, getShapeTheme } from '../utils';
- import { select } from '../../utils/selection';
- import { p } from '../../mark/utils';
- export const Image = (options) => {
- const style = __rest(options, []);
- return (points, value, coordinate, theme) => {
- const { mark, shape, defaultShape } = value;
- const _a = getShapeTheme(theme, mark, shape, defaultShape), { defaultColor } = _a, shapeTheme = __rest(_a, ["defaultColor"]);
- const { color = defaultColor, src = '', size = 32, transform = '' } = value;
- let { width = size, height = size } = style;
- const [[x0, y0]] = points;
- // Support percentage width, height.
- const [w, h] = coordinate.getSize();
- width = typeof width === 'string' ? p(width) * w : width;
- height = typeof height === 'string' ? p(height) * h : height;
- const x = x0 - Number(width) / 2;
- const y = y0 - Number(height) / 2;
- return select(new GImage())
- .call(applyStyle, shapeTheme)
- .style('x', x)
- .style('y', y)
- .style('img', src)
- .style('stroke', color)
- .style('transform', transform)
- .call(applyStyle, style)
- .style('width', width)
- .style('height', height)
- .node();
- };
- };
- Image.props = {
- defaultEnterAnimation: 'fadeIn',
- defaultUpdateAnimation: 'morphing',
- defaultExitAnimation: 'fadeOut',
- };
- //# sourceMappingURL=image.js.map
|