UNPKG

@antv/x6

Version:

JavaScript diagramming library that uses SVG and HTML for rendering

55 lines 2.28 kB
"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.classic = exports.block = void 0; const x6_geometry_1 = require("@antv/x6-geometry"); const x6_common_1 = require("@antv/x6-common"); const util_1 = require("./util"); const block = (_a) => { var { size, width, height, offset, open } = _a, attrs = __rest(_a, ["size", "width", "height", "offset", "open"]); return createClassicMarker({ size, width, height, offset }, open === true, true, undefined, attrs); }; exports.block = block; const classic = (_a) => { var { size, width, height, offset, factor } = _a, attrs = __rest(_a, ["size", "width", "height", "offset", "factor"]); return createClassicMarker({ size, width, height, offset }, false, false, factor, attrs); }; exports.classic = classic; function createClassicMarker(options, open, full, factor = 3 / 4, attrs = {}) { const size = options.size || 10; const width = options.width || size; const height = options.height || size; const path = new x6_geometry_1.Path(); const localAttrs = {}; if (open) { path .moveTo(width, 0) .lineTo(0, height / 2) .lineTo(width, height); localAttrs.fill = 'none'; } else { path.moveTo(0, height / 2); path.lineTo(width, 0); if (!full) { const f = x6_common_1.NumberExt.clamp(factor, 0, 1); path.lineTo(width * f, height / 2); } path.lineTo(width, height); path.close(); } return Object.assign(Object.assign(Object.assign({}, localAttrs), attrs), { tagName: 'path', d: (0, util_1.normalize)(path.serialize(), { x: options.offset != null ? options.offset : -width / 2, }) }); } //# sourceMappingURL=classic.js.map