@tsparticles/shape-star 3.0.0-alpha.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020 Matteo Bruni
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,71 @@
1
+ [![banner](https://particles.js.org/images/banner2.png)](https://particles.js.org)
2
+
3
+ # tsParticles Star Shape
4
+
5
+ [![jsDelivr](https://data.jsdelivr.com/v1/package/npm/tsparticles-shape-star/badge)](https://www.jsdelivr.com/package/npm/tsparticles-shape-star)
6
+ [![npmjs](https://badge.fury.io/js/tsparticles-shape-star.svg)](https://www.npmjs.com/package/tsparticles-shape-star)
7
+ [![npmjs](https://img.shields.io/npm/dt/tsparticles-shape-star)](https://www.npmjs.com/package/tsparticles-shape-star) [![GitHub Sponsors](https://img.shields.io/github/sponsors/matteobruni)](https://github.com/sponsors/matteobruni)
8
+
9
+ [tsParticles](https://github.com/matteobruni/tsparticles) additional star shape.
10
+
11
+ ## How to use it
12
+
13
+ ### CDN / Vanilla JS / jQuery
14
+
15
+ The CDN/Vanilla version JS has one required file in vanilla configuration:
16
+
17
+ Including the `tsparticles.shape.star.min.js` file will export the function to load the shape:
18
+
19
+ ```javascript
20
+ loadStarShape;
21
+ ```
22
+
23
+ ### Usage
24
+
25
+ Once the scripts are loaded you can set up `tsParticles` and the shape like this:
26
+
27
+ ```javascript
28
+ (async () => {
29
+ await loadStarShape();
30
+
31
+ await tsParticles.load({
32
+ id: "tsparticles",
33
+ options: {
34
+ /* options */
35
+ /* here you can use particles.shape.type: "star" */
36
+ },
37
+ });
38
+ })();
39
+ ```
40
+
41
+ ### ESM / CommonJS
42
+
43
+ This package is compatible also with ES or CommonJS modules, firstly this needs to be installed, like this:
44
+
45
+ ```shell
46
+ $ npm install tsparticles-shape-star
47
+ ```
48
+
49
+ or
50
+
51
+ ```shell
52
+ $ yarn add tsparticles-shape-star
53
+ ```
54
+
55
+ Then you need to import it in the app, like this:
56
+
57
+ ```javascript
58
+ const { tsParticles } = require("tsparticles-engine");
59
+ const { loadStarShape } = require("tsparticles-shape-star");
60
+
61
+ loadStarShape(tsParticles);
62
+ ```
63
+
64
+ or
65
+
66
+ ```javascript
67
+ import { tsParticles } from "tsparticles-engine";
68
+ import { loadStarShape } from "tsparticles-shape-star";
69
+
70
+ loadStarShape(tsParticles);
71
+ ```
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,24 @@
1
+ import { getRangeValue } from "@tsparticles/engine";
2
+ export class StarDrawer {
3
+ draw(context, particle, radius) {
4
+ var _a;
5
+ const sides = particle.sides, inset = (_a = particle.starInset) !== null && _a !== void 0 ? _a : 2;
6
+ context.moveTo(0, 0 - radius);
7
+ for (let i = 0; i < sides; i++) {
8
+ context.rotate(Math.PI / sides);
9
+ context.lineTo(0, 0 - radius * inset);
10
+ context.rotate(Math.PI / sides);
11
+ context.lineTo(0, 0 - radius);
12
+ }
13
+ }
14
+ getSidesCount(particle) {
15
+ var _a, _b;
16
+ const star = particle.shapeData;
17
+ return Math.round(getRangeValue((_b = (_a = star === null || star === void 0 ? void 0 : star.sides) !== null && _a !== void 0 ? _a : star === null || star === void 0 ? void 0 : star.nb_sides) !== null && _b !== void 0 ? _b : 5));
18
+ }
19
+ particleInit(container, particle) {
20
+ var _a;
21
+ const star = particle.shapeData, inset = getRangeValue((_a = star === null || star === void 0 ? void 0 : star.inset) !== null && _a !== void 0 ? _a : 2);
22
+ particle.starInset = inset;
23
+ }
24
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ import { StarDrawer } from "./StarDrawer";
2
+ export async function loadStarShape(engine) {
3
+ await engine.addShape("star", new StarDrawer());
4
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StarDrawer = void 0;
4
+ const engine_1 = require("@tsparticles/engine");
5
+ class StarDrawer {
6
+ draw(context, particle, radius) {
7
+ var _a;
8
+ const sides = particle.sides, inset = (_a = particle.starInset) !== null && _a !== void 0 ? _a : 2;
9
+ context.moveTo(0, 0 - radius);
10
+ for (let i = 0; i < sides; i++) {
11
+ context.rotate(Math.PI / sides);
12
+ context.lineTo(0, 0 - radius * inset);
13
+ context.rotate(Math.PI / sides);
14
+ context.lineTo(0, 0 - radius);
15
+ }
16
+ }
17
+ getSidesCount(particle) {
18
+ var _a, _b;
19
+ const star = particle.shapeData;
20
+ return Math.round((0, engine_1.getRangeValue)((_b = (_a = star === null || star === void 0 ? void 0 : star.sides) !== null && _a !== void 0 ? _a : star === null || star === void 0 ? void 0 : star.nb_sides) !== null && _b !== void 0 ? _b : 5));
21
+ }
22
+ particleInit(container, particle) {
23
+ var _a;
24
+ const star = particle.shapeData, inset = (0, engine_1.getRangeValue)((_a = star === null || star === void 0 ? void 0 : star.inset) !== null && _a !== void 0 ? _a : 2);
25
+ particle.starInset = inset;
26
+ }
27
+ }
28
+ exports.StarDrawer = StarDrawer;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/cjs/index.js ADDED
@@ -0,0 +1,19 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.loadStarShape = void 0;
13
+ const StarDrawer_1 = require("./StarDrawer");
14
+ function loadStarShape(engine) {
15
+ return __awaiter(this, void 0, void 0, function* () {
16
+ yield engine.addShape("star", new StarDrawer_1.StarDrawer());
17
+ });
18
+ }
19
+ exports.loadStarShape = loadStarShape;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,24 @@
1
+ import { getRangeValue } from "@tsparticles/engine";
2
+ export class StarDrawer {
3
+ draw(context, particle, radius) {
4
+ var _a;
5
+ const sides = particle.sides, inset = (_a = particle.starInset) !== null && _a !== void 0 ? _a : 2;
6
+ context.moveTo(0, 0 - radius);
7
+ for (let i = 0; i < sides; i++) {
8
+ context.rotate(Math.PI / sides);
9
+ context.lineTo(0, 0 - radius * inset);
10
+ context.rotate(Math.PI / sides);
11
+ context.lineTo(0, 0 - radius);
12
+ }
13
+ }
14
+ getSidesCount(particle) {
15
+ var _a, _b;
16
+ const star = particle.shapeData;
17
+ return Math.round(getRangeValue((_b = (_a = star === null || star === void 0 ? void 0 : star.sides) !== null && _a !== void 0 ? _a : star === null || star === void 0 ? void 0 : star.nb_sides) !== null && _b !== void 0 ? _b : 5));
18
+ }
19
+ particleInit(container, particle) {
20
+ var _a;
21
+ const star = particle.shapeData, inset = getRangeValue((_a = star === null || star === void 0 ? void 0 : star.inset) !== null && _a !== void 0 ? _a : 2);
22
+ particle.starInset = inset;
23
+ }
24
+ }
@@ -0,0 +1 @@
1
+ export {};
package/esm/index.js ADDED
@@ -0,0 +1,4 @@
1
+ import { StarDrawer } from "./StarDrawer";
2
+ export async function loadStarShape(engine) {
3
+ await engine.addShape("star", new StarDrawer());
4
+ }
package/package.json ADDED
@@ -0,0 +1,54 @@
1
+ {
2
+ "name": "@tsparticles/shape-star",
3
+ "version": "3.0.0-alpha.0",
4
+ "description": "tsParticles star shape",
5
+ "homepage": "https://particles.js.org",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/matteobruni/tsparticles.git",
9
+ "directory": "shapes/star"
10
+ },
11
+ "keywords": [
12
+ "front-end",
13
+ "frontend",
14
+ "tsparticles",
15
+ "particles",
16
+ "particle",
17
+ "canvas",
18
+ "jsparticles",
19
+ "xparticles",
20
+ "particles-js",
21
+ "particles.js",
22
+ "particles-ts",
23
+ "particles.ts",
24
+ "typescript",
25
+ "javascript",
26
+ "animation",
27
+ "web",
28
+ "html5",
29
+ "web-design",
30
+ "webdesign",
31
+ "css",
32
+ "html",
33
+ "css3",
34
+ "animated",
35
+ "background",
36
+ "@tsparticles/shape"
37
+ ],
38
+ "author": "Matteo Bruni <matteo.bruni@me.com>",
39
+ "license": "MIT",
40
+ "bugs": {
41
+ "url": "https://github.com/matteobruni/tsparticles/issues"
42
+ },
43
+ "main": "cjs/index.js",
44
+ "jsdelivr": "tsparticles.shape.star.min.js",
45
+ "unpkg": "tsparticles.shape.star.min.js",
46
+ "module": "esm/index.js",
47
+ "types": "types/index.d.ts",
48
+ "publishConfig": {
49
+ "access": "public"
50
+ },
51
+ "dependencies": {
52
+ "@tsparticles/engine": "^3.0.0-alpha.0"
53
+ }
54
+ }