Skip to content

Commit 1779147

Browse files
committed
refactor: splitted the old canvas class to canvas and render managers
1 parent ea15db8 commit 1779147

20 files changed

Lines changed: 529 additions & 467 deletions

File tree

engine/src/Core/CanvasManager.ts

Lines changed: 475 additions & 0 deletions
Large diffs are not rendered by default.

engine/src/Core/Container.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
removeDeleteCount,
88
removeMinIndex,
99
} from "./Utils/Constants.js";
10-
import { Canvas } from "./Canvas.js";
10+
import { CanvasManager } from "./CanvasManager.js";
1111
import type { Engine } from "./Engine.js";
1212
import { EventListeners } from "./Utils/EventListeners.js";
1313
import { EventType } from "../Enums/Types/EventType.js";
@@ -19,7 +19,7 @@ import type { IPlugin } from "./Interfaces/IPlugin.js";
1919
import { type IShapeDrawer } from "./Interfaces/IShapeDrawer.js";
2020
import type { ISourceOptions } from "../Types/ISourceOptions.js";
2121
import { Options } from "../Options/Classes/Options.js";
22-
import { Particles } from "./Particles.js";
22+
import { ParticlesManager } from "./ParticlesManager.js";
2323
import type { PluginManager } from "./Utils/PluginManager.js";
2424
import { Retina } from "./Retina.js";
2525
import { getLogger } from "../Utils/LogUtils.js";
@@ -182,8 +182,8 @@ export class Container {
182182
this.shapeDrawers = new Map();
183183
this.particleUpdaters = [];
184184
this.retina = new Retina(this);
185-
this.canvas = new Canvas(this._engine.pluginManager, this);
186-
this.particles = new Particles(this._engine.pluginManager, this);
185+
this.canvas = new CanvasManager(this._engine.pluginManager, this);
186+
this.particles = new ParticlesManager(this._engine.pluginManager, this);
187187
this.plugins = [];
188188
this.particleDestroyedPlugins = [];
189189
this.particleCreatedPlugins = [];
@@ -625,7 +625,7 @@ export class Container {
625625
return;
626626
}
627627

628-
this.canvas.drawParticles(this._delta);
628+
this.canvas.render.drawParticles(this._delta);
629629

630630
if (!this.alive()) {
631631
this.destroy();

engine/src/Core/Particle.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -410,10 +410,10 @@ export class Particle {
410410

411411
draw(delta: IDelta): void {
412412
const container = this._container,
413-
canvas = container.canvas;
413+
render = container.canvas.render;
414414

415-
canvas.drawParticlePlugins(this, delta);
416-
canvas.drawParticle(this, delta);
415+
render.drawParticlePlugins(this, delta);
416+
render.drawParticle(this, delta);
417417
}
418418

419419
getAngle(): number {
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import { loadParticlesOptions } from "../Utils/OptionsUtils.js";
3030
/**
3131
* Particles manager object
3232
*/
33-
export class Particles {
33+
export class ParticlesManager {
3434
checkParticlePositionPlugins: IContainerPlugin[];
3535

3636
grid;
@@ -295,7 +295,7 @@ export class Particles {
295295
this.clear();
296296
await this.init();
297297

298-
this._container.canvas.drawParticles({ value: 0, factor: 0 });
298+
this._container.canvas.render.drawParticles({ value: 0, factor: 0 });
299299
}
300300

301301
remove(particle: Particle, group?: string, override?: boolean): void {

0 commit comments

Comments
 (0)