Skip to content

Commit

Permalink
feat: update editorconfig
Browse files Browse the repository at this point in the history
  • Loading branch information
drawcall committed Sep 10, 2021
1 parent 5ea73b6 commit 2bd0415
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 115 deletions.
1 change: 1 addition & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ charset = utf-8
indent_style = space
indent_size = 2
end_of_line = lf
max_line_length = 120
insert_final_newline = true
trim_trailing_whitespace = true

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "proton-engine",
"version": "4.2.1",
"version": "5.0.1",
"description": "Proton is a simple and powerful javascript particle animation engine.",
"keywords": [
"particle",
Expand Down
201 changes: 87 additions & 114 deletions src/render/BaseRenderer.js
Original file line number Diff line number Diff line change
@@ -1,118 +1,91 @@
import Pool from "../core/Pool";

export default class BaseRenderer {
constructor(element, stroke) {
this.pool = new Pool();
this.element = element;
this.stroke = stroke;
this.circleConf = { isCircle: true };

this.initHandler();
this.name = "BaseRenderer";
}

setStroke(color = "#000000", thinkness = 1) {
this.stroke = { color, thinkness };
}

initHandler() {
this._protonUpdateHandler = () => {
this.onProtonUpdate.call(this);
};

this._protonUpdateAfterHandler = () => {
this.onProtonUpdateAfter.call(this);
};

this._emitterAddedHandler = emitter => {
this.onEmitterAdded.call(this, emitter);
};

this._emitterRemovedHandler = emitter => {
this.onEmitterRemoved.call(this, emitter);
};

this._particleCreatedHandler = particle => {
this.onParticleCreated.call(this, particle);
};

this._particleUpdateHandler = particle => {
this.onParticleUpdate.call(this, particle);
};

this._particleDeadHandler = particle => {
this.onParticleDead.call(this, particle);
};
}

init(proton) {
this.parent = proton;

proton.addEventListener("PROTON_UPDATE", this._protonUpdateHandler);
proton.addEventListener(
"PROTON_UPDATE_AFTER",
this._protonUpdateAfterHandler
);

proton.addEventListener("EMITTER_ADDED", this._emitterAddedHandler);
proton.addEventListener("EMITTER_REMOVED", this._emitterRemovedHandler);

proton.addEventListener(
"PARTICLE_CREATED",
this._particleCreatedHandler
);
proton.addEventListener("PARTICLE_UPDATE", this._particleUpdateHandler);
proton.addEventListener("PARTICLE_DEAD", this._particleDeadHandler);
}

resize(width, height) {}

destroy() {
this.remove();
}

remove(proton) {
this.parent.removeEventListener(
"PROTON_UPDATE",
this._protonUpdateHandler
);
this.parent.removeEventListener(
"PROTON_UPDATE_AFTER",
this._protonUpdateAfterHandler
);

this.parent.removeEventListener(
"EMITTER_ADDED",
this._emitterAddedHandler
);
this.parent.removeEventListener(
"EMITTER_REMOVED",
this._emitterRemovedHandler
);

this.parent.removeEventListener(
"PARTICLE_CREATED",
this._particleCreatedHandler
);
this.parent.removeEventListener(
"PARTICLE_UPDATE",
this._particleUpdateHandler
);
this.parent.removeEventListener(
"PARTICLE_DEAD",
this._particleDeadHandler
);

this.parent = null;
}

onProtonUpdate() {}
onProtonUpdateAfter() {}

onEmitterAdded(emitter) {}
onEmitterRemoved(emitter) {}

onParticleCreated(particle) {}
onParticleUpdate(particle) {}
onParticleDead(particle) {}
constructor(element, stroke) {
this.pool = new Pool();
this.element = element;
this.stroke = stroke;
this.circleConf = { isCircle: true };

this.initHandler();
this.name = "BaseRenderer";
}

setStroke(color = "#000000", thinkness = 1) {
this.stroke = { color, thinkness };
}

initHandler() {
this._protonUpdateHandler = () => {
this.onProtonUpdate.call(this);
};

this._protonUpdateAfterHandler = () => {
this.onProtonUpdateAfter.call(this);
};

this._emitterAddedHandler = emitter => {
this.onEmitterAdded.call(this, emitter);
};

this._emitterRemovedHandler = emitter => {
this.onEmitterRemoved.call(this, emitter);
};

this._particleCreatedHandler = particle => {
this.onParticleCreated.call(this, particle);
};

this._particleUpdateHandler = particle => {
this.onParticleUpdate.call(this, particle);
};

this._particleDeadHandler = particle => {
this.onParticleDead.call(this, particle);
};
}

init(proton) {
this.parent = proton;

proton.addEventListener("PROTON_UPDATE", this._protonUpdateHandler);
proton.addEventListener("PROTON_UPDATE_AFTER", this._protonUpdateAfterHandler);

proton.addEventListener("EMITTER_ADDED", this._emitterAddedHandler);
proton.addEventListener("EMITTER_REMOVED", this._emitterRemovedHandler);

proton.addEventListener("PARTICLE_CREATED", this._particleCreatedHandler);
proton.addEventListener("PARTICLE_UPDATE", this._particleUpdateHandler);
proton.addEventListener("PARTICLE_DEAD", this._particleDeadHandler);
}

resize(width, height) {}

destroy() {
this.remove();
}

remove(proton) {
this.parent.removeEventListener("PROTON_UPDATE", this._protonUpdateHandler);
this.parent.removeEventListener("PROTON_UPDATE_AFTER", this._protonUpdateAfterHandler);

this.parent.removeEventListener("EMITTER_ADDED", this._emitterAddedHandler);
this.parent.removeEventListener("EMITTER_REMOVED", this._emitterRemovedHandler);

this.parent.removeEventListener("PARTICLE_CREATED", this._particleCreatedHandler);
this.parent.removeEventListener("PARTICLE_UPDATE", this._particleUpdateHandler);
this.parent.removeEventListener("PARTICLE_DEAD", this._particleDeadHandler);

this.parent = null;
}

onProtonUpdate() {}
onProtonUpdateAfter() {}

onEmitterAdded(emitter) {}
onEmitterRemoved(emitter) {}

onParticleCreated(particle) {}
onParticleUpdate(particle) {}
onParticleDead(particle) {}
}

0 comments on commit 2bd0415

Please sign in to comment.