How to use the proton-engine.Span function in proton-engine

To help you get started, we’ve selected a few proton-engine 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 lindelof / particles-bg / dist / index.es.js View on Github external
value: function createProton(canvas, width, height) {
      this.proton = new Proton();
      var emitter = new Proton.Emitter();
      emitter.rate = new Proton.Rate(this.props.num ? this.props.num : 50);
      emitter.damping = 0;

      emitter.addInitialize(new Proton.Mass(1));
      emitter.addInitialize(new Proton.Radius(4, 70));
      emitter.addInitialize(new Proton.Velocity(new Proton.Span(2, 10), new Proton.Span(0), "polar"));
      emitter.addInitialize(new Proton.Position(new Proton.LineZone(0, canvas.height, canvas.width, canvas.height)));

      var dis = 150;
      var crossZoneBehaviour = new Proton.CrossZone(new Proton.RectZone(0 - dis, 0 - dis, canvas.width + 2 * dis, canvas.height + 2 * dis), "cross");
      emitter.addBehaviour(crossZoneBehaviour);
      emitter.addBehaviour(new Proton.Alpha(Proton.getSpan(0.1, 0.55)));
      emitter.addBehaviour(new Proton.Color(this.colors));

      emitter.emit("once");
      this.proton.addEmitter(emitter);
      var renderer = this.createRenderer(canvas);
      this.proton.addRenderer(renderer);

      this.crossZoneBehaviour = crossZoneBehaviour;
      emitter.preEmit(2);
    }
