@cycjimmy/canvas-snow 1.0.5 → 2.0.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/package.json CHANGED
@@ -1,13 +1,22 @@
1
1
  {
2
2
  "name": "@cycjimmy/canvas-snow",
3
- "version": "1.0.5",
3
+ "version": "2.0.0",
4
4
  "description": "Generates snow in canvas.",
5
- "main": "build/canvas-snow.min.js",
5
+ "type": "module",
6
+ "main": "dist/canvas-snow.cjs.js",
7
+ "module": "dist/canvas-snow.esm.js",
8
+ "browser": "dist/canvas-snow.umd.min.js",
6
9
  "scripts": {
7
- "test": "jest",
8
- "start": "cross-env NODE_ENV=development webpack --display-modules --display-reasons --display-error-details --watch --color",
9
- "build": "cross-env NODE_ENV=production webpack --progress --optimize-minimize && webpack --progress --display-modules --display-reasons --display-error-details --color",
10
- "build:dev": "cross-env NODE_ENV=development webpack --display-modules --display-reasons --display-error-details --color"
10
+ "start": "npm run dev",
11
+ "test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --color --forceExit --detectOpenHandles",
12
+ "coveralls": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --color --forceExit --detectOpenHandles --coverage",
13
+ "lint": "eslint --ext .js,.cjs,.mjs -c .eslintrc .",
14
+ "lint:fix": "eslint --ext .js,.cjs,.mjs --fix -c .eslintrc . --fix",
15
+ "dev": "cross-env NODE_ENV=development rollup -c rollup/rollup.config.dev.mjs --watch",
16
+ "build": "npm run build:prod:umd && npm run build:prod",
17
+ "build:prod": "cross-env NODE_ENV=production rollup -c rollup/rollup.config.prod.mjs",
18
+ "build:prod:umd": "cross-env NODE_ENV=production rollup -c rollup/rollup.config.dev.mjs",
19
+ "build:deployment": "cross-env NODE_ENV=deployment rollup -c rollup/rollup.config.dev.mjs"
11
20
  },
12
21
  "repository": {
13
22
  "type": "git",
@@ -24,36 +33,40 @@
24
33
  "url": "https://github.com/cycjimmy/canvas-snow/issues"
25
34
  },
26
35
  "homepage": "https://github.com/cycjimmy/canvas-snow#readme",
36
+ "files": [
37
+ "/dist"
38
+ ],
39
+ "publishConfig": {
40
+ "access": "public"
41
+ },
27
42
  "dependencies": {
28
- "@cycjimmy/awesome-js-funcs": "^1.1.1"
43
+ "@cycjimmy/awesome-js-funcs": "^4.0.4"
29
44
  },
30
45
  "devDependencies": {
31
- "@babel/core": "^7.6.4",
32
- "@babel/plugin-syntax-dynamic-import": "^7.2.0",
33
- "@babel/preset-env": "^7.6.3",
34
- "@cycjimmy/config-lib": "^1.2.0",
35
- "autoprefixer": "^9.6.5",
36
- "babel-jest": "^24.9.0",
37
- "babel-loader": "^8.0.6",
38
- "browser-sync": "^2.26.7",
39
- "browser-sync-webpack-plugin": "^2.2.2",
40
- "clean-webpack-plugin": "^3.0.0",
41
- "cross-env": "^6.0.3",
42
- "cz-conventional-changelog": "^3.0.2",
43
- "html-webpack-plugin": "^3.2.0",
44
- "jest": "^24.9.0",
45
- "pug": "^2.0.4",
46
- "pug-loader": "^2.4.0",
47
- "regenerator-runtime": "^0.13.3",
48
- "sass-loader": "^8.0.0",
49
- "style-loader": "^1.0.0",
50
- "terser-webpack-plugin": "^2.2.1",
51
- "webpack": "^4.41.2",
52
- "webpack-cli": "^3.3.9"
53
- },
54
- "config": {
55
- "commitizen": {
56
- "path": "./node_modules/cz-conventional-changelog"
57
- }
46
+ "@babel/core": "^7.17.7",
47
+ "@babel/plugin-syntax-dynamic-import": "^7.8.3",
48
+ "@babel/preset-env": "^7.16.11",
49
+ "@cycjimmy/config-lib": "^3.0.5",
50
+ "@jest/globals": "^27.5.1",
51
+ "@rollup/plugin-babel": "^5.3.1",
52
+ "@rollup/plugin-commonjs": "^21.0.2",
53
+ "@rollup/plugin-eslint": "^8.0.1",
54
+ "@rollup/plugin-json": "^4.1.0",
55
+ "@rollup/plugin-node-resolve": "^13.1.3",
56
+ "autoprefixer": "^10.4.3",
57
+ "babel-jest": "^27.5.1",
58
+ "coveralls": "^3.1.1",
59
+ "cross-env": "^7.0.3",
60
+ "eslint": "^8.11.0",
61
+ "eslint-config-airbnb-base": "^15.0.0",
62
+ "eslint-plugin-import": "^2.25.4",
63
+ "jest": "^27.5.1",
64
+ "jest-canvas-mock": "^2.3.1",
65
+ "node-sass": "^7.0.1",
66
+ "rollup": "^2.70.1",
67
+ "rollup-plugin-browsersync": "^1.3.3",
68
+ "rollup-plugin-copy": "^3.4.0",
69
+ "rollup-plugin-postcss": "^4.0.2",
70
+ "rollup-plugin-terser": "^7.0.2"
58
71
  }
59
72
  }
