| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- "use strict";
- 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;
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.Image = void 0;
- const g_1 = require("@antv/g");
- const utils_1 = require("../utils");
- const selection_1 = require("../../utils/selection");
- const utils_2 = require("../../mark/utils");
- const Image = (options) => {
- const style = __rest(options, []);
- return (points, value, coordinate, theme) => {
- const { mark, shape, defaultShape } = value;
- const _a = (0, utils_1.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' ? (0, utils_2.p)(width) * w : width;
- height = typeof height === 'string' ? (0, utils_2.p)(height) * h : height;
- const x = x0 - Number(width) / 2;
- const y = y0 - Number(height) / 2;
- return (0, selection_1.select)(new g_1.Image())
- .call(utils_1.applyStyle, shapeTheme)
- .style('x', x)
- .style('y', y)
- .style('img', src)
- .style('stroke', color)
- .style('transform', transform)
- .call(utils_1.applyStyle, style)
- .style('width', width)
- .style('height', height)
- .node();
- };
- };
- exports.Image = Image;
- exports.Image.props = {
- defaultEnterAnimation: 'fadeIn',
- defaultUpdateAnimation: 'morphing',
- defaultExitAnimation: 'fadeOut',
- };
- //# sourceMappingURL=image.js.map
|