github lindelof / particles-bg / src / particles / Color.jsx View on Github external
createProton(canvas, width, height) {
    this.proton = new Proton();
    const emitter = new Proton.Emitter();
    emitter.rate = new Proton.Rate(
      this.props.num ? new Proton.Span(this.props.num) : new Proton.Span(5, 8),
      new Proton.Span(0.1, 0.25)
    );

    emitter.addInitialize(new Proton.Mass(1));
    emitter.addInitialize(new Proton.Radius(20, 200));
    emitter.addInitialize(new Proton.Life(2, 4));
    emitter.addInitialize(
      new Proton.Position(new Proton.RectZone(0, 0, width, height))
    );

    emitter.addBehaviour(new Proton.Alpha(0, 1, Infinity, Proton.easeOutCubic));
    emitter.addBehaviour(new Proton.Scale(1, 0, Infinity, Proton.easeOutCubic));
    emitter.addBehaviour(new Proton.Color(this.colors, "random"));

    emitter.emit();
    this.proton.addEmitter(emitter);
github lindelof / particles-bg / dist / index.es.js View on Github external
radius = _ref.radius,
          _ref$color = _ref.color,
          color = _ref$color === undefined ? COLOR : _ref$color,
          _ref$zone = _ref.zone,
          zone = _ref$zone === undefined ? "dead" : _ref$zone,
          _ref$once = _ref.once,
          once = _ref$once === undefined ? "all" : _ref$once,
          _ref$alpha = _ref.alpha,
          alpha = _ref$alpha === undefined ? 0.85 : _ref$alpha,
          _ref$gravity = _ref.gravity,
          gravity = _ref$gravity === undefined ? 3.5 : _ref$gravity;

      var emitter = this.proton.pool.get(Proton.Emitter);

      if (!emitter.completed) {
        emitter.rate = new Proton.Rate(this.props.num ? new Proton.Span(this.props.num) : new Proton.Span(4, 9), new Proton.Span(1.6, 2.2));

        var radiusInit = mainEmitter ? new Proton.Radius(10, 110) : new Proton.Radius(3, radius);
        emitter.addInitialize(new Proton.Mass(1));
        emitter.addInitialize(radiusInit);
        emitter.addInitialize(new Proton.Life(3, 6));
        emitter.addInitialize(new Proton.Velocity(new Proton.Span(4, 6), new Proton.Span(-90, 90), "polar"));

        emitter.addBehaviour(new Proton.Alpha(alpha, 0.2));
        emitter.addBehaviour(new Proton.Color(color));
        emitter.addBehaviour(new Proton.Scale(1, 0.3));
        emitter.addBehaviour(new Proton.Rotate());
        emitter.addBehaviour(new Proton.Gravity(gravity));

        emitter.addBehaviour(this.customDeadBehaviour(canvas));
        emitter.addBehaviour(new Proton.CrossZone(new Proton.RectZone(0, 0, canvas.width, canvas.height), zone));
      }
github lindelof / particles-bg / src / particles / Polygon.jsx View on Github external
canvas,
    x,
    y,
    radius,
    color = COLOR,
    zone = "dead",
    once = "all",
    alpha = 0.85,
    gravity = 3.5
  }) {
    const emitter = this.proton.pool.get(Proton.Emitter);

    if (!emitter.completed) {
      emitter.rate = new Proton.Rate(
        this.props.num ? new Proton.Span(this.props.num) : new Proton.Span(4, 9),
        new Proton.Span(1.6, 2.2)
      );

      const radiusInit = mainEmitter
        ? new Proton.Radius(10, 110)
        : new Proton.Radius(3, radius);
      emitter.addInitialize(new Proton.Mass(1));
      emitter.addInitialize(radiusInit);
      emitter.addInitialize(new Proton.Life(3, 6));
      emitter.addInitialize(
        new Proton.Velocity(
          new Proton.Span(4, 6),
          new Proton.Span(-90, 90),
          "polar"
        )
      );
github lindelof / particles-bg / src / particles / Ball.jsx View on Github external
const context = canvas.getContext("2d");
    this.proton = new Proton();

    const emitter = new Proton.Emitter();
    emitter.rate = new Proton.Rate(
      this.props.num ? new Proton.Span(this.props.num) : new Proton.Span(4, 9),
      new Proton.Span(0.8, 1.3)
    );

    emitter.addInitialize(new Proton.Mass(1));
    emitter.addInitialize(new Proton.Radius(1, 50));
    emitter.addInitialize(new Proton.Life(5, 6));
    emitter.addInitialize(
      new Proton.Velocity(
        new Proton.Span(5, 8),
        new Proton.Span(30, 70),
        "polar"
      )
    );

    emitter.addBehaviour(new Proton.Alpha(1, 0));
    emitter.addBehaviour(
      new Proton.Color(["#36aaf3", "#fd769c", "#94ff22", "#ffa545", "#ffffff"])
    );
    emitter.addBehaviour(new Proton.Scale(0.7, 1));
    emitter.addBehaviour(new Proton.Gravity(3));
    emitter.addBehaviour(new Proton.Collision(emitter));
    emitter.addBehaviour(this.customDeadBehaviour(canvas));
    emitter.addBehaviour(
      new Proton.CrossZone(
        new Proton.RectZone(0, 0, canvas.width, canvas.height),
        "bound"
github lindelof / particles-bg / src / particles / Ball.jsx View on Github external
createMiniEmitter(canvas) {
    const miniEmitter = new Proton.Emitter();
    miniEmitter.rate = new Proton.Rate(
      new Proton.Span(3, 6),
      new Proton.Span(1, 2)
    );

    miniEmitter.addInitialize(new Proton.Mass(1));
    miniEmitter.radiusInitialize = new Proton.Radius();
    miniEmitter.addInitialize(miniEmitter.radiusInitialize);
    miniEmitter.addInitialize(new Proton.Life(0.5, 1));
    miniEmitter.addInitialize(
      new Proton.V(
        new Proton.Span(1.5, 3),
        new Proton.Span(0, 70, true),
        "polar"
      )
    );

    miniEmitter.colorBehaviour = new Proton.Color("#ffffff");
github lindelof / particles-bg / src / particles / Polygon.jsx View on Github external
mainEmitter,
    canvas,
    x,
    y,
    radius,
    color = COLOR,
    zone = "dead",
    once = "all",
    alpha = 0.85,
    gravity = 3.5
  }) {
    const emitter = this.proton.pool.get(Proton.Emitter);

    if (!emitter.completed) {
      emitter.rate = new Proton.Rate(
        this.props.num ? new Proton.Span(this.props.num) : new Proton.Span(4, 9),
        new Proton.Span(1.6, 2.2)
      );

      const radiusInit = mainEmitter
        ? new Proton.Radius(10, 110)
        : new Proton.Radius(3, radius);
      emitter.addInitialize(new Proton.Mass(1));
      emitter.addInitialize(radiusInit);
      emitter.addInitialize(new Proton.Life(3, 6));
      emitter.addInitialize(
        new Proton.Velocity(
          new Proton.Span(4, 6),
          new Proton.Span(-90, 90),
          "polar"
        )
      );
github lindelof / particles-bg / src / particles / Tadpole.jsx View on Github external
createProton(canvas, width, height) {
    this.proton = new Proton();

    const emitter = new Proton.Emitter();
    emitter.damping = 0.008;
    emitter.rate = new Proton.Rate(this.props.num ? this.props.num : 50);
    emitter.addInitialize(new Proton.Mass(1));
    emitter.addInitialize(new Proton.Radius(5, 9));
    emitter.addInitialize(
      new Proton.Velocity(
        new Proton.Span(1.5),
        new Proton.Span(0, 360),
        "polar"
      )
    );
    emitter.addInitialize(
      new Proton.Position(new Proton.RectZone(0, 0, width, height))
    );

    const mouseInfo = {
      x: width / 2,
      y: height / 2
    };

    const attractionBehaviour = new Proton.Attraction(mouseInfo, 0, 0);
    const crossZoneBehaviour = new Proton.CrossZone(
      new Proton.RectZone(0, 0, canvas.width, canvas.height),
      "bound"
github drawcall / Proton / source / src / components / particles / Cobweb.jsx View on Github external
createProton(canvas, width, height) {
    this.proton = new Proton();

    const emitter = new Proton.Emitter();
    emitter.rate = new Proton.Rate(
      new Proton.Span(100),
      new Proton.Span(0.05, 0.2)
    );

    emitter.addInitialize(new Proton.Mass(1));
    emitter.addInitialize(new Proton.Radius(1, 4));
    emitter.addInitialize(new Proton.Life(Infinity));

    const pointZone = new Proton.Position(
      new Proton.RectZone(0, 0, width, height)
    );
    emitter.addInitialize(pointZone);
    emitter.addInitialize(
      new Proton.Velocity(
        new Proton.Span(0.3, 0.6),
        new Proton.Span(0, 360),
        "polar"