stroke.js 815 B

123456789101112131415161718
  1. import { ObjectExt } from '@antv/x6-common';
  2. export const stroke = {
  3. qualify: ObjectExt.isPlainObject,
  4. set(stroke, { view }) {
  5. const cell = view.cell;
  6. const options = Object.assign({}, stroke);
  7. if (cell.isEdge() && options.type === 'linearGradient') {
  8. const edgeView = view;
  9. const source = edgeView.sourcePoint;
  10. const target = edgeView.targetPoint;
  11. options.id = `gradient-${options.type}-${cell.id}`;
  12. options.attrs = Object.assign(Object.assign({}, options.attrs), { x1: source.x, y1: source.y, x2: target.x, y2: target.y, gradientUnits: 'userSpaceOnUse' });
  13. view.graph.defs.remove(options.id);
  14. }
  15. return `url(#${view.graph.defineGradient(options)})`;
  16. },
  17. };
  18. //# sourceMappingURL=stroke.js.map