How to use the spritejs.Polygon 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 / stepExtendtion.js View on Github external
draw: function () {
      const { text, fillColor, textAttrs, shapeAttrs } = this.attr();
      this.points = this.points || shapeAttrs.points;
      this.$shape = new Polygon();
      let mergeShapeAttr = newObj({
        points: this.points,
        fillColor,
        // anchor: [0.5, 0.5],
      }, shapeAttrs);
      this.points = mergeShapeAttr.points;
      this.attr({ shapeAttrs: mergeShapeAttr });
      this.$shape.attr(mergeShapeAttr);
      this.append(this.$shape);
      addLabel.call(this, text, textAttrs)
    }
  }
github spritejs / q-charts / src / visuals / Line / index.js View on Github external
this.renderLines.forEach((line, i) => {
      let color = this.color(i)
      let areaAttrs = {
        fillColor: color,
        lineWidth: 0,
        strokeColor: 'transparent'
      }
      let cusAttrs = this.style('area')(
        areaAttrs,
        line.data.map(item => item.dataOrigin),
        i
      )
      Object.assign(areaAttrs, cusAttrs)
      if (cusAttrs !== false) {
        delete areaAttrs.opacity
        let polygon = new Polygon()
        polygon.attr(areaAttrs)
        let attrs = getAreaPoints(lines, i, { size, smooth, stack }, 'to')
        patchPoints.start.push(line.points[0].point)
        patchPoints.end.push(line.points[line.points.length - 1].point)
        polygon.attr(attrs)
        group.append(polygon)
        polygon.on('afterdraw', e => {
          setTimeout(_ => {
            removeLine(patchPoints, layer, this.attr(), 0)
          })
          if (compositeOperation) {
            layer.context.globalCompositeOperation = 'source-over'
          }
        })
        new Tween()
          .from(getAreaPoints(lines, i, { size, smooth, stack }, 'from'))