@tsparticles/shape-square 3.0.0-alpha.1 → 3.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -12
- package/browser/SquareDrawer.js +2 -1
- package/browser/index.js +2 -3
- package/cjs/SquareDrawer.js +2 -1
- package/cjs/index.js +2 -14
- package/esm/SquareDrawer.js +2 -1
- package/esm/index.js +2 -3
- package/package.json +6 -5
- package/report.html +4 -4
- package/tsparticles.shape.square.js +7 -6
- package/tsparticles.shape.square.min.js +1 -1
- package/tsparticles.shape.square.min.js.LICENSE.txt +1 -8
- package/types/index.d.ts +1 -1
- package/umd/SquareDrawer.js +2 -1
- package/umd/index.js +2 -3
package/README.md
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
# tsParticles Square Shape
|
|
4
4
|
|
|
5
|
-
[](https://www.jsdelivr.com/package/npm/@tsparticles/shape-square)
|
|
6
|
+
[](https://www.npmjs.com/package/@tsparticles/shape-square)
|
|
7
|
+
[](https://www.npmjs.com/package/@tsparticles/shape-square) [](https://github.com/sponsors/matteobruni)
|
|
8
8
|
|
|
9
9
|
[tsParticles](https://github.com/matteobruni/tsparticles) additional square shape.
|
|
10
10
|
|
|
@@ -26,7 +26,7 @@ Once the scripts are loaded you can set up `tsParticles` and the shape like this
|
|
|
26
26
|
|
|
27
27
|
```javascript
|
|
28
28
|
(async () => {
|
|
29
|
-
await loadSquareShape();
|
|
29
|
+
await loadSquareShape(tsParticles);
|
|
30
30
|
|
|
31
31
|
await tsParticles.load({
|
|
32
32
|
id: "tsparticles",
|
|
@@ -43,29 +43,33 @@ Once the scripts are loaded you can set up `tsParticles` and the shape like this
|
|
|
43
43
|
This package is compatible also with ES or CommonJS modules, firstly this needs to be installed, like this:
|
|
44
44
|
|
|
45
45
|
```shell
|
|
46
|
-
$ npm install tsparticles
|
|
46
|
+
$ npm install @tsparticles/shape-square
|
|
47
47
|
```
|
|
48
48
|
|
|
49
49
|
or
|
|
50
50
|
|
|
51
51
|
```shell
|
|
52
|
-
$ yarn add tsparticles
|
|
52
|
+
$ yarn add @tsparticles/shape-square
|
|
53
53
|
```
|
|
54
54
|
|
|
55
55
|
Then you need to import it in the app, like this:
|
|
56
56
|
|
|
57
57
|
```javascript
|
|
58
|
-
const { tsParticles } = require("tsparticles
|
|
59
|
-
const { loadSquareShape } = require("tsparticles
|
|
58
|
+
const { tsParticles } = require("@tsparticles/engine");
|
|
59
|
+
const { loadSquareShape } = require("@tsparticles/shape-square");
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
(async () => {
|
|
62
|
+
await loadSquareShape(tsParticles);
|
|
63
|
+
})();
|
|
62
64
|
```
|
|
63
65
|
|
|
64
66
|
or
|
|
65
67
|
|
|
66
68
|
```javascript
|
|
67
|
-
import { tsParticles } from "tsparticles
|
|
68
|
-
import { loadSquareShape } from "tsparticles
|
|
69
|
+
import { tsParticles } from "@tsparticles/engine";
|
|
70
|
+
import { loadSquareShape } from "@tsparticles/shape-square";
|
|
69
71
|
|
|
70
|
-
|
|
72
|
+
(async () => {
|
|
73
|
+
await loadSquareShape(tsParticles);
|
|
74
|
+
})();
|
|
71
75
|
```
|
package/browser/SquareDrawer.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
const fixFactor = Math.sqrt(2);
|
|
2
2
|
export class SquareDrawer {
|
|
3
3
|
draw(context, particle, radius) {
|
|
4
|
-
|
|
4
|
+
const fixedRadius = radius / fixFactor, fixedDiameter = fixedRadius * 2;
|
|
5
|
+
context.rect(-fixedRadius, -fixedRadius, fixedDiameter, fixedDiameter);
|
|
5
6
|
}
|
|
6
7
|
getSidesCount() {
|
|
7
8
|
return 4;
|
package/browser/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { SquareDrawer } from "./SquareDrawer";
|
|
2
|
-
export async function loadSquareShape(engine) {
|
|
3
|
-
|
|
4
|
-
await engine.addShape(["edge", "square"], drawer);
|
|
2
|
+
export async function loadSquareShape(engine, refresh = true) {
|
|
3
|
+
await engine.addShape(["edge", "square"], new SquareDrawer(), refresh);
|
|
5
4
|
}
|
package/cjs/SquareDrawer.js
CHANGED
|
@@ -4,7 +4,8 @@ exports.SquareDrawer = void 0;
|
|
|
4
4
|
const fixFactor = Math.sqrt(2);
|
|
5
5
|
class SquareDrawer {
|
|
6
6
|
draw(context, particle, radius) {
|
|
7
|
-
|
|
7
|
+
const fixedRadius = radius / fixFactor, fixedDiameter = fixedRadius * 2;
|
|
8
|
+
context.rect(-fixedRadius, -fixedRadius, fixedDiameter, fixedDiameter);
|
|
8
9
|
}
|
|
9
10
|
getSidesCount() {
|
|
10
11
|
return 4;
|
package/cjs/index.js
CHANGED
|
@@ -1,20 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.loadSquareShape = void 0;
|
|
13
4
|
const SquareDrawer_1 = require("./SquareDrawer");
|
|
14
|
-
function loadSquareShape(engine) {
|
|
15
|
-
|
|
16
|
-
const drawer = new SquareDrawer_1.SquareDrawer();
|
|
17
|
-
yield engine.addShape(["edge", "square"], drawer);
|
|
18
|
-
});
|
|
5
|
+
async function loadSquareShape(engine, refresh = true) {
|
|
6
|
+
await engine.addShape(["edge", "square"], new SquareDrawer_1.SquareDrawer(), refresh);
|
|
19
7
|
}
|
|
20
8
|
exports.loadSquareShape = loadSquareShape;
|
package/esm/SquareDrawer.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
const fixFactor = Math.sqrt(2);
|
|
2
2
|
export class SquareDrawer {
|
|
3
3
|
draw(context, particle, radius) {
|
|
4
|
-
|
|
4
|
+
const fixedRadius = radius / fixFactor, fixedDiameter = fixedRadius * 2;
|
|
5
|
+
context.rect(-fixedRadius, -fixedRadius, fixedDiameter, fixedDiameter);
|
|
5
6
|
}
|
|
6
7
|
getSidesCount() {
|
|
7
8
|
return 4;
|
package/esm/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { SquareDrawer } from "./SquareDrawer";
|
|
2
|
-
export async function loadSquareShape(engine) {
|
|
3
|
-
|
|
4
|
-
await engine.addShape(["edge", "square"], drawer);
|
|
2
|
+
export async function loadSquareShape(engine, refresh = true) {
|
|
3
|
+
await engine.addShape(["edge", "square"], new SquareDrawer(), refresh);
|
|
5
4
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsparticles/shape-square",
|
|
3
|
-
"version": "3.0.0-
|
|
3
|
+
"version": "3.0.0-beta.0",
|
|
4
4
|
"description": "tsParticles square shape",
|
|
5
5
|
"homepage": "https://particles.js.org",
|
|
6
6
|
"repository": {
|
|
@@ -45,10 +45,11 @@
|
|
|
45
45
|
"unpkg": "tsparticles.shape.square.min.js",
|
|
46
46
|
"module": "esm/index.js",
|
|
47
47
|
"types": "types/index.d.ts",
|
|
48
|
+
"sideEffects": false,
|
|
49
|
+
"dependencies": {
|
|
50
|
+
"@tsparticles/engine": "^3.0.0-beta.0"
|
|
51
|
+
},
|
|
48
52
|
"publishConfig": {
|
|
49
53
|
"access": "public"
|
|
50
|
-
},
|
|
51
|
-
"dependencies": {
|
|
52
|
-
"@tsparticles/engine": "^3.0.0-alpha.1"
|
|
53
54
|
}
|
|
54
|
-
}
|
|
55
|
+
}
|