How to use the snapsvg.Matrix function in snapsvg

To help you get started, we’ve selected a few snapsvg 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 fralonra / lottery-wheel / src / index.js View on Github external
let textSum = 0 // a-z0-9 为 1,其他为 2
      for (let i = 0; i < d.text.length; ++i) {
        if (d.text[i].match(/\w/)) {
          textSum += 1
        } else textSum += 2
      }
      if (!opt.fontSize && !d.fontSize) {
        fontSize = fontSize * textSum / 2 > dLen * opt.textBottomPercentage ? dLen * opt.textBottomPercentage / textSum * 2 : fontSize
      }
      const text = svg.text(opt.center[0], opt.pos[1] + opt.radius - (r * opt.textBottomPercentage * Snap.cos(self[deg] / 2)) - fontSize, d.text)
      text.attr({
        fill: d.fontColor ? d.fontColor : opt.color.prizeFont,
        fontSize: opt.fontSize ? opt.fontSize : fontSize
      })
      const box = text.node.getBoundingClientRect()
      text.transform(new Snap.Matrix().translate(-Math.round(box.width / 2), 2))

      const g = svg.g(pie, text).transform(new Snap.Matrix().rotate(self[deg] * Number(i), opt.center[0], opt.center[1]))
      self[turntable].add(g)
    }
  }
github microsoft / PowerBI-visuals-ClusterMap / lib / @uncharted / personas / src / personas.persona.js View on Github external
Persona.prototype.onEnter = function() {
    if (this.mShouldPopIn) {
        this.mShouldPopIn = false;
        this.mContainer.attr({display: 'block'});
        this.mContainer.scale = 0.1;
        this.mContainer.animate({transform: new Snap.Matrix()}, this.mPersonaOptions.config.transitionsDuration, mina.backout);
    }

    /* if this persona was set to be out of visual focus before it was added to the paper, apply the filter */
    if (!this.mInVisualFocus) {
        this._applyVisualFilter(1);
    }
};
github fralonra / lottery-wheel / src / index.js View on Github external
let textSum = 0
      for (let i = 0; i < opt.buttonText.length; ++i) {
        if (opt.buttonText[i].match(/\w/)) {
          textSum += 1
        } else textSum += 2
      }
      if (!opt.buttonFontSize) {
        fontSize = fontSize * textSum / 2 > maxLen ? maxLen / textSum * 2 : fontSize
      }
      text = svg.text(center[0], center[1], opt.buttonText)
      text.attr({
        fill: opt.color.buttonFont,
        fontSize: opt.buttonFontSize ? opt.buttonFontSize : fontSize
      })
      const box = text.node.getBoundingClientRect()
      text.transform(new Snap.Matrix().translate(-Math.round(box.width / 2), 2))
    }

    self[button] = svg.g(b, text)
  }
github microsoft / PowerBI-visuals-ClusterMap / lib / @uncharted / personas / src / personas.core.node.js View on Github external
Node.prototype._setScale = function (scale) {
    if (scale !== this.mScale) {
        this.mScale = scale;
        var matrix = new Snap.Matrix();
        matrix.e = this.mPosition.x;
        matrix.f = this.mPosition.y;
        matrix.scale(scale);
        this.transform(matrix);
    }
};
github fralonra / lottery-wheel / src / index.js View on Github external
if (d.text[i].match(/\w/)) {
          textSum += 1
        } else textSum += 2
      }
      if (!opt.fontSize && !d.fontSize) {
        fontSize = fontSize * textSum / 2 > dLen * opt.textBottomPercentage ? dLen * opt.textBottomPercentage / textSum * 2 : fontSize
      }
      const text = svg.text(opt.center[0], opt.pos[1] + opt.radius - (r * opt.textBottomPercentage * Snap.cos(self[deg] / 2)) - fontSize, d.text)
      text.attr({
        fill: d.fontColor ? d.fontColor : opt.color.prizeFont,
        fontSize: opt.fontSize ? opt.fontSize : fontSize
      })
      const box = text.node.getBoundingClientRect()
      text.transform(new Snap.Matrix().translate(-Math.round(box.width / 2), 2))

      const g = svg.g(pie, text).transform(new Snap.Matrix().rotate(self[deg] * Number(i), opt.center[0], opt.center[1]))
      self[turntable].add(g)
    }
  }

snapsvg

JavaScript Vector Library

Apache-2.0
Latest version published 8 years ago

Package Health Score

58 / 100
Full package analysis

Similar packages