From 2bd0415e06a9d5ece15f00de967b47028c76262d Mon Sep 17 00:00:00 2001 From: drawcall Date: Fri, 10 Sep 2021 11:31:32 +0800 Subject: [PATCH] feat: update editorconfig --- .editorconfig | 1 + package.json | 2 +- src/render/BaseRenderer.js | 201 ++++++++++++++++--------------------- 3 files changed, 89 insertions(+), 115 deletions(-) diff --git a/.editorconfig b/.editorconfig index 3454886..6588b4a 100755 --- a/.editorconfig +++ b/.editorconfig @@ -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 diff --git a/package.json b/package.json index 7e86bea..05c97fd 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/render/BaseRenderer.js b/src/render/BaseRenderer.js index 12d994a..67c51a3 100755 --- a/src/render/BaseRenderer.js +++ b/src/render/BaseRenderer.js @@ -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) {} }