How to use the proton-engine.CrossZone 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
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
    const crossZoneBehaviour = new Proton.CrossZone(
      new Proton.RectZone(0, 0, canvas.width, canvas.height),
      "cross"
    );
    emitter.addBehaviour(crossZoneBehaviour);
    this.repulsion = new Proton.Repulsion(
      {
        x: canvas.width / 2,
        y: canvas.height / 2 - 100
      },
      3,
      300
    );

    this.attraction = new Proton.Attraction(
      {
        x: canvas.width / 2,
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;
      emitter.p.y = canvas.height / 2;
      emitter.emit("once");

      this.proton.addEmitter(emitter);
      this.proton.addRenderer(this.createRenderer(canvas));
      this.crossZoneBehaviour = crossZoneBehaviour;
    }
  }, {
github lindelof / particles-bg / src / particles / Tadpole.jsx View on Github external
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"
    );
    emitter.addBehaviour(new Proton.Color(this.props.color || "#bbb"));
    //emitter.addBehaviour(new Proton.Alpha(new Proton.Span(0.5, 1)));
    emitter.addBehaviour(attractionBehaviour, crossZoneBehaviour);
    emitter.addBehaviour(new Proton.RandomDrift(15, 15, 0.05));
    emitter.emit("once");

    this.proton.addEmitter(emitter);
    this.proton.addRenderer(this.createRenderer(canvas));
    this.crossZoneBehaviour = crossZoneBehaviour;
  }
github lindelof / particles-bg / src / particles / Square.jsx View on Github external
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)
      )
    );

    const dis = 150;
    const 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);
    const renderer = this.createRenderer(canvas);
    this.proton.addRenderer(renderer);
github drawcall / Proton / source / src / components / particles / Lines.jsx View on Github external
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
    };

    const attractionBehaviour = new Proton.Attraction(mouseObj, 0, 0);
    const 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;
    emitter.p.y = canvas.height / 2;
    emitter.emit("once");

    this.proton.addEmitter(emitter);
    this.proton.addRenderer(this.createRenderer(canvas));
    this.crossZoneBehaviour = crossZoneBehaviour;
  }
github drawcall / Proton / source / src / components / particles / Cobweb.jsx View on Github external
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"
      )
    );

    emitter.addBehaviour(new Proton.Alpha(Proton.getSpan(0.2, 0.9)));
    emitter.addBehaviour(new Proton.Color("#ffffff"));
    this.crossZoneBehaviour = new Proton.CrossZone(
      new Proton.RectZone(0, 0, width, height),
      "cross"
    );
    emitter.addBehaviour(this.crossZoneBehaviour);

    emitter.emit("once");
    emitter.damping = 0;
    this.proton.addEmitter(emitter);
    this.proton.addRenderer(this.createRenderer(canvas, emitter));
  }
github lindelof / particles-bg / dist / index.es.js View on Github external
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(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));

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

      emitter.addBehaviour(new Proton.Alpha(Proton.getSpan(0.2, 0.9)));
      emitter.addBehaviour(new Proton.Color(this.props.color || "#333"));
      this.crossZoneBehaviour = new Proton.CrossZone(new Proton.RectZone(0, 0, width, height), "cross");
      emitter.addBehaviour(this.crossZoneBehaviour);

      emitter.emit("once");
      emitter.damping = 0;
      this.proton.addEmitter(emitter);
      this.proton.addRenderer(this.createRenderer(canvas, emitter));
    }
  }, {
github lindelof / particles-bg / src / particles / Polygon.jsx View on Github external
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 drawcall / Proton / source / src / components / particles / Circle.jsx View on Github external
emitter.addInitialize(new Proton.Mass(1));
    emitter.addInitialize(new Proton.Radius(30, 600));
    emitter.addInitialize(
      new Proton.Velocity(
        new Proton.Span(0.5),
        new Proton.Span(0, 360),
        "polar"
      )
    );
    emitter.addInitialize(
      new Proton.Position(
        new Proton.RectZone(0, 0, canvas.width, canvas.height)
      )
    );

    const crossZoneBehaviour = new Proton.CrossZone(
      new Proton.RectZone(0, 0, canvas.width, canvas.height),
      "cross"
    );
    emitter.addBehaviour(crossZoneBehaviour);
    emitter.addBehaviour(new Proton.Alpha(Proton.getSpan(0.35, 0.55)));
    emitter.addBehaviour(new Proton.Color(this.colors, "random"));
    emitter.addBehaviour(new Proton.RandomDrift(50, 50, 0.5));

    emitter.emit("once");
    this.proton.addEmitter(emitter);

    const renderer = new Proton.CanvasRenderer(canvas);
    this.proton.addRenderer(renderer);

    this.crossZoneBehaviour = crossZoneBehaviour;
  }
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;
    }
  }, {