How to use the spritejs.Triangle function in spritejs

To help you get started, we’ve selected a few spritejs 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 spritejs / sprite-workflow / src / linkExtendtion.js View on Github external
polyline: function () { // 折线连ζŽ₯
      this.$line = new Polyline();
      this.$arrow = new Triangle();
      const { startPoint, endPoint, text, textAttrs, lineAttrs } = this.attr();
      const { lineWidth = 1 } = lineAttrs;
      let insertPoint = [ endPoint[ 0 ], startPoint[ 1 ] ];
      if (Math.abs(endPoint[ 1 ] - startPoint[ 1 ]) < Math.abs(endPoint[ 0 ] - startPoint[ 0 ])) {
        insertPoint = [ startPoint[ 0 ], endPoint[ 1 ] ];
      }
      let lineEndPoint = getPointByDistance(endPoint, insertPoint, lineWidth)
      let mergeLinkAttrs = newObj({ lineWidth: 1, color: '#eee', bgcolor: '#f00' }, lineAttrs, { points: [ startPoint, insertPoint, lineEndPoint ] });
      this.$line.attr(mergeLinkAttrs);
      this.$arrow.attr({ color: mergeLinkAttrs.color, pos: [ endPoint ], sides: [ 8 + lineWidth, 8 + lineWidth ], angle: 45, fillColor: mergeLinkAttrs.color });
      this.append(this.$line);
      this.append(this.$arrow);
      if (getType(text) === 'string') {
        this.$label = new Label(text);
        this.$label.attr(newObj({}, textAttrs, { anchor: [ 0.5, 0.5 ], clipOverflow: false }))
        this.append(this.$label);