-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #41 from tsparticles/dev
Dev
- Loading branch information
Showing
13 changed files
with
1,773 additions
and
1,286 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,10 @@ | ||
import type { Container, Engine, IPlugin, ISourceOptions, Options } from "@tsparticles/engine"; | ||
import { PluginInstance } from "./PluginInstance"; | ||
|
||
/** | ||
*/ | ||
class Plugin implements IPlugin { | ||
readonly id; | ||
|
||
private readonly _engine; | ||
|
||
constructor(engine: Engine) { | ||
this.id = "#template#"; | ||
|
||
this._engine = engine; | ||
} | ||
|
||
getPlugin(container: Container): PluginInstance { | ||
return new PluginInstance(container, this._engine); | ||
} | ||
|
||
loadOptions(_options: Options, _source?: ISourceOptions): void { | ||
if (!this.needsPlugin()) { | ||
// ignore plugin options when not needed | ||
|
||
return; | ||
} | ||
|
||
// Load your options here | ||
} | ||
|
||
needsPlugin(_options?: ISourceOptions): boolean { | ||
return true; // add your condition here, replace true with condition if needed | ||
} | ||
} | ||
import type { Engine } from "@tsparticles/engine"; | ||
|
||
/** | ||
* @param engine - The engine instance | ||
*/ | ||
export async function loadTemplatePlugin(engine: Engine): Promise<void> { | ||
const { Plugin } = await import("./plugin.js"); | ||
|
||
await engine.addPlugin(new Plugin(engine)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { type Container, type Engine, type IPlugin, type ISourceOptions, type Options } from "@tsparticles/engine"; | ||
import type { PluginInstance } from "./PluginInstance.js"; | ||
|
||
/** | ||
*/ | ||
export class Plugin implements IPlugin { | ||
readonly id; | ||
|
||
private readonly _engine; | ||
|
||
constructor(engine: Engine) { | ||
this.id = "#template#"; | ||
|
||
this._engine = engine; | ||
} | ||
|
||
async getPlugin(container: Container): Promise<PluginInstance> { | ||
const { PluginInstance } = await import("./PluginInstance.js"); | ||
|
||
return new PluginInstance(container, this._engine); | ||
} | ||
|
||
loadOptions(_options: Options, _source?: ISourceOptions): void { | ||
if (!this.needsPlugin()) { | ||
// ignore plugin options when not needed | ||
|
||
return; | ||
} | ||
|
||
// Load your options here | ||
} | ||
|
||
needsPlugin(_options?: ISourceOptions): boolean { | ||
return true; // add your condition here, replace true with condition if needed | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
import type { Engine } from "@tsparticles/engine"; | ||
import { ShapeDrawer } from "./ShapeDrawer"; | ||
|
||
/** | ||
* @param engine - the engine instance to load the shape into | ||
*/ | ||
export async function loadTemplateShape(engine: Engine): Promise<void> { | ||
const { ShapeDrawer } = await import("./ShapeDrawer.js"); | ||
|
||
await engine.addShape("#template#", new ShapeDrawer()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.