How to use the proton-engine.Emitter 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 drawcall / Proton / source / src / components / particles / Thick.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(150);

    // Initialize
    emitter.addInitialize(new Proton.Mass(1));
    emitter.addInitialize(new Proton.Radius(8));
    emitter.addInitialize(
      new Proton.V(new Proton.Span(0.1, 0.5), new Proton.Span(0, 360), "polar")
    );
    emitter.addInitialize(
      new Proton.Position(
        new Proton.CircleZone(canvas.width / 2, canvas.height / 2, 100)
      )
    );

    // Behaviour
github lindelof / particles-bg / src / particles / Thick.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 : 150);

    // Initialize
    emitter.addInitialize(new Proton.Mass(1));
    emitter.addInitialize(new Proton.Radius(8));
    emitter.addInitialize(
      new Proton.V(new Proton.Span(0.1, 0.5), new Proton.Span(0, 360), "polar")
    );
    emitter.addInitialize(
      new Proton.Position(
        new Proton.CircleZone(canvas.width / 2, canvas.height / 2, 100)
      )
    );

    // Behaviour
github lindelof / particles-bg / src / particles / Lines.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 : 250);
    emitter.addInitialize(new Proton.Mass(1));
    emitter.addInitialize(new Proton.Radius(4));
    emitter.addInitialize(
      new Proton.Velocity(
        new Proton.Span(1.5),
        new Proton.Span(0, 360),
        "polar"
      )
    );
    const mouseObj = {
      x: width / 2,
      y: height / 2
    };
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 = {
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"));
github lindelof / particles-bg / src / particles / Ball.jsx View on Github external
createProton(canvas, width, height) {
    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"
      )
    );
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"
      )
    );
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.damping = 0.008;
      emitter.rate = new Proton.Rate(this.props.num ? this.props.num : 250);
      emitter.addInitialize(new Proton.Mass(1));
      emitter.addInitialize(new Proton.Radius(4));
      emitter.addInitialize(new Proton.Velocity(new Proton.Span(1.5), new Proton.Span(0, 360), "polar"));
      var mouseObj = {
        x: width / 2,
        y: height / 2
      };

      var attractionBehaviour = new Proton.Attraction(mouseObj, 0, 0);
      var crossZoneBehaviour = new Proton.CrossZone(new Proton.RectZone(0, 0, canvas.width, canvas.height), "cross");
      emitter.addBehaviour(new Proton.Color("random"));
      emitter.addBehaviour(attractionBehaviour, crossZoneBehaviour);
      emitter.addBehaviour(new Proton.RandomDrift(10, 10, 0.05));
      emitter.p.x = canvas.width / 2;
github lindelof / particles-bg / src / particles / Custom.jsx View on Github external
const alpha = this.getArrProp("alpha");
        const scale = this.getArrProp("scale");
        const color = this.getArrProp("color");
        const cross = this.getProp("cross", "dead");
        const random = this.getProp("random");
        const rotate = this.getArrProp("rotate");
        const g = this.getProp("g");
        const f = this.getArrProp("f");
        const emitterV = this.getProp("emitter");

        this.proton = new Proton();
        let emitter;
        if (emitterV === "follow") {
            emitter = new Proton.FollowEmitter();
        } else {
            emitter = new Proton.Emitter();
        }
        emitter.rate = new Proton.Rate(num, rps);

        emitter.addInitialize(new Proton.Mass(mass));
        emitter.addInitialize(new Proton.Radius(radius));
        emitter.addInitialize(new Proton.Life(life));
        emitter.addInitialize(new Proton.Velocity(v, tha, "polar"));
        if (body) emitter.addInitialize(new Proton.Body(body));

        let pos;
        if (position === "all" || position === "screen") {
            pos = new Proton.Position(new Proton.RectZone(0, 0, canvas.width, canvas.height))
        } else if (typeof position === "object") {
            pos = new Proton.Position(new Proton.RectZone(position.x, position.y, position.width, position.height))
        } else {
            emitter.p.x = canvas.width / 2;