@tsparticles/shape-cog 3.0.0-beta.2 → 3.0.0-beta.4
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/browser/CogDrawer.js +16 -14
- package/cjs/CogDrawer.js +16 -14
- package/esm/CogDrawer.js +16 -14
- package/package.json +3 -3
- package/report.html +4 -22
- package/tsparticles.shape.cog.js +25 -15
- package/tsparticles.shape.cog.min.js +1 -1
- package/tsparticles.shape.cog.min.js.LICENSE.txt +1 -1
- package/types/CogDrawer.d.ts +4 -4
- package/umd/CogDrawer.js +16 -14
package/tsparticles.shape.cog.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Demo / Generator : https://particles.js.org/
|
|
5
5
|
* GitHub : https://www.github.com/matteobruni/tsparticles
|
|
6
6
|
* How to use? : Check the GitHub README
|
|
7
|
-
* v3.0.0-beta.
|
|
7
|
+
* v3.0.0-beta.4
|
|
8
8
|
*/
|
|
9
9
|
(function webpackUniversalModuleDefinition(root, factory) {
|
|
10
10
|
if(typeof exports === 'object' && typeof module === 'object')
|
|
@@ -99,21 +99,31 @@ var engine_root_window_ = __webpack_require__(533);
|
|
|
99
99
|
;// CONCATENATED MODULE: ./dist/browser/CogDrawer.js
|
|
100
100
|
|
|
101
101
|
class CogDrawer {
|
|
102
|
-
|
|
102
|
+
afterDraw(data) {
|
|
103
|
+
const {
|
|
104
|
+
context,
|
|
105
|
+
particle,
|
|
106
|
+
radius
|
|
107
|
+
} = data;
|
|
103
108
|
if (particle.cogHoleRadius === undefined || particle.cogInnerRadius === undefined || particle.cogInnerTaper === undefined || particle.cogNotches === undefined || particle.cogOuterTaper === undefined) {
|
|
104
109
|
return;
|
|
105
110
|
}
|
|
106
111
|
const pi2 = 2 * Math.PI,
|
|
107
112
|
holeRadius = radius * particle.cogHoleRadius / 100;
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
113
|
+
context.globalCompositeOperation = "destination-out";
|
|
114
|
+
context.beginPath();
|
|
115
|
+
context.moveTo(holeRadius, 0);
|
|
116
|
+
context.arc(0, 0, holeRadius, 0, pi2);
|
|
117
|
+
context.closePath();
|
|
118
|
+
context.fill();
|
|
119
|
+
context.globalCompositeOperation = "source-over";
|
|
115
120
|
}
|
|
116
|
-
draw(
|
|
121
|
+
draw(data) {
|
|
122
|
+
const {
|
|
123
|
+
context,
|
|
124
|
+
particle,
|
|
125
|
+
radius
|
|
126
|
+
} = data;
|
|
117
127
|
if (particle.cogHoleRadius === undefined || particle.cogInnerRadius === undefined || particle.cogInnerTaper === undefined || particle.cogNotches === undefined || particle.cogOuterTaper === undefined) {
|
|
118
128
|
return;
|
|
119
129
|
}
|
|
@@ -124,14 +134,14 @@ class CogDrawer {
|
|
|
124
134
|
innerRadius = radius * particle.cogInnerRadius / 100;
|
|
125
135
|
let a = angle,
|
|
126
136
|
toggle = false;
|
|
127
|
-
|
|
137
|
+
context.moveTo(radius * Math.cos(taperAO), radius * Math.sin(taperAO));
|
|
128
138
|
for (; a <= pi2; a += angle) {
|
|
129
139
|
if (toggle) {
|
|
130
|
-
|
|
131
|
-
|
|
140
|
+
context.lineTo(innerRadius * Math.cos(a - taperAI), innerRadius * Math.sin(a - taperAI));
|
|
141
|
+
context.lineTo(radius * Math.cos(a + taperAO), radius * Math.sin(a + taperAO));
|
|
132
142
|
} else {
|
|
133
|
-
|
|
134
|
-
|
|
143
|
+
context.lineTo(radius * Math.cos(a - taperAO), radius * Math.sin(a - taperAO));
|
|
144
|
+
context.lineTo(innerRadius * Math.cos(a + taperAI), innerRadius * Math.sin(a + taperAI));
|
|
135
145
|
}
|
|
136
146
|
toggle = !toggle;
|
|
137
147
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! For license information please see tsparticles.shape.cog.min.js.LICENSE.txt */
|
|
2
|
-
!function(e,o){if("object"==typeof exports&&"object"==typeof module)module.exports=o(require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine"],o);else{var t="object"==typeof exports?o(require("@tsparticles/engine")):o(e.window);for(var r in t)("object"==typeof exports?exports:e)[r]=t[r]}}(this,(e=>(()=>{"use strict";var o={533:o=>{o.exports=e}},t={};function r(e){var a=t[e];if(void 0!==a)return a.exports;var n=t[e]={exports:{}};return o[e](n,n.exports,r),n.exports}r.d=(e,o)=>{for(var t in o)r.o(o,t)&&!r.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:o[t]})},r.o=(e,o)=>Object.prototype.hasOwnProperty.call(e,o),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var a={};return(()=>{r.r(a),r.d(a,{loadCogShape:()=>t});var e=r(533);class o{
|
|
2
|
+
!function(e,o){if("object"==typeof exports&&"object"==typeof module)module.exports=o(require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine"],o);else{var t="object"==typeof exports?o(require("@tsparticles/engine")):o(e.window);for(var r in t)("object"==typeof exports?exports:e)[r]=t[r]}}(this,(e=>(()=>{"use strict";var o={533:o=>{o.exports=e}},t={};function r(e){var a=t[e];if(void 0!==a)return a.exports;var n=t[e]={exports:{}};return o[e](n,n.exports,r),n.exports}r.d=(e,o)=>{for(var t in o)r.o(o,t)&&!r.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:o[t]})},r.o=(e,o)=>Object.prototype.hasOwnProperty.call(e,o),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var a={};return(()=>{r.r(a),r.d(a,{loadCogShape:()=>t});var e=r(533);class o{afterDraw(e){const{context:o,particle:t,radius:r}=e;if(void 0===t.cogHoleRadius||void 0===t.cogInnerRadius||void 0===t.cogInnerTaper||void 0===t.cogNotches||void 0===t.cogOuterTaper)return;const a=2*Math.PI,n=r*t.cogHoleRadius/100;o.globalCompositeOperation="destination-out",o.beginPath(),o.moveTo(n,0),o.arc(0,0,n,0,a),o.closePath(),o.fill(),o.globalCompositeOperation="source-over"}draw(e){const{context:o,particle:t,radius:r}=e;if(void 0===t.cogHoleRadius||void 0===t.cogInnerRadius||void 0===t.cogInnerTaper||void 0===t.cogNotches||void 0===t.cogOuterTaper)return;const a=2*Math.PI,n=a/(2*t.cogNotches),i=n*t.cogInnerTaper*.005,s=n*t.cogOuterTaper*.005,c=r*t.cogInnerRadius/100;let p=n,d=!1;for(o.moveTo(r*Math.cos(s),r*Math.sin(s));p<=a;p+=n)d?(o.lineTo(c*Math.cos(p-i),c*Math.sin(p-i)),o.lineTo(r*Math.cos(p+s),r*Math.sin(p+s))):(o.lineTo(r*Math.cos(p-s),r*Math.sin(p-s)),o.lineTo(c*Math.cos(p+i),c*Math.sin(p+i))),d=!d}particleInit(o,t){const r=t.shapeData;t.cogHoleRadius=(0,e.getRangeValue)(r?.holeRadius??44),t.cogInnerRadius=(0,e.getRangeValue)(r?.innerRadius??72),t.cogInnerTaper=(0,e.getRangeValue)(r?.innerTaper??35),t.cogNotches=(0,e.getRangeValue)(r?.notches??7),t.cogOuterTaper=(0,e.getRangeValue)(r?.outerTaper??50)}}async function t(e,t=!0){await e.addShape("cog",new o,t)}})(),a})()));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
/*! tsParticles Cog Shape v3.0.0-beta.
|
|
1
|
+
/*! tsParticles Cog Shape v3.0.0-beta.4 by Matteo Bruni */
|
package/types/CogDrawer.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { type Container, type IShapeDrawer } from "@tsparticles/engine";
|
|
1
|
+
import { type Container, type IShapeDrawData, type IShapeDrawer } from "@tsparticles/engine";
|
|
2
2
|
import type { CogParticle } from "./CogParticle.js";
|
|
3
|
-
export declare class CogDrawer implements IShapeDrawer {
|
|
4
|
-
|
|
5
|
-
draw(
|
|
3
|
+
export declare class CogDrawer implements IShapeDrawer<CogParticle> {
|
|
4
|
+
afterDraw(data: IShapeDrawData<CogParticle>): void;
|
|
5
|
+
draw(data: IShapeDrawData<CogParticle>): void;
|
|
6
6
|
particleInit(container: Container, particle: CogParticle): void;
|
|
7
7
|
}
|
package/umd/CogDrawer.js
CHANGED
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
exports.CogDrawer = void 0;
|
|
13
13
|
const engine_1 = require("@tsparticles/engine");
|
|
14
14
|
class CogDrawer {
|
|
15
|
-
|
|
15
|
+
afterDraw(data) {
|
|
16
|
+
const { context, particle, radius } = data;
|
|
16
17
|
if (particle.cogHoleRadius === undefined ||
|
|
17
18
|
particle.cogInnerRadius === undefined ||
|
|
18
19
|
particle.cogInnerTaper === undefined ||
|
|
@@ -21,15 +22,16 @@
|
|
|
21
22
|
return;
|
|
22
23
|
}
|
|
23
24
|
const pi2 = 2 * Math.PI, holeRadius = (radius * particle.cogHoleRadius) / 100;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
25
|
+
context.globalCompositeOperation = "destination-out";
|
|
26
|
+
context.beginPath();
|
|
27
|
+
context.moveTo(holeRadius, 0);
|
|
28
|
+
context.arc(0, 0, holeRadius, 0, pi2);
|
|
29
|
+
context.closePath();
|
|
30
|
+
context.fill();
|
|
31
|
+
context.globalCompositeOperation = "source-over";
|
|
31
32
|
}
|
|
32
|
-
draw(
|
|
33
|
+
draw(data) {
|
|
34
|
+
const { context, particle, radius } = data;
|
|
33
35
|
if (particle.cogHoleRadius === undefined ||
|
|
34
36
|
particle.cogInnerRadius === undefined ||
|
|
35
37
|
particle.cogInnerTaper === undefined ||
|
|
@@ -39,15 +41,15 @@
|
|
|
39
41
|
}
|
|
40
42
|
const pi2 = 2 * Math.PI, angle = pi2 / (particle.cogNotches * 2), taperAI = angle * particle.cogInnerTaper * 0.005, taperAO = angle * particle.cogOuterTaper * 0.005, innerRadius = (radius * particle.cogInnerRadius) / 100;
|
|
41
43
|
let a = angle, toggle = false;
|
|
42
|
-
|
|
44
|
+
context.moveTo(radius * Math.cos(taperAO), radius * Math.sin(taperAO));
|
|
43
45
|
for (; a <= pi2; a += angle) {
|
|
44
46
|
if (toggle) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
+
context.lineTo(innerRadius * Math.cos(a - taperAI), innerRadius * Math.sin(a - taperAI));
|
|
48
|
+
context.lineTo(radius * Math.cos(a + taperAO), radius * Math.sin(a + taperAO));
|
|
47
49
|
}
|
|
48
50
|
else {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
+
context.lineTo(radius * Math.cos(a - taperAO), radius * Math.sin(a - taperAO));
|
|
52
|
+
context.lineTo(innerRadius * Math.cos(a + taperAI), innerRadius * Math.sin(a + taperAI));
|
|
51
53
|
}
|
|
52
54
|
toggle = !toggle;
|
|
53
55
|
}
|