How to use the proton-engine.Gravity 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 / src / particles / Polygon.jsx View on Github external
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
        )
      );
    }

    emitter.p.x = x;
    emitter.p.y = y;
    if (once === "once") emitter.emit("once");
    else emitter.emit();

    this.proton.addEmitter(emitter);
github lindelof / particles-bg / dist / index.es.js View on Github external
var context = canvas.getContext("2d");
      this.proton = new Proton();

      var 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"));

      emitter.p.x = Math.min(500, Math.max(canvas.width / 2 - 400, 50));
      emitter.p.y = canvas.height / 2 + 50;
      emitter.emit();
      this.proton.addEmitter(emitter);

      var renderer = new Proton.CanvasRenderer(canvas);
      renderer.onProtonUpdate = function () {
        context.fillStyle = getColor(_this2.props.color, 0.2) || "rgba(255, 255, 255, 0.2)";
        context.fillRect(0, 0, canvas.width, canvas.height);
      };
      this.proton.addRenderer(renderer);
    }
github lindelof / particles-bg / src / particles / Ball.jsx View on Github external
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"
      )
    );

    emitter.p.x = Math.min(500, Math.max(canvas.width / 2 - 400, 50));
    emitter.p.y = canvas.height / 2 + 50;
    emitter.emit();
    this.proton.addEmitter(emitter);

    const renderer = new Proton.CanvasRenderer(canvas);
    renderer.onProtonUpdate =  ()=> {
github lindelof / particles-bg / dist / index.es.js View on Github external
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));
      }

      emitter.p.x = x;
      emitter.p.y = y;
      if (once === "once") emitter.emit("once");else emitter.emit();

      this.proton.addEmitter(emitter);
      //this.expireEmitter(emitter);
    }
  }, {
github lindelof / particles-bg / src / particles / Ball.jsx View on Github external
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");
    miniEmitter.addBehaviour(new Proton.Alpha(1, 0));
    miniEmitter.addBehaviour(miniEmitter.colorBehaviour);
    miniEmitter.addBehaviour(new Proton.Gravity(4));
    miniEmitter.addBehaviour(new Proton.Collision(miniEmitter));
    miniEmitter.addBehaviour(
      new Proton.CrossZone(
        new Proton.RectZone(0, 0, canvas.width, canvas.height),
        "bound"
      )
    );
    this.proton.addEmitter(miniEmitter);

    this.miniEmitter = miniEmitter;
  }
github lindelof / particles-bg / dist / index.es.js View on Github external
value: function createMiniEmitter(canvas) {
      var 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");
      miniEmitter.addBehaviour(new Proton.Alpha(1, 0));
      miniEmitter.addBehaviour(miniEmitter.colorBehaviour);
      miniEmitter.addBehaviour(new Proton.Gravity(4));
      miniEmitter.addBehaviour(new Proton.Collision(miniEmitter));
      miniEmitter.addBehaviour(new Proton.CrossZone(new Proton.RectZone(0, 0, canvas.width, canvas.height), "bound"));
      this.proton.addEmitter(miniEmitter);

      this.miniEmitter = miniEmitter;
    }
  }, {