1 | import { __assign } from "tslib";
|
2 | import { jsx } from '@antv/f-engine';
|
3 | import { deepMix } from '@antv/util';
|
4 | export default (function (props, context) {
|
5 | var _a = props.theme,
|
6 | theme = _a === void 0 ? {} : _a;
|
7 | var _b = deepMix(__assign({}, theme.rect), props),
|
8 | points = _b.points,
|
9 | style = _b.style,
|
10 | animation = _b.animation,
|
11 | offsetX = _b.offsetX,
|
12 | offsetY = _b.offsetY;
|
13 | var checkNaN = points.some(function (d) {
|
14 | return isNaN(d.x) || isNaN(d.y);
|
15 | });
|
16 | if (checkNaN) return null;
|
17 | var start = points[0] || {};
|
18 | var end = points[1] || {};
|
19 | var offsetXNum = context.px2hd(offsetX);
|
20 | var offsetYNum = context.px2hd(offsetY);
|
21 | var posX = Math.min(start.x, end.x) + (offsetXNum || 0);
|
22 | var posY = Math.min(start.y, end.y) + (offsetYNum || 0);
|
23 | return jsx("group", null, jsx("rect", {
|
24 | style: __assign({
|
25 | x: posX,
|
26 | y: posY,
|
27 | width: Math.abs(end.x - start.x),
|
28 | height: Math.abs(start.y - end.y)
|
29 | }, style),
|
30 | animation: animation
|
31 | }));
|
32 | }); |
\ | No newline at end of file |