@tsparticles/shape-star 3.0.0-alpha.0 → 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/StarDrawer.js +4 -7
- package/browser/index.js +2 -2
- package/cjs/StarDrawer.js +4 -7
- package/cjs/index.js +2 -13
- package/esm/StarDrawer.js +4 -7
- package/esm/index.js +2 -2
- package/package.json +6 -5
- package/report.html +4 -4
- package/tsparticles.shape.star.js +8 -12
- package/tsparticles.shape.star.min.js +1 -1
- package/tsparticles.shape.star.min.js.LICENSE.txt +1 -8
- package/types/StarDrawer.d.ts +1 -1
- package/types/index.d.ts +1 -1
- package/umd/StarDrawer.js +4 -7
- package/umd/index.js +2 -2
package/README.md
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
# tsParticles Star Shape
|
|
4
4
|
|
|
5
|
-
[](https://www.jsdelivr.com/package/npm/@tsparticles/shape-star)
|
|
6
|
+
[](https://www.npmjs.com/package/@tsparticles/shape-star)
|
|
7
|
+
[](https://www.npmjs.com/package/@tsparticles/shape-star) [](https://github.com/sponsors/matteobruni)
|
|
8
8
|
|
|
9
9
|
[tsParticles](https://github.com/matteobruni/tsparticles) additional star 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 loadStarShape();
|
|
29
|
+
await loadStarShape(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-star
|
|
47
47
|
```
|
|
48
48
|
|
|
49
49
|
or
|
|
50
50
|
|
|
51
51
|
```shell
|
|
52
|
-
$ yarn add tsparticles
|
|
52
|
+
$ yarn add @tsparticles/shape-star
|
|
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 { loadStarShape } = require("tsparticles
|
|
58
|
+
const { tsParticles } = require("@tsparticles/engine");
|
|
59
|
+
const { loadStarShape } = require("@tsparticles/shape-star");
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
(async () => {
|
|
62
|
+
await loadStarShape(tsParticles);
|
|
63
|
+
})();
|
|
62
64
|
```
|
|
63
65
|
|
|
64
66
|
or
|
|
65
67
|
|
|
66
68
|
```javascript
|
|
67
|
-
import { tsParticles } from "tsparticles
|
|
68
|
-
import { loadStarShape } from "tsparticles
|
|
69
|
+
import { tsParticles } from "@tsparticles/engine";
|
|
70
|
+
import { loadStarShape } from "@tsparticles/shape-star";
|
|
69
71
|
|
|
70
|
-
|
|
72
|
+
(async () => {
|
|
73
|
+
await loadStarShape(tsParticles);
|
|
74
|
+
})();
|
|
71
75
|
```
|
package/browser/StarDrawer.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { getRangeValue } from "@tsparticles/engine";
|
|
2
2
|
export class StarDrawer {
|
|
3
3
|
draw(context, particle, radius) {
|
|
4
|
-
|
|
5
|
-
const sides = particle.sides, inset = (_a = particle.starInset) !== null && _a !== void 0 ? _a : 2;
|
|
4
|
+
const sides = particle.sides, inset = particle.starInset ?? 2;
|
|
6
5
|
context.moveTo(0, 0 - radius);
|
|
7
6
|
for (let i = 0; i < sides; i++) {
|
|
8
7
|
context.rotate(Math.PI / sides);
|
|
@@ -12,13 +11,11 @@ export class StarDrawer {
|
|
|
12
11
|
}
|
|
13
12
|
}
|
|
14
13
|
getSidesCount(particle) {
|
|
15
|
-
var _a, _b;
|
|
16
14
|
const star = particle.shapeData;
|
|
17
|
-
return Math.round(getRangeValue(
|
|
15
|
+
return Math.round(getRangeValue(star?.sides ?? 5));
|
|
18
16
|
}
|
|
19
17
|
particleInit(container, particle) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
particle.starInset = inset;
|
|
18
|
+
const star = particle.shapeData;
|
|
19
|
+
particle.starInset = getRangeValue(star?.inset ?? 2);
|
|
23
20
|
}
|
|
24
21
|
}
|
package/browser/index.js
CHANGED
package/cjs/StarDrawer.js
CHANGED
|
@@ -4,8 +4,7 @@ exports.StarDrawer = void 0;
|
|
|
4
4
|
const engine_1 = require("@tsparticles/engine");
|
|
5
5
|
class StarDrawer {
|
|
6
6
|
draw(context, particle, radius) {
|
|
7
|
-
|
|
8
|
-
const sides = particle.sides, inset = (_a = particle.starInset) !== null && _a !== void 0 ? _a : 2;
|
|
7
|
+
const sides = particle.sides, inset = particle.starInset ?? 2;
|
|
9
8
|
context.moveTo(0, 0 - radius);
|
|
10
9
|
for (let i = 0; i < sides; i++) {
|
|
11
10
|
context.rotate(Math.PI / sides);
|
|
@@ -15,14 +14,12 @@ class StarDrawer {
|
|
|
15
14
|
}
|
|
16
15
|
}
|
|
17
16
|
getSidesCount(particle) {
|
|
18
|
-
var _a, _b;
|
|
19
17
|
const star = particle.shapeData;
|
|
20
|
-
return Math.round((0, engine_1.getRangeValue)(
|
|
18
|
+
return Math.round((0, engine_1.getRangeValue)(star?.sides ?? 5));
|
|
21
19
|
}
|
|
22
20
|
particleInit(container, particle) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
particle.starInset = inset;
|
|
21
|
+
const star = particle.shapeData;
|
|
22
|
+
particle.starInset = (0, engine_1.getRangeValue)(star?.inset ?? 2);
|
|
26
23
|
}
|
|
27
24
|
}
|
|
28
25
|
exports.StarDrawer = StarDrawer;
|
package/cjs/index.js
CHANGED
|
@@ -1,19 +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.loadStarShape = void 0;
|
|
13
4
|
const StarDrawer_1 = require("./StarDrawer");
|
|
14
|
-
function loadStarShape(engine) {
|
|
15
|
-
|
|
16
|
-
yield engine.addShape("star", new StarDrawer_1.StarDrawer());
|
|
17
|
-
});
|
|
5
|
+
async function loadStarShape(engine, refresh = true) {
|
|
6
|
+
await engine.addShape("star", new StarDrawer_1.StarDrawer(), refresh);
|
|
18
7
|
}
|
|
19
8
|
exports.loadStarShape = loadStarShape;
|
package/esm/StarDrawer.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { getRangeValue } from "@tsparticles/engine";
|
|
2
2
|
export class StarDrawer {
|
|
3
3
|
draw(context, particle, radius) {
|
|
4
|
-
|
|
5
|
-
const sides = particle.sides, inset = (_a = particle.starInset) !== null && _a !== void 0 ? _a : 2;
|
|
4
|
+
const sides = particle.sides, inset = particle.starInset ?? 2;
|
|
6
5
|
context.moveTo(0, 0 - radius);
|
|
7
6
|
for (let i = 0; i < sides; i++) {
|
|
8
7
|
context.rotate(Math.PI / sides);
|
|
@@ -12,13 +11,11 @@ export class StarDrawer {
|
|
|
12
11
|
}
|
|
13
12
|
}
|
|
14
13
|
getSidesCount(particle) {
|
|
15
|
-
var _a, _b;
|
|
16
14
|
const star = particle.shapeData;
|
|
17
|
-
return Math.round(getRangeValue(
|
|
15
|
+
return Math.round(getRangeValue(star?.sides ?? 5));
|
|
18
16
|
}
|
|
19
17
|
particleInit(container, particle) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
particle.starInset = inset;
|
|
18
|
+
const star = particle.shapeData;
|
|
19
|
+
particle.starInset = getRangeValue(star?.inset ?? 2);
|
|
23
20
|
}
|
|
24
21
|
}
|
package/esm/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsparticles/shape-star",
|
|
3
|
-
"version": "3.0.0-
|
|
3
|
+
"version": "3.0.0-beta.0",
|
|
4
4
|
"description": "tsParticles star shape",
|
|
5
5
|
"homepage": "https://particles.js.org",
|
|
6
6
|
"repository": {
|
|
@@ -45,10 +45,11 @@
|
|
|
45
45
|
"unpkg": "tsparticles.shape.star.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.0"
|
|
53
54
|
}
|
|
54
|
-
}
|
|
55
|
+
}
|