How to use the diagram-js/lib/util/RenderUtil.componentsToPath function in diagram-js

To help you get started, we’ve selected a few diagram-js examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bptlab / chor-js / lib / draw / ChoreoRenderer.js View on Github external
// draw the participant band
    let bandShape = svgCreate('path');
    svgAttr(bandShape, {
      d: getParticipantBandOutline(0, 0, element.width, element.height, bandKind),
      fill: isInitiating ? 'white' : 'black',
      fillOpacity: isInitiating ? 0 : NON_INITIATING_OPACITY
    });
    svgAppend(p, bandShape);
    attachMarkerToParticipant(p, element);

    // add the line(s)
    if (isTop || isMiddle) {
      let line = svgCreate('path');
      svgAttr(line, {
        d: componentsToPath([
          ['M', 0, element.height],
          ['l', element.width, 0]
        ]),
        stroke: 'black',
        strokeWidth: 2
      });
      svgAppend(p, line);
    }
    if (isBottom || isMiddle) {
      let line = svgCreate('path');
      svgAttr(line, {
        d: componentsToPath([
          ['M', 0, 0],
          ['l', element.width, 0]
        ]),
        stroke: 'black',
github bpmn-io / bpmn-js / test / integration / custom-elements / CustomRenderer.js View on Github external
this.getCirclePath = function(shape) {
    var cx = shape.x + shape.width / 2,
        cy = shape.y + shape.height / 2,
        radius = shape.width / 2;

    var circlePath = [
      ['M', cx, cy],
      ['m', 0, -radius],
      ['a', radius, radius, 0, 1, 1, 0, 2 * radius],
      ['a', radius, radius, 0, 1, 1, 0, -2 * radius],
      ['z']
    ];

    return componentsToPath(circlePath);
  };
github bpmn-io / bpmn-js / lib / draw / BpmnRenderUtil.js View on Github external
height = shape.height;

  var roundRectPath = [
    ['M', x + borderRadius, y],
    ['l', width - borderRadius * 2, 0],
    ['a', borderRadius, borderRadius, 0, 0, 1, borderRadius, borderRadius],
    ['l', 0, height - borderRadius * 2],
    ['a', borderRadius, borderRadius, 0, 0, 1, -borderRadius, borderRadius],
    ['l', borderRadius * 2 - width, 0],
    ['a', borderRadius, borderRadius, 0, 0, 1, -borderRadius, -borderRadius],
    ['l', 0, borderRadius * 2 - height],
    ['a', borderRadius, borderRadius, 0, 0, 1, borderRadius, -borderRadius],
    ['z']
  ];

  return componentsToPath(roundRectPath);
}
github camunda-consulting / code / snippets / bpmnjs-custom-modeler / app / custom-modeler / custom / CustomRenderer.js View on Github external
this.getTrianglePath = function(element) {
    var x = element.x,
        y = element.y,
        width = element.width,
        height = element.height;

    var trianglePath = [
      ['M', x + width / 2, y],
      ['l', width / 2, height],
      ['l', -width, 0 ],
      ['z']
    ];

    return componentsToPath(trianglePath);
  };
github WPS / domain-story-modeler / app / domain-story-modeler / language / DomainStoryRenderer.js View on Github external
this.getActivityPath = function(connection) {
    let waypoints = connection.waypoints.map(function(p) {
      return p.original || p;
    });

    let activityPath = [
      ['M', waypoints[0].x, waypoints[0].y]
    ];

    waypoints.forEach(function(waypoint, index) {
      if (index !== 0) {
        activityPath.push(['L', waypoint.x, waypoint.y]);
      }
    });
    return componentsToPath(activityPath);
  };
github bptlab / chor-js / lib / draw / ChoreoRenderer.js View on Github external
width += 2 * offset;
  height += 2 * offset;
  r += offset;

  let path = [
    ['M', x + r, y],
    ['a', r, r, 0, 0, 0, -r, r],
    ['l', 0, height - 2 * r],
    ['a', r, r, 0, 0, 0, r, r],
    ['l', width - 2 * r, 0],
    ['a', r, r, 0, 0, 0, r, -r],
    ['l', 0, -height + 2 * r],
    ['a', r, r, 0, 0, 0, -r, -r],
    ['z']
  ];
  return componentsToPath(path);
}
github bptlab / chor-js / lib / draw / ChoreoRenderer.js View on Github external
function getEnvelopePath(width, height) {
  let flap = height * 0.6;
  let path = [
    ['M', 0, 0],
    ['l', 0, height],
    ['l', width, 0],
    ['l', 0, -height],
    ['z'],
    ['M', 0, 0],
    ['l', width / 2., flap],
    ['l', width / 2., -flap]
  ];
  return componentsToPath(path);
}
github camunda-consulting / code / snippets / bpmnjs-custom-modeler / app / custom-modeler / custom / CustomRenderer.js View on Github external
this.getCustomConnectionPath = function(connection) {
    var waypoints = connection.waypoints.map(function(p) {
      return p.original || p;
    });

    var connectionPath = [
      ['M', waypoints[0].x, waypoints[0].y]
    ];

    waypoints.forEach(function(waypoint, index) {
      if (index !== 0) {
        connectionPath.push(['L', waypoint.x, waypoint.y]);
      }
    });

    return componentsToPath(connectionPath);
  };
}
github bptlab / chor-js / lib / draw / ChoreoRenderer.js View on Github external
function getMessageOutline(x, y, width, height) {
  let path = [
    ['M', x, y],
    ['l', 0, height],
    ['l', width, 0],
    ['l', 0, -height],
    ['z']
  ];
  return componentsToPath(path);
}
github bptlab / chor-js / lib / draw / ChoreoRenderer.js View on Github external
['l', 0, height - r],
      ['a', r, r, 0, 0, 0, r, r],
      ['l', width - 2 * r, 0],
      ['a', r, r, 0, 0, 0, r, -r],
      ['z']
    ];
  } else {
    path = [
      ['M', x, y + height],
      ['l', width, 0],
      ['l', 0, -height],
      ['l', -width, 0],
      ['z']
    ];
  }
  return componentsToPath(path);
}