How to use the proton-engine.Color 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
var pos = void 0;
            if (position === "all" || position === "screen") {
                pos = new Proton.Position(new Proton.RectZone(0, 0, canvas.width, canvas.height));
            } else if ((typeof position === "undefined" ? "undefined" : _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;
                emitter.p.y = canvas.height / 2;
            }

            emitter.addInitialize(pos);

            /// behaviour
            var alphaB = alpha ? new Proton.Alpha(alpha[0], alpha[1]) : new Proton.Alpha(0, 1);
            var scaleB = scale ? new Proton.Scale(scale[0], scale[1]) : new Proton.Scale(1, 0.2);
            var colorB = color ? new Proton.Color(color[0], color[1]) : new Proton.Color(this.colors);

            emitter.addBehaviour(alphaB);
            emitter.addBehaviour(scaleB);
            if (!body) emitter.addBehaviour(colorB);

            if (rotate) {
                if (rotate[0] === true || rotate[0] === "rotate") {
                    emitter.addBehaviour(new Proton.Rotate());
                } else {
                    emitter.addBehaviour(new Proton.Rotate(rotate[0], rotate[1]));
                }
            }

            var zone = new Proton.RectZone(0, 0, canvas.width, canvas.height);
            var crossZoneBehaviour = new Proton.CrossZone(zone, cross);
            emitter.addBehaviour(crossZoneBehaviour);
github lindelof / particles-bg / src / particles / Custom.jsx View on Github external
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;
            emitter.p.y = canvas.height / 2;
        }

        emitter.addInitialize(pos);

        /// behaviour
        const alphaB = alpha ? new Proton.Alpha(alpha[0], alpha[1]) : new Proton.Alpha(0, 1);
        const scaleB = scale ? new Proton.Scale(scale[0], scale[1]) : new Proton.Scale(1, 0.2);
        const colorB = color ? new Proton.Color(color[0], color[1]) : new Proton.Color(this.colors);

        emitter.addBehaviour(alphaB);
        emitter.addBehaviour(scaleB);
        if(!body) emitter.addBehaviour(colorB);

        if(rotate){
            if(rotate[0]===true||rotate[0]==="rotate"){
                emitter.addBehaviour(new Proton.Rotate());
            }else{
                emitter.addBehaviour(new Proton.Rotate(rotate[0], rotate[1]));
            }
        }

        const zone = new Proton.RectZone(0, 0, canvas.width, canvas.height)
        const crossZoneBehaviour = new Proton.CrossZone(zone, cross);
        emitter.addBehaviour(crossZoneBehaviour);
github lindelof / particles-bg / dist / index.es.js View on Github external
_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));
      }

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

    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);
github lindelof / particles-bg / src / particles / Thick.jsx View on Github external
y: canvas.height / 2 - 100
      },
      3,
      300
    );

    this.attraction = new Proton.Attraction(
      {
        x: canvas.width / 2,
        y: canvas.height / 2
      },
      3,
      200
    );
    emitter.addBehaviour(this.attraction, this.repulsion);
    emitter.addBehaviour(new Proton.Color("random"));
    emitter.addBehaviour(new Proton.RandomDrift(20, 15, 0.15));

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

      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");
github drawcall / Proton / source / src / components / particles / Circle.jsx View on Github external
"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 createProton(canvas, width, height) {
      this.proton = new Proton();

      var emitter = new Proton.Emitter();
      emitter.rate = new Proton.Rate(this.props.num || 20);
      emitter.damping = 0.008;

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

      var 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.getColor()));
      emitter.addBehaviour(new Proton.RandomDrift(50, 50, 0.5));

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

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

      this.crossZoneBehaviour = crossZoneBehaviour;
    }
  }, {
github lindelof / particles-bg / src / particles / Color.jsx View on Github external
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);

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