package/.babelrc DELETED
@@ -1,26 +0,0 @@
1
- {
2
- "presets": [
3
- [
4
- "@babel/preset-env",
5
- {
6
- "loose": true,
7
- "modules": false
8
- }
9
- ]
10
- ],
11
- "env": {
12
- "test": {
13
- "presets": [
14
- [
15
- "@babel/preset-env"
16
- ]
17
- ]
18
- }
19
- },
20
- "plugins": [
21
- "@babel/plugin-syntax-dynamic-import"
22
- ],
23
- "ignore": [
24
- "node_modules"
25
- ]
26
- }
package/.browserslistrc DELETED
@@ -1,13 +0,0 @@
1
- [production staging]
2
- last 4 versions
3
- ie >= 10
4
- ie_mob >= 10
5
- ff >= 30
6
- chrome >= 40
7
- safari >= 8
8
- opera >= 23
9
- ios >= 8
10
- android >= 4.4
11
-
12
- [development]
13
- last 2 versions
package/.gitattributes DELETED
@@ -1,17 +0,0 @@
1
- # Auto detect text files and perform LF normalization
2
- * text=auto
3
-
4
- # Custom for Visual Studio
5
- *.cs diff=csharp
6
-
7
- # Standard to msysgit
8
- *.doc diff=astextplain
9
- *.DOC diff=astextplain
10
- *.docx diff=astextplain
11
- *.DOCX diff=astextplain
12
- *.dot diff=astextplain
13
- *.DOT diff=astextplain
14
- *.pdf diff=astextplain
15
- *.PDF diff=astextplain
16
- *.rtf diff=astextplain
17
- *.RTF diff=astextplain
@@ -1,46 +0,0 @@
1
- # Contributor Covenant Code of Conduct
2
-
3
- ## Our Pledge
4
-
5
- In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
-
7
- ## Our Standards
8
-
9
- Examples of behavior that contributes to creating a positive environment include:
10
-
11
- * Using welcoming and inclusive language
12
- * Being respectful of differing viewpoints and experiences
13
- * Gracefully accepting constructive criticism
14
- * Focusing on what is best for the community
15
- * Showing empathy towards other community members
16
-
17
- Examples of unacceptable behavior by participants include:
18
-
19
- * The use of sexualized language or imagery and unwelcome sexual attention or advances
20
- * Trolling, insulting/derogatory comments, and personal or political attacks
21
- * Public or private harassment
22
- * Publishing others' private information, such as a physical or electronic address, without explicit permission
23
- * Other conduct which could reasonably be considered inappropriate in a professional setting
24
-
25
- ## Our Responsibilities
26
-
27
- Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
28
-
29
- Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
30
-
31
- ## Scope
32
-
33
- This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
34
-
35
- ## Enforcement
36
-
37
- Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at cycjimmy@gmail.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
38
-
39
- Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
40
-
41
- ## Attribution
42
-
43
- This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
44
-
45
- [homepage]: http://contributor-covenant.org
46
- [version]: http://contributor-covenant.org/version/1/4/
@@ -1,410 +0,0 @@
1
- /*!
2
- * @cycjimmy/canvas-snow v1.0.5
3
- * Homepage: https://github.com/cycjimmy/canvas-snow#readme
4
- * Released under the MIT License.
5
- */
6
- (function webpackUniversalModuleDefinition(root, factory) {
7
- if(typeof exports === 'object' && typeof module === 'object')
8
- module.exports = factory();
9
- else if(typeof define === 'function' && define.amd)
10
- define([], factory);
11
- else if(typeof exports === 'object')
12
- exports["CanvasSnow"] = factory();
13
- else
14
- root["CanvasSnow"] = factory();
15
- })(window, function() {
16
- return /******/ (function(modules) { // webpackBootstrap
17
- /******/ // The module cache
18
- /******/ var installedModules = {};
19
- /******/
20
- /******/ // The require function
21
- /******/ function __webpack_require__(moduleId) {
22
- /******/
23
- /******/ // Check if module is in cache
24
- /******/ if(installedModules[moduleId]) {
25
- /******/ return installedModules[moduleId].exports;
26
- /******/ }
27
- /******/ // Create a new module (and put it into the cache)
28
- /******/ var module = installedModules[moduleId] = {
29
- /******/ i: moduleId,
30
- /******/ l: false,
31
- /******/ exports: {}
32
- /******/ };
33
- /******/
34
- /******/ // Execute the module function
35
- /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
36
- /******/
37
- /******/ // Flag the module as loaded
38
- /******/ module.l = true;
39
- /******/
40
- /******/ // Return the exports of the module
41
- /******/ return module.exports;
42
- /******/ }
43
- /******/
44
- /******/
45
- /******/ // expose the modules object (__webpack_modules__)
46
- /******/ __webpack_require__.m = modules;
47
- /******/
48
- /******/ // expose the module cache
49
- /******/ __webpack_require__.c = installedModules;
50
- /******/
51
- /******/ // define getter function for harmony exports
52
- /******/ __webpack_require__.d = function(exports, name, getter) {
53
- /******/ if(!__webpack_require__.o(exports, name)) {
54
- /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
55
- /******/ }
56
- /******/ };
57
- /******/
58
- /******/ // define __esModule on exports
59
- /******/ __webpack_require__.r = function(exports) {
60
- /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
61
- /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
62
- /******/ }
63
- /******/ Object.defineProperty(exports, '__esModule', { value: true });
64
- /******/ };
65
- /******/
66
- /******/ // create a fake namespace object
67
- /******/ // mode & 1: value is a module id, require it
68
- /******/ // mode & 2: merge all properties of value into the ns
69
- /******/ // mode & 4: return value when already ns object
70
- /******/ // mode & 8|1: behave like require
71
- /******/ __webpack_require__.t = function(value, mode) {
72
- /******/ if(mode & 1) value = __webpack_require__(value);
73
- /******/ if(mode & 8) return value;
74
- /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
75
- /******/ var ns = Object.create(null);
76
- /******/ __webpack_require__.r(ns);
77
- /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
78
- /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
79
- /******/ return ns;
80
- /******/ };
81
- /******/
82
- /******/ // getDefaultExport function for compatibility with non-harmony modules
83
- /******/ __webpack_require__.n = function(module) {
84
- /******/ var getter = module && module.__esModule ?
85
- /******/ function getDefault() { return module['default']; } :
86
- /******/ function getModuleExports() { return module; };
87
- /******/ __webpack_require__.d(getter, 'a', getter);
88
- /******/ return getter;
89
- /******/ };
90
- /******/
91
- /******/ // Object.prototype.hasOwnProperty.call
92
- /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
93
- /******/
94
- /******/ // __webpack_public_path__
95
- /******/ __webpack_require__.p = "";
96
- /******/
97
- /******/
98
- /******/ // Load entry module and return exports
99
- /******/ return __webpack_require__(__webpack_require__.s = 0);
100
- /******/ })
101
- /************************************************************************/
102
- /******/ ([
103
- /* 0 */
104
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
105
-
106
- "use strict";
107
- __webpack_require__.r(__webpack_exports__);
108
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return CanvasSnow; });
109
- /* harmony import */ var _cycjimmy_awesome_js_funcs_judgeBasic_isString__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1);
110
- /* harmony import */ var _Snow__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(2);
111
- /* harmony import */ var _SnowList__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(3);
112
-
113
-
114
-
115
-
116
- var CanvasSnow =
117
- /*#__PURE__*/
118
- function () {
119
- function CanvasSnow(_ref) {
120
- var context = _ref.context,
121
- _ref$width = _ref.width,
122
- width = _ref$width === void 0 ? '100%' : _ref$width,
123
- _ref$height = _ref.height,
124
- height = _ref$height === void 0 ? '100%' : _ref$height,
125
- cell = _ref.cell;
126
- this.context = Object(_cycjimmy_awesome_js_funcs_judgeBasic_isString__WEBPACK_IMPORTED_MODULE_0__["default"])(context) ? document.querySelector(context) : context;
127
- this.width = _getHorizontalDistance(this.context, width);
128
- this.height = _getVerticalDistance(this.context, height);
129
- this.cell = cell;
130
- this.state = 'stop';
131
- this.snowList = null;
132
- this.canvas = null;
133
- this.cxt = null;
134
- this.interval = null;
135
- }
136
-
137
- var _proto = CanvasSnow.prototype;
138
-
139
- _proto.init = function init() {
140
- if (!this.canvas) {
141
- this._initCanvas();
142
- }
143
-
144
- if (!this.snowList) {
145
- this.snowList = new _SnowList__WEBPACK_IMPORTED_MODULE_2__["default"]();
146
-
147
- this._newSnow();
148
- }
149
-
150
- return this;
151
- };
152
-
153
- _proto._initCanvas = function _initCanvas() {
154
- this.canvas = document.createElement('canvas');
155
- this.context.appendChild(this.canvas);
156
- this.canvas.height = this.height;
157
- this.canvas.width = this.width;
158
- this.cxt = this.canvas.getContext('2d');
159
- };
160
-
161
- /**
162
- * animation start
163
- */
164
- _proto.start = function start() {
165
- var _this = this;
166
-
167
- if (!this.snowList) {
168
- this.init();
169
- }
170
-
171
- this.state = 'play';
172
- this.interval = setInterval(function () {
173
- _this.cxt.clearRect(0, 0, _this.canvas.width, _this.canvas.height);
174
-
175
- _this.snowList.update();
176
-
177
- _this.snowList.draw(_this.cxt);
178
- }, 13);
179
- };
180
-
181
- /**
182
- * animation stop
183
- */
184
- _proto.stop = function stop() {
185
- this.state = 'stop';
186
- clearInterval(this.interval);
187
- this.interval = null;
188
- this.cxt.clearRect(0, 0, this.canvas.width, this.canvas.height);
189
- };
190
-
191
- /**
192
- *
193
- */
194
- _proto.clear = function clear() {
195
- this.stop();
196
- this.snowList = null;
197
- };
198
-
199
- _proto._newSnow = function _newSnow() {
200
- for (var i = 0; i < this.cell; i++) {
201
- var randomX = this._getRandom('x'),
202
- randomY = this._getRandom('y'),
203
- randomR = this._getRandom('r'),
204
- randomFnx = this._getRandom('fnx'),
205
- randomFny = this._getRandom('fny'),
206
- snow = new _Snow__WEBPACK_IMPORTED_MODULE_1__["default"](randomX, randomY, randomR, {
207
- x: randomFnx,
208
- y: randomFny
209
- }, this.width, this.height);
210
-
211
- snow.draw(this.cxt);
212
- this.snowList.push(snow);
213
- }
214
- };
215
-
216
- /**
217
- * Generate random x-pos, y-pos or fn functions
218
- * @param {string} option x|y|fnx|fny
219
- * @return {int|Function}
220
- */
221
- _proto._getRandom = function _getRandom(option) {
222
- var ret, random;
223
-
224
- switch (option) {
225
- case 'x':
226
- ret = Math.random() * this.width;
227
- break;
228
-
229
- case 'y':
230
- ret = (Math.random() - 1) * this.height;
231
- break;
232
-
233
- case 'r':
234
- ret = 2 + Math.random() * 4;
235
- break;
236
-
237
- case 'fnx':
238
- random = 27 + Math.random() * 100;
239
-
240
- ret = function ret(x, y) {
241
- return x + 0.5 * Math.sin(y / random);
242
- };
243
-
244
- break;
245
-
246
- case 'fny':
247
- random = 0.4 + Math.random() * 1.4;
248
-
249
- ret = function ret(x, y) {
250
- return y + random;
251
- };
252
-
253
- break;
254
- }
255
-
256
- return ret;
257
- };
258
-
259
- return CanvasSnow;
260
- }();
261
-
262
-
263
- ; // private
264
-
265
- var _handleDistanceNum = function _handleDistanceNum(num, totalDistance) {
266
- if (num.toString().indexOf('%') !== -1) {
267
- return num.split('%')[0] / 100 * totalDistance;
268
- }
269
-
270
- return Object(_cycjimmy_awesome_js_funcs_judgeBasic_isString__WEBPACK_IMPORTED_MODULE_0__["default"])(num) ? Number(num) : num;
271
- },
272
- _getTotalDistance = function _getTotalDistance(_ref2) {
273
- var el = _ref2.el,
274
- _ref2$tip = _ref2.tip,
275
- tip = _ref2$tip === void 0 ? 'horizontal' : _ref2$tip;
276
-
277
- switch (tip) {
278
- case 'horizontal':
279
- return el.getBoundingClientRect().width;
280
-
281
- case 'vertical':
282
- return el.getBoundingClientRect().height;
283
-
284
- default:
285
- return el.getBoundingClientRect();
286
- }
287
- },
288
- _getVerticalDistance = function _getVerticalDistance(el, num) {
289
- return _handleDistanceNum(num, _getTotalDistance({
290
- el: el,
291
- tip: 'vertical'
292
- }));
293
- },
294
- _getHorizontalDistance = function _getHorizontalDistance(el, num) {
295
- return _handleDistanceNum(num, _getTotalDistance({
296
- el: el,
297
- tip: 'horizontal'
298
- }));
299
- };
300
-
301
- /***/ }),
302
- /* 1 */
303
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
304
-
305
- "use strict";
306
- __webpack_require__.r(__webpack_exports__);
307
- /**
308
- * 判断是否字符串
309
- * @param str
310
- * @returns {boolean}
311
- */
312
- /* harmony default export */ __webpack_exports__["default"] = (function (str) {
313
- return typeof str === 'string' && str.constructor === String;
314
- });
315
-
316
- /***/ }),
317
- /* 2 */
318
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
319
-
320
- "use strict";
321
- __webpack_require__.r(__webpack_exports__);
322
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return _default; });
323
- var _default =
324
- /*#__PURE__*/
325
- function () {
326
- function _default(x, y, radius, fn, canvasW, canvasH) {
327
- this.x = x;
328
- this.y = y;
329
- this.r = radius;
330
- this.fn = fn;
331
- this.canvasW = canvasW;
332
- this.canvasH = canvasH;
333
- }
334
-
335
- var _proto = _default.prototype;
336
-
337
- _proto.update = function update() {
338
- if (this.y > this.canvasH) {
339
- this.x = Math.random() * this.canvasW;
340
- this.y = 0;
341
- } else {
342
- this.x = this.fn.x(this.x, this.y);
343
- this.y = this.fn.y(this.y, this.y);
344
- }
345
- };
346
-
347
- _proto.draw = function draw(cxt) {
348
- var grd = cxt.createRadialGradient(this.x, this.y, 0, this.x, this.y, this.r);
349
- grd.addColorStop(0, 'rgba(255, 255, 255, ' + this.r / 6 * 1 + ')');
350
- grd.addColorStop(.5, 'rgba(255, 255, 255, ' + this.r / 6 * .5 + ')');
351
- grd.addColorStop(1, 'rgba(255, 255, 255, 0)');
352
- cxt.fillStyle = grd;
353
- cxt.fillRect(this.x - this.r, this.y - this.r, this.r * 2, this.r * 2);
354
- };
355
-
356
- return _default;
357
- }();
358
-
359
-
360
- ;
361
-
362
- /***/ }),
363
- /* 3 */
364
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
365
-
366
- "use strict";
367
- __webpack_require__.r(__webpack_exports__);
368
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return _default; });
369
- var _default =
370
- /*#__PURE__*/
371
- function () {
372
- function _default() {
373
- this.list = [];
374
- }
375
-
376
- var _proto = _default.prototype;
377
-
378
- _proto.update = function update() {
379
- for (var i = 0, len = this.size(); i < len; i++) {
380
- this.list[i].update();
381
- }
382
- };
383
-
384
- _proto.push = function push(snow) {
385
- this.list.push(snow);
386
- };
387
-
388
- _proto.draw = function draw(cxt) {
389
- for (var i = 0, len = this.size(); i < len; i++) {
390
- this.list[i].draw(cxt);
391
- }
392
- };
393
-
394
- _proto.get = function get(index) {
395
- return this.list[index];
396
- };
397
-
398
- _proto.size = function size() {
399
- return this.list.length;
400
- };
401
-
402
- return _default;
403
- }();
404
-
405
-
406
- ;
407
-
408
- /***/ })
409
- /******/ ])["default"];
410
- });
@@ -1,6 +0,0 @@
1
- /*!
2
- * @cycjimmy/canvas-snow v1.0.5
3
- * Homepage: https://github.com/cycjimmy/canvas-snow#readme
4
- * Released under the MIT License.
5
- */
6
- !function(t,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports.CanvasSnow=n():t.CanvasSnow=n()}(window,(function(){return function(t){var n={};function i(e){if(n[e])return n[e].exports;var s=n[e]={i:e,l:!1,exports:{}};return t[e].call(s.exports,s,s.exports,i),s.l=!0,s.exports}return i.m=t,i.c=n,i.d=function(t,n,e){i.o(t,n)||Object.defineProperty(t,n,{enumerable:!0,get:e})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,n){if(1&n&&(t=i(t)),8&n)return t;if(4&n&&"object"==typeof t&&t&&t.__esModule)return t;var e=Object.create(null);if(i.r(e),Object.defineProperty(e,"default",{enumerable:!0,value:t}),2&n&&"string"!=typeof t)for(var s in t)i.d(e,s,function(n){return t[n]}.bind(null,s));return e},i.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(n,"a",n),n},i.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},i.p="",i(i.s="tjUo")}({tjUo:function(t,n,i){"use strict";i.r(n);var e=function(t){return"string"==typeof t&&t.constructor===String},s=function(){function t(t,n,i,e,s,r){this.x=t,this.y=n,this.r=i,this.fn=e,this.canvasW=s,this.canvasH=r}var n=t.prototype;return n.update=function(){this.y>this.canvasH?(this.x=Math.random()*this.canvasW,this.y=0):(this.x=this.fn.x(this.x,this.y),this.y=this.fn.y(this.y,this.y))},n.draw=function(t){var n=t.createRadialGradient(this.x,this.y,0,this.x,this.y,this.r);n.addColorStop(0,"rgba(255, 255, 255, "+this.r/6*1+")"),n.addColorStop(.5,"rgba(255, 255, 255, "+this.r/6*.5+")"),n.addColorStop(1,"rgba(255, 255, 255, 0)"),t.fillStyle=n,t.fillRect(this.x-this.r,this.y-this.r,2*this.r,2*this.r)},t}(),r=function(){function t(){this.list=[]}var n=t.prototype;return n.update=function(){for(var t=0,n=this.size();t<n;t++)this.list[t].update()},n.push=function(t){this.list.push(t)},n.draw=function(t){for(var n=0,i=this.size();n<i;n++)this.list[n].draw(t)},n.get=function(t){return this.list[t]},n.size=function(){return this.list.length},t}();i.d(n,"default",(function(){return o}));var o=function(){function t(t){var n=t.context,i=t.width,s=void 0===i?"100%":i,r=t.height,o=void 0===r?"100%":r,a=t.cell;this.context=e(n)?document.querySelector(n):n,this.width=u(this.context,s),this.height=c(this.context,o),this.cell=a,this.state="stop",this.snowList=null,this.canvas=null,this.cxt=null,this.interval=null}var n=t.prototype;return n.init=function(){return this.canvas||this._initCanvas(),this.snowList||(this.snowList=new r,this._newSnow()),this},n._initCanvas=function(){this.canvas=document.createElement("canvas"),this.context.appendChild(this.canvas),this.canvas.height=this.height,this.canvas.width=this.width,this.cxt=this.canvas.getContext("2d")},n.start=function(){var t=this;this.snowList||this.init(),this.state="play",this.interval=setInterval((function(){t.cxt.clearRect(0,0,t.canvas.width,t.canvas.height),t.snowList.update(),t.snowList.draw(t.cxt)}),13)},n.stop=function(){this.state="stop",clearInterval(this.interval),this.interval=null,this.cxt.clearRect(0,0,this.canvas.width,this.canvas.height)},n.clear=function(){this.stop(),this.snowList=null},n._newSnow=function(){for(var t=0;t<this.cell;t++){var n=this._getRandom("x"),i=this._getRandom("y"),e=this._getRandom("r"),r=this._getRandom("fnx"),o=this._getRandom("fny"),a=new s(n,i,e,{x:r,y:o},this.width,this.height);a.draw(this.cxt),this.snowList.push(a)}},n._getRandom=function(t){var n,i;switch(t){case"x":n=Math.random()*this.width;break;case"y":n=(Math.random()-1)*this.height;break;case"r":n=2+4*Math.random();break;case"fnx":i=27+100*Math.random(),n=function(t,n){return t+.5*Math.sin(n/i)};break;case"fny":i=.4+1.4*Math.random(),n=function(t,n){return n+i}}return n},t}(),a=function(t,n){return-1!==t.toString().indexOf("%")?t.split("%")[0]/100*n:e(t)?Number(t):t},h=function(t){var n=t.el,i=t.tip;switch(void 0===i?"horizontal":i){case"horizontal":return n.getBoundingClientRect().width;case"vertical":return n.getBoundingClientRect().height;default:return n.getBoundingClientRect()}},c=function(t,n){return a(n,h({el:t,tip:"vertical"}))},u=function(t,n){return a(n,h({el:t,tip:"horizontal"}))}}}).default}));
package/docs/CHANGELOG.md DELETED
@@ -1,6 +0,0 @@
1
- ## [1.0.5](https://github.com/cycjimmy/canvas-snow/compare/v1.0.4...v1.0.5) (2019-10-24)
2
-
3
-
4
- ### Bug Fixes
5
-
6
- * **build:** replace "uglifyjs" with "terser" ([a88cecb](https://github.com/cycjimmy/canvas-snow/commit/a88cecb86dbaafca12458c5d8053477ae960cc54))