@tsparticles/shape-rounded-rect 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.
@@ -0,0 +1,118 @@
1
+ /*!
2
+ * Author : Matteo Bruni
3
+ * MIT license: https://opensource.org/licenses/MIT
4
+ * Demo / Generator : https://particles.js.org/
5
+ * GitHub : https://www.github.com/matteobruni/tsparticles
6
+ * How to use? : Check the GitHub README
7
+ * v3.0.0-alpha.0
8
+ */
9
+ (function webpackUniversalModuleDefinition(root, factory) {
10
+ if(typeof exports === 'object' && typeof module === 'object')
11
+ module.exports = factory();
12
+ else if(typeof define === 'function' && define.amd)
13
+ define([], factory);
14
+ else {
15
+ var a = factory();
16
+ for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
17
+ }
18
+ })(this, () => {
19
+ return /******/ (() => { // webpackBootstrap
20
+ /******/ "use strict";
21
+ /******/ // The require scope
22
+ /******/ var __webpack_require__ = {};
23
+ /******/
24
+ /************************************************************************/
25
+ /******/ /* webpack/runtime/define property getters */
26
+ /******/ (() => {
27
+ /******/ // define getter functions for harmony exports
28
+ /******/ __webpack_require__.d = (exports, definition) => {
29
+ /******/ for(var key in definition) {
30
+ /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
31
+ /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
32
+ /******/ }
33
+ /******/ }
34
+ /******/ };
35
+ /******/ })();
36
+ /******/
37
+ /******/ /* webpack/runtime/hasOwnProperty shorthand */
38
+ /******/ (() => {
39
+ /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
40
+ /******/ })();
41
+ /******/
42
+ /******/ /* webpack/runtime/make namespace object */
43
+ /******/ (() => {
44
+ /******/ // define __esModule on exports
45
+ /******/ __webpack_require__.r = (exports) => {
46
+ /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
47
+ /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
48
+ /******/ }
49
+ /******/ Object.defineProperty(exports, '__esModule', { value: true });
50
+ /******/ };
51
+ /******/ })();
52
+ /******/
53
+ /************************************************************************/
54
+ var __webpack_exports__ = {};
55
+ // ESM COMPAT FLAG
56
+ __webpack_require__.r(__webpack_exports__);
57
+
58
+ // EXPORTS
59
+ __webpack_require__.d(__webpack_exports__, {
60
+ "loadRoundedRectShape": () => (/* binding */ loadRoundedRectShape)
61
+ });
62
+
63
+ ;// CONCATENATED MODULE: ./dist/browser/RoundedRectDrawer.js
64
+ const drawRoundedRect = (ctx, info, radius = {
65
+ topRight: 4,
66
+ bottomRight: 4,
67
+ bottomLeft: 4,
68
+ topLeft: 4
69
+ }) => {
70
+ const {
71
+ x,
72
+ y,
73
+ width,
74
+ height
75
+ } = info;
76
+ const r = x + width;
77
+ const b = y + height;
78
+ ctx.moveTo(x + radius.topLeft, y);
79
+ ctx.lineTo(r - radius.topRight, y);
80
+ ctx.quadraticCurveTo(r, y, r, y + radius.topRight);
81
+ ctx.lineTo(r, y + height - radius.bottomRight);
82
+ ctx.quadraticCurveTo(r, b, r - radius.bottomRight, b);
83
+ ctx.lineTo(x + radius.bottomLeft, b);
84
+ ctx.quadraticCurveTo(x, b, x, b - radius.bottomLeft);
85
+ ctx.lineTo(x, y + radius.topLeft);
86
+ ctx.quadraticCurveTo(x, y, x + radius.topLeft, y);
87
+ };
88
+ class RoundedRectDrawer {
89
+ draw(context, particle, radius) {
90
+ const roundedRect = particle;
91
+ drawRoundedRect(context, {
92
+ x: 0,
93
+ y: 0,
94
+ height: radius,
95
+ width: radius
96
+ }, {
97
+ topLeft: roundedRect.borderRadius,
98
+ topRight: roundedRect.borderRadius,
99
+ bottomLeft: roundedRect.borderRadius,
100
+ bottomRight: roundedRect.borderRadius
101
+ });
102
+ }
103
+ particleInit(container, particle) {
104
+ var _a;
105
+ const shapeData = particle.shapeData;
106
+ const roundedRect = particle;
107
+ roundedRect.borderRadius = ((_a = shapeData === null || shapeData === void 0 ? void 0 : shapeData.radius) !== null && _a !== void 0 ? _a : 4) * container.retina.pixelRatio;
108
+ }
109
+ }
110
+ ;// CONCATENATED MODULE: ./dist/browser/index.js
111
+
112
+ function loadRoundedRectShape(engine) {
113
+ engine.addShape("rounded-rect", new RoundedRectDrawer());
114
+ }
115
+ /******/ return __webpack_exports__;
116
+ /******/ })()
117
+ ;
118
+ });
@@ -0,0 +1,2 @@
1
+ /*! For license information please see tsparticles.shape.rounded-rect.min.js.LICENSE.txt */
2
+ !function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var o=e();for(var r in o)("object"==typeof exports?exports:t)[r]=o[r]}}(this,(()=>(()=>{"use strict";var t={d:(e,o)=>{for(var r in o)t.o(o,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:o[r]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{loadRoundedRectShape:()=>r});class o{draw(t,e,o){const r=e;((t,e,o={topRight:4,bottomRight:4,bottomLeft:4,topLeft:4})=>{const{x:r,y:i,width:d,height:a}=e,n=r+d,u=i+a;t.moveTo(r+o.topLeft,i),t.lineTo(n-o.topRight,i),t.quadraticCurveTo(n,i,n,i+o.topRight),t.lineTo(n,i+a-o.bottomRight),t.quadraticCurveTo(n,u,n-o.bottomRight,u),t.lineTo(r+o.bottomLeft,u),t.quadraticCurveTo(r,u,r,u-o.bottomLeft),t.lineTo(r,i+o.topLeft),t.quadraticCurveTo(r,i,r+o.topLeft,i)})(t,{x:0,y:0,height:o,width:o},{topLeft:r.borderRadius,topRight:r.borderRadius,bottomLeft:r.borderRadius,bottomRight:r.borderRadius})}particleInit(t,e){var o;const r=e.shapeData;e.borderRadius=(null!==(o=null==r?void 0:r.radius)&&void 0!==o?o:4)*t.retina.pixelRatio}}function r(t){t.addShape("rounded-rect",new o)}return e})()));
@@ -0,0 +1,8 @@
1
+ /*!
2
+ * Author : Matteo Bruni
3
+ * MIT license: https://opensource.org/licenses/MIT
4
+ * Demo / Generator : https://particles.js.org/
5
+ * GitHub : https://www.github.com/matteobruni/tsparticles
6
+ * How to use? : Check the GitHub README
7
+ * v3.0.0-alpha.0
8
+ */
@@ -0,0 +1,4 @@
1
+ import type { IParticle } from "@tsparticles/engine";
2
+ export interface IRoundedParticle extends IParticle {
3
+ borderRadius: number;
4
+ }
@@ -0,0 +1,4 @@
1
+ import type { IShapeValues } from "@tsparticles/engine";
2
+ export interface IRoundedRectData extends IShapeValues {
3
+ radius: number;
4
+ }
@@ -0,0 +1,6 @@
1
+ export type RadiusInfo = {
2
+ bottomLeft: number;
3
+ bottomRight: number;
4
+ topLeft: number;
5
+ topRight: number;
6
+ };
@@ -0,0 +1,6 @@
1
+ export type RectInfo = {
2
+ height: number;
3
+ width: number;
4
+ x: number;
5
+ y: number;
6
+ };
@@ -0,0 +1,5 @@
1
+ import type { Container, IParticle, IShapeDrawer } from "@tsparticles/engine";
2
+ export declare class RoundedRectDrawer implements IShapeDrawer {
3
+ draw(context: CanvasRenderingContext2D, particle: IParticle, radius: number): void;
4
+ particleInit(container: Container, particle: IParticle): void;
5
+ }
@@ -0,0 +1,2 @@
1
+ import type { Engine } from "@tsparticles/engine";
2
+ export declare function loadRoundedRectShape(engine: Engine): void;
@@ -0,0 +1,12 @@
1
+ (function (factory) {
2
+ if (typeof module === "object" && typeof module.exports === "object") {
3
+ var v = factory(require, exports);
4
+ if (v !== undefined) module.exports = v;
5
+ }
6
+ else if (typeof define === "function" && define.amd) {
7
+ define(["require", "exports"], factory);
8
+ }
9
+ })(function (require, exports) {
10
+ "use strict";
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ });
@@ -0,0 +1,12 @@
1
+ (function (factory) {
2
+ if (typeof module === "object" && typeof module.exports === "object") {
3
+ var v = factory(require, exports);
4
+ if (v !== undefined) module.exports = v;
5
+ }
6
+ else if (typeof define === "function" && define.amd) {
7
+ define(["require", "exports"], factory);
8
+ }
9
+ })(function (require, exports) {
10
+ "use strict";
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ });
@@ -0,0 +1,12 @@
1
+ (function (factory) {
2
+ if (typeof module === "object" && typeof module.exports === "object") {
3
+ var v = factory(require, exports);
4
+ if (v !== undefined) module.exports = v;
5
+ }
6
+ else if (typeof define === "function" && define.amd) {
7
+ define(["require", "exports"], factory);
8
+ }
9
+ })(function (require, exports) {
10
+ "use strict";
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ });
@@ -0,0 +1,12 @@
1
+ (function (factory) {
2
+ if (typeof module === "object" && typeof module.exports === "object") {
3
+ var v = factory(require, exports);
4
+ if (v !== undefined) module.exports = v;
5
+ }
6
+ else if (typeof define === "function" && define.amd) {
7
+ define(["require", "exports"], factory);
8
+ }
9
+ })(function (require, exports) {
10
+ "use strict";
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ });
@@ -0,0 +1,55 @@
1
+ (function (factory) {
2
+ if (typeof module === "object" && typeof module.exports === "object") {
3
+ var v = factory(require, exports);
4
+ if (v !== undefined) module.exports = v;
5
+ }
6
+ else if (typeof define === "function" && define.amd) {
7
+ define(["require", "exports"], factory);
8
+ }
9
+ })(function (require, exports) {
10
+ "use strict";
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.RoundedRectDrawer = void 0;
13
+ const drawRoundedRect = (ctx, info, radius = {
14
+ topRight: 4,
15
+ bottomRight: 4,
16
+ bottomLeft: 4,
17
+ topLeft: 4,
18
+ }) => {
19
+ const { x, y, width, height } = info;
20
+ const r = x + width;
21
+ const b = y + height;
22
+ ctx.moveTo(x + radius.topLeft, y);
23
+ ctx.lineTo(r - radius.topRight, y);
24
+ ctx.quadraticCurveTo(r, y, r, y + radius.topRight);
25
+ ctx.lineTo(r, y + height - radius.bottomRight);
26
+ ctx.quadraticCurveTo(r, b, r - radius.bottomRight, b);
27
+ ctx.lineTo(x + radius.bottomLeft, b);
28
+ ctx.quadraticCurveTo(x, b, x, b - radius.bottomLeft);
29
+ ctx.lineTo(x, y + radius.topLeft);
30
+ ctx.quadraticCurveTo(x, y, x + radius.topLeft, y);
31
+ };
32
+ class RoundedRectDrawer {
33
+ draw(context, particle, radius) {
34
+ const roundedRect = particle;
35
+ drawRoundedRect(context, {
36
+ x: 0,
37
+ y: 0,
38
+ height: radius,
39
+ width: radius,
40
+ }, {
41
+ topLeft: roundedRect.borderRadius,
42
+ topRight: roundedRect.borderRadius,
43
+ bottomLeft: roundedRect.borderRadius,
44
+ bottomRight: roundedRect.borderRadius,
45
+ });
46
+ }
47
+ particleInit(container, particle) {
48
+ var _a;
49
+ const shapeData = particle.shapeData;
50
+ const roundedRect = particle;
51
+ roundedRect.borderRadius = ((_a = shapeData === null || shapeData === void 0 ? void 0 : shapeData.radius) !== null && _a !== void 0 ? _a : 4) * container.retina.pixelRatio;
52
+ }
53
+ }
54
+ exports.RoundedRectDrawer = RoundedRectDrawer;
55
+ });
package/umd/index.js ADDED
@@ -0,0 +1,18 @@
1
+ (function (factory) {
2
+ if (typeof module === "object" && typeof module.exports === "object") {
3
+ var v = factory(require, exports);
4
+ if (v !== undefined) module.exports = v;
5
+ }
6
+ else if (typeof define === "function" && define.amd) {
7
+ define(["require", "exports", "./RoundedRectDrawer"], factory);
8
+ }
9
+ })(function (require, exports) {
10
+ "use strict";
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.loadRoundedRectShape = void 0;
13
+ const RoundedRectDrawer_1 = require("./RoundedRectDrawer");
14
+ function loadRoundedRectShape(engine) {
15
+ engine.addShape("rounded-rect", new RoundedRectDrawer_1.RoundedRectDrawer());
16
+ }
17
+ exports.loadRoundedRectShape = loadRoundedRectShape;
18
+ });