Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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
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,
} 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));
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);
this.props.num ? new Proton.Span(this.props.num) : new Proton.Span(4, 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.Velocity(
new Proton.Span(4, 7),
new Proton.Span(0, 360),
"polar"
)
);
emitter.addInitialize(
new Proton.Position(new Proton.CircleZone(width / 2, height / 2, 100))
);
emitter.addBehaviour(new Proton.Alpha(1, 0));
emitter.addBehaviour(new Proton.Scale(0.2, 1));
emitter.addBehaviour(this.createCustomBehaviour());
emitter.addBehaviour(new Proton.Color(this.colors, "random"));
emitter.emit();
this.proton.addEmitter(emitter);
const renderer = new Proton.CanvasRenderer(canvas);
this.proton.addRenderer(renderer);
}
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);
const renderer = new Proton.CanvasRenderer(canvas);
this.proton.addRenderer(renderer);
}
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(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"
)
);
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"
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"
)
);
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"
createProton(canvas, width, height) {
this.proton = new Proton();
const 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)
)
);
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)));