Skip to content

Commit

Permalink
feat: added poisson disc plugin for better particles initial positions
Browse files Browse the repository at this point in the history
  • Loading branch information
matteobruni committed Jan 1, 2024
1 parent de1fbc2 commit 405f1df
Show file tree
Hide file tree
Showing 32 changed files with 917 additions and 0 deletions.
1 change: 1 addition & 0 deletions bundles/all/package.dist.json
Expand Up @@ -130,6 +130,7 @@
"@tsparticles/plugin-hsv-color": "^3.0.3",
"@tsparticles/plugin-infection": "^3.0.3",
"@tsparticles/plugin-motion": "^3.0.3",
"@tsparticles/plugin-poisson-disc": "^3.0.3",
"@tsparticles/plugin-polygon-mask": "^3.0.3",
"@tsparticles/plugin-sounds": "^3.0.3",
"@tsparticles/shape-arrow": "^3.0.3",
Expand Down
1 change: 1 addition & 0 deletions bundles/all/package.json
Expand Up @@ -138,6 +138,7 @@
"@tsparticles/plugin-hsv-color": "^3.0.3",
"@tsparticles/plugin-infection": "^3.0.3",
"@tsparticles/plugin-motion": "^3.0.3",
"@tsparticles/plugin-poisson-disc": "^3.0.3",
"@tsparticles/plugin-polygon-mask": "^3.0.3",
"@tsparticles/plugin-sounds": "^3.0.3",
"@tsparticles/shape-arrow": "^3.0.3",
Expand Down
2 changes: 2 additions & 0 deletions bundles/all/src/index.ts
Expand Up @@ -33,6 +33,7 @@ import { loadOrbitUpdater } from "@tsparticles/updater-orbit";
import { loadParticlesRepulseInteraction } from "@tsparticles/interaction-particles-repulse";
import { loadPathShape } from "@tsparticles/shape-path";
import { loadPerlinNoisePath } from "@tsparticles/path-perlin-noise";
import { loadPoissonDiscPlugin } from "@tsparticles/plugin-poisson-disc";
import { loadPolygonMaskPlugin } from "@tsparticles/plugin-polygon-mask";
import { loadPolygonPath } from "@tsparticles/path-polygon";
import { loadRoundedPolygonShape } from "@tsparticles/shape-rounded-polygon";
Expand Down Expand Up @@ -89,6 +90,7 @@ export async function loadAll(engine: Engine, refresh = true): Promise<void> {
await loadCurvesPath(engine, false);
await loadCurlNoisePath(engine, false);
await loadPerlinNoisePath(engine, false);
await loadPoissonDiscPlugin(engine, false);
await loadPolygonPath(engine, false);
await loadSVGPath(engine, false);
await loadSimplexNoisePath(engine, false);
Expand Down
1 change: 1 addition & 0 deletions demo/vanilla/app.ts
Expand Up @@ -105,6 +105,7 @@ app.use("/interaction-external-trail", express.static("./node_modules/@tsparticl
app.use("/plugin-absorbers", express.static("./node_modules/@tsparticles/plugin-absorbers"));
app.use("/plugin-emitters", express.static("./node_modules/@tsparticles/plugin-emitters"));
app.use("/plugin-polygon-mask", express.static("./node_modules/@tsparticles/plugin-polygon-mask"));
app.use("/plugin-poisson-disc", express.static("./node_modules/@tsparticles/plugin-poisson-disc"));
app.use("/interaction-external-pop", express.static("./node_modules/@tsparticles/interaction-external-pop"));
app.use("/interaction-light", express.static("./node_modules/@tsparticles/interaction-light"));
app.use("/interaction-particles-repulse", express.static("./node_modules/@tsparticles/interaction-particles-repulse"));
Expand Down
1 change: 1 addition & 0 deletions demo/vanilla/package.json
Expand Up @@ -108,6 +108,7 @@
"@tsparticles/plugin-hsv-color": "^3.0.3",
"@tsparticles/plugin-infection": "^3.0.3",
"@tsparticles/plugin-motion": "^3.0.3",
"@tsparticles/plugin-poisson-disc": "^3.0.3",
"@tsparticles/plugin-polygon-mask": "^3.0.3",
"@tsparticles/plugin-sounds": "^3.0.3",
"@tsparticles/shape-arrow": "^3.0.3",
Expand Down
1 change: 1 addition & 0 deletions demo/vanilla/views/index.pug
Expand Up @@ -152,6 +152,7 @@ html(lang="en")
script(src="/interaction-external-trail/tsparticles.interaction.external.trail.js")
script(src="/plugin-absorbers/tsparticles.plugin.absorbers.js")
script(src="/plugin-emitters/tsparticles.plugin.emitters.js")
script(src="/plugin-poisson-disc/tsparticles.plugin.poisson.js")
script(src="/plugin-polygon-mask/tsparticles.plugin.polygon-mask.js")
script(src="/interaction-external-pop/tsparticles.interaction.external.pop.js")
script(src="/interaction-light/tsparticles.interaction.light.js")
Expand Down
2 changes: 2 additions & 0 deletions plugins/poisson/.browserslistrc
@@ -0,0 +1,2 @@
since 2019
not dead
2 changes: 2 additions & 0 deletions plugins/poisson/.eslintignore
@@ -0,0 +1,2 @@
dist
node_modules
5 changes: 5 additions & 0 deletions plugins/poisson/.eslintrc.js
@@ -0,0 +1,5 @@
module.exports = {
extends: [
"@tsparticles/eslint-config",
]
};
1 change: 1 addition & 0 deletions plugins/poisson/.npmignore
@@ -0,0 +1 @@
report.html
21 changes: 21 additions & 0 deletions plugins/poisson/LICENSE
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2020 Matteo Bruni

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
74 changes: 74 additions & 0 deletions plugins/poisson/README.md
@@ -0,0 +1,74 @@
[![banner](https://particles.js.org/images/banner2.png)](https://particles.js.org)

# tsParticles Poisson Disc Plugin

[![jsDelivr](https://data.jsdelivr.com/v1/package/npm/@tsparticles/plugin-poisson/badge)](https://www.jsdelivr.com/package/npm/@tsparticles/plugin-poisson)
[![npmjs](https://badge.fury.io/js/@tsparticles/plugin-poisson.svg)](https://www.npmjs.com/package/@tsparticles/plugin-poisson)
[![npmjs](https://img.shields.io/npm/dt/@tsparticles/plugin-poisson)](https://www.npmjs.com/package/@tsparticles/plugin-poisson) [![GitHub Sponsors](https://img.shields.io/github/sponsors/matteobruni)](https://github.com/sponsors/matteobruni)

[tsParticles](https://github.com/tsparticles/tsparticles) plugin for particles poisson disc effect.

## How to use it

### CDN / Vanilla JS / jQuery

The CDN/Vanilla version JS has one required file in vanilla configuration:

Including the `tsparticles.plugin.poisson.min.js` file will export the function to load the plugin:

```javascript
loadPoissonDiscPlugin;
```

### Usage

Once the scripts are loaded you can set up `tsParticles` and the plugin like this:

```javascript
(async () => {
await loadPoissonDiscPlugin(tsParticles);

await tsParticles.load({
id: "tsparticles",
options: {
/* options */
},
});
})();
```

### ESM / CommonJS

This package is compatible also with ES or CommonJS modules, firstly this needs to be installed, like this:

```shell
$ npm install @tsparticles/plugin-poisson
```

or

```shell
$ yarn add @tsparticles/plugin-poisson
```

Then you need to import it in the app, like this:

```javascript
const { tsParticles } = require("@tsparticles/engine");
const { loadPoissonDiscPlugin } = require("@tsparticles/plugin-poisson");

(async () => {
await loadPoissonDiscPlugin(tsParticles);
})();
```

or

```javascript
import { tsParticles } from "@tsparticles/engine";
import { loadPoissonDiscPlugin } from "@tsparticles/plugin-poisson";

(async () => {
await loadPoissonDiscPlugin(tsParticles);
})();
```
93 changes: 93 additions & 0 deletions plugins/poisson/package.dist.json
@@ -0,0 +1,93 @@
{
"name": "@tsparticles/plugin-poisson-disc",
"version": "3.0.3",
"description": "tsParticles poisson disc plugin",
"homepage": "https://particles.js.org",
"repository": {
"type": "git",
"url": "git+https://github.com/tsparticles/tsparticles.git",
"directory": "plugins/poisson"
},
"keywords": [
"front-end",
"frontend",
"tsparticles",
"particles.js",
"particlesjs",
"particles",
"particle",
"canvas",
"jsparticles",
"xparticles",
"particles-js",
"particles-bg",
"particles-bg-vue",
"particles-ts",
"particles.ts",
"react-particles-js",
"react-particles.js",
"react-particles",
"react",
"reactjs",
"vue-particles",
"ngx-particles",
"angular-particles",
"particleground",
"vue",
"vuejs",
"preact",
"preactjs",
"jquery",
"angularjs",
"angular",
"typescript",
"javascript",
"animation",
"web",
"html5",
"web-design",
"webdesign",
"css",
"html",
"css3",
"animated",
"background",
"confetti",
"canvas",
"fireworks",
"fireworks-js",
"confetti-js",
"confettijs",
"fireworksjs",
"canvas-confetti",
"tsparticles-plugin"
],
"author": "Matteo Bruni <matteo.bruni@me.com>",
"license": "MIT",
"bugs": {
"url": "https://github.com/tsparticles/tsparticles/issues"
},
"jsdelivr": "tsparticles.plugin.poisson.min.js",
"unpkg": "tsparticles.plugin.poisson.min.js",
"browser": "browser/index.js",
"main": "cjs/index.js",
"module": "esm/index.js",
"types": "types/index.d.ts",
"exports": {
".": {
"types": "./types/index.d.ts",
"browser": "./browser/index.js",
"import": "./esm/index.js",
"require": "./cjs/index.js",
"umd": "./umd/index.js",
"default": "./cjs/index.js"
},
"./package.json": "./package.json"
},
"dependencies": {
"@tsparticles/engine": "^3.0.3"
},
"publishConfig": {
"access": "public"
}
}
88 changes: 88 additions & 0 deletions plugins/poisson/package.json
@@ -0,0 +1,88 @@
{
"name": "@tsparticles/plugin-poisson-disc",
"version": "3.0.3",
"description": "tsParticles poisson disc plugin",
"homepage": "https://particles.js.org",
"scripts": {
"build": "tsparticles-cli build",
"build:ci": "tsparticles-cli build --ci",
"version": "tsparticles-cli build -d && git add package.dist.json",
"prepack": "pnpm run build"
},
"repository": {
"type": "git",
"url": "git+https://github.com/tsparticles/tsparticles.git",
"directory": "plugins/poisson"
},
"keywords": [
"front-end",
"frontend",
"tsparticles",
"particles.js",
"particlesjs",
"particles",
"particle",
"canvas",
"jsparticles",
"xparticles",
"particles-js",
"particles-bg",
"particles-bg-vue",
"particles-ts",
"particles.ts",
"react-particles-js",
"react-particles.js",
"react-particles",
"react",
"reactjs",
"vue-particles",
"ngx-particles",
"angular-particles",
"particleground",
"vue",
"vuejs",
"preact",
"preactjs",
"jquery",
"angularjs",
"angular",
"typescript",
"javascript",
"animation",
"web",
"html5",
"web-design",
"webdesign",
"css",
"html",
"css3",
"animated",
"background",
"confetti",
"canvas",
"fireworks",
"fireworks-js",
"confetti-js",
"confettijs",
"fireworksjs",
"canvas-confetti",
"tsparticles-plugin"
],
"author": "Matteo Bruni <matteo.bruni@me.com>",
"license": "MIT",
"bugs": {
"url": "https://github.com/tsparticles/tsparticles/issues"
},
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
"types": "dist/types/index.d.ts",
"prettier": "@tsparticles/prettier-config",
"dependencies": {
"@tsparticles/engine": "^3.0.3"
},
"publishConfig": {
"access": "public",
"directory": "dist",
"linkDirectory": true
}
}
6 changes: 6 additions & 0 deletions plugins/poisson/src/Interfaces/IPoissonPoint.ts
@@ -0,0 +1,6 @@
import type { ICoordinates } from "@tsparticles/engine";

export interface IPoissonPoint {
gridPosition: ICoordinates;
position: ICoordinates;
}

0 comments on commit 405f1df

Please sign in to comment.