Files
railwaysystem/RuoYi-Vue/ruoyi-ui/node_modules2/@antv/g6-pc/lib/util/image.js
T
2026-09-10 15:40:10 +08:00

40 lines
1.3 KiB
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.cloneGElement = void 0;
/**
* Clone group and clone the clip shapes of image shapes.
* @param group group to be cloned
* @returns cloned group with same clipped shapes of original group
*/
var cloneGElement = exports.cloneGElement = function cloneGElement(element) {
var vElement = element.clone();
_applyCloneClip(element, vElement);
return vElement;
};
/**
* Apply the clipShape for image shapes from original element to cloned one (clonedElement).
* @param element original element
* @param clonedElement cloned element of original element
*/
var _applyCloneClip = function applyCloneClip(element, clonedElement) {
var _a;
if (element.isGroup() && clonedElement.isGroup()) {
(_a = element.get('children')) === null || _a === void 0 ? void 0 : _a.forEach(function (child, i) {
var clonedChild = clonedElement.get('children')[i];
_applyCloneClip(child, clonedChild);
});
}
var type = element.get('type');
var clonedType = clonedElement.get('type');
if (type !== 'image' || clonedType !== 'image') return;
var clipShape = element.get('clipShape');
if (clipShape) {
clonedElement.setClip({
type: clipShape.get('type'),
attrs: clipShape.attr()
});
}
};