pts 0.10.4 → 0.10.8

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/dist/pts.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * pts.js 0.10.4 - Copyright © 2017-2021 William Ngan and contributors.
2
+ * pts.js 0.10.8 - Copyright © 2017-2021 William Ngan and contributors.
3
3
  * Licensed under Apache 2.0 License.
4
4
  * See https://github.com/williamngan/pts for details.
5
5
  */
@@ -110,7 +110,7 @@ return /******/ (function(modules) { // webpackBootstrap
110
110
 
111
111
  "use strict";
112
112
 
113
- /*! Source code licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
113
+ /*! Pts.js is licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
114
114
  Object.defineProperty(exports, "__esModule", { value: true });
115
115
  exports.CanvasForm = exports.CanvasSpace = void 0;
116
116
  const Space_1 = __webpack_require__(/*! ./Space */ "./src/Space.ts");
@@ -202,6 +202,9 @@ class CanvasSpace extends Space_1.MultiTouchSpace {
202
202
  else {
203
203
  this._offscreen = false;
204
204
  }
205
+ if (opt.pixelDensity) {
206
+ this._pixelScale = opt.pixelDensity;
207
+ }
205
208
  return this;
206
209
  }
207
210
  set autoResize(auto) {
@@ -218,13 +221,13 @@ class CanvasSpace extends Space_1.MultiTouchSpace {
218
221
  get autoResize() { return this._autoResize; }
219
222
  resize(b, evt) {
220
223
  this.bound = b;
221
- this._canvas.width = this.bound.size.x * this._pixelScale;
222
- this._canvas.height = this.bound.size.y * this._pixelScale;
223
- this._canvas.style.width = Math.floor(this.bound.size.x) + "px";
224
- this._canvas.style.height = Math.floor(this.bound.size.y) + "px";
224
+ this._canvas.width = Math.ceil(this.bound.size.x) * this._pixelScale;
225
+ this._canvas.height = Math.ceil(this.bound.size.y) * this._pixelScale;
226
+ this._canvas.style.width = Math.ceil(this.bound.size.x) + "px";
227
+ this._canvas.style.height = Math.ceil(this.bound.size.y) + "px";
225
228
  if (this._offscreen) {
226
- this._offCanvas.width = this.bound.size.x * this._pixelScale;
227
- this._offCanvas.height = this.bound.size.y * this._pixelScale;
229
+ this._offCanvas.width = Math.ceil(this.bound.size.x) * this._pixelScale;
230
+ this._offCanvas.height = Math.ceil(this.bound.size.y) * this._pixelScale;
228
231
  }
229
232
  if (this._pixelScale != 1) {
230
233
  this._ctx.scale(this._pixelScale, this._pixelScale);
@@ -279,27 +282,29 @@ class CanvasSpace extends Space_1.MultiTouchSpace {
279
282
  if (bg)
280
283
  this._bgcolor = bg;
281
284
  const lastColor = this._ctx.fillStyle;
285
+ const px = Math.ceil(this.pixelScale);
282
286
  if (!this._bgcolor || this._bgcolor === "transparent") {
283
- this._ctx.clearRect(-1, -1, this._canvas.width + 1, this._canvas.height + 1);
287
+ this._ctx.clearRect(-px, -px, this._canvas.width + px, this._canvas.height + px);
284
288
  }
285
289
  else {
286
290
  if (this._bgcolor.indexOf("rgba") === 0 || (this._bgcolor.length === 9 && this._bgcolor.indexOf("#") === 0)) {
287
- this._ctx.clearRect(-1, -1, this._canvas.width + 1, this._canvas.height + 1);
291
+ this._ctx.clearRect(-px, -px, this._canvas.width + px, this._canvas.height + px);
288
292
  }
289
293
  this._ctx.fillStyle = this._bgcolor;
290
- this._ctx.fillRect(-1, -1, this._canvas.width + 1, this._canvas.height + 1);
294
+ this._ctx.fillRect(-px, -px, this._canvas.width + px, this._canvas.height + px);
291
295
  }
292
296
  this._ctx.fillStyle = lastColor;
293
297
  return this;
294
298
  }
295
299
  clearOffscreen(bg) {
296
300
  if (this._offscreen) {
301
+ const px = Math.ceil(this.pixelScale);
297
302
  if (bg) {
298
303
  this._offCtx.fillStyle = bg;
299
- this._offCtx.fillRect(-1, -1, this._canvas.width + 1, this._canvas.height + 1);
304
+ this._offCtx.fillRect(-px, -px, this._canvas.width + px, this._canvas.height + px);
300
305
  }
301
306
  else {
302
- this._offCtx.clearRect(-1, -1, this._offCanvas.width + 1, this._offCanvas.height + 1);
307
+ this._offCtx.clearRect(-px, -px, this._offCanvas.width + px, this._offCanvas.height + px);
303
308
  }
304
309
  }
305
310
  return this;
@@ -324,9 +329,9 @@ class CanvasSpace extends Space_1.MultiTouchSpace {
324
329
  this.removeAll();
325
330
  return this;
326
331
  }
327
- recorder(downloadOrCallback, filetype = "webm") {
332
+ recorder(downloadOrCallback, filetype = "webm", bitrate = 15000000) {
328
333
  let stream = this._canvas.captureStream();
329
- const recorder = new MediaRecorder(stream, { mimeType: `video/${filetype}` });
334
+ const recorder = new MediaRecorder(stream, { mimeType: `video/${filetype}`, bitsPerSecond: bitrate });
330
335
  recorder.ondataavailable = function (d) {
331
336
  let url = URL.createObjectURL(new Blob([d.data], { type: `video/${filetype}` }));
332
337
  if (typeof downloadOrCallback === "function") {
@@ -352,6 +357,8 @@ class CanvasForm extends Form_1.VisualForm {
352
357
  lineWidth: 1, lineJoin: "bevel", lineCap: "butt",
353
358
  globalAlpha: 1
354
359
  };
360
+ if (!space)
361
+ return this;
355
362
  const _setup = (ctx) => {
356
363
  this._ctx = ctx;
357
364
  this._ctx.fillStyle = this._style.fillStyle;
@@ -422,6 +429,19 @@ class CanvasForm extends Form_1.VisualForm {
422
429
  }
423
430
  return this;
424
431
  }
432
+ applyFillStroke(filled = true, stroked = true, strokeWidth = 1) {
433
+ if (filled) {
434
+ if (typeof filled === 'string')
435
+ this.fill(filled);
436
+ this._ctx.fill();
437
+ }
438
+ if (stroked) {
439
+ if (typeof stroked === 'string')
440
+ this.stroke(stroked, strokeWidth);
441
+ this._ctx.stroke();
442
+ }
443
+ return this;
444
+ }
425
445
  gradient(stops) {
426
446
  let vals = [];
427
447
  if (stops.length < 2)
@@ -790,7 +810,7 @@ exports.CanvasForm = CanvasForm;
790
810
 
791
811
  "use strict";
792
812
 
793
- /*! Source code licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
813
+ /*! Pts.js is licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
794
814
  Object.defineProperty(exports, "__esModule", { value: true });
795
815
  exports.Color = void 0;
796
816
  const Pt_1 = __webpack_require__(/*! ./Pt */ "./src/Pt.ts");
@@ -1046,12 +1066,12 @@ class Color extends Pt_1.Pt {
1046
1066
  static XYZtoRGB(xyz, normalizedInput = false, normalizedOutput = false) {
1047
1067
  let [x, y, z] = (!normalizedInput) ? xyz.$normalize() : xyz;
1048
1068
  let rgb = [
1049
- x * 3.2404542 + y * -1.5371385 + z * -0.4985314,
1050
- x * -0.9692660 + y * 1.8760108 + z * 0.0415560,
1051
- x * 0.0556434 + y * -0.2040259 + z * 1.0572252
1069
+ x * 3.2406254773200533 + y * -1.5372079722103187 + z * -0.4986285986982479,
1070
+ x * -0.9689307147293197 + y * 1.8757560608852415 + z * 0.041517523842953964,
1071
+ x * 0.055710120445510616 + y * -0.2040210505984867 + z * 1.0569959422543882
1052
1072
  ];
1053
1073
  for (let i = 0; i < 3; i++) {
1054
- rgb[i] = (rgb[i] < 0) ? 0 : (rgb[i] > 0.0031308) ? (1.055 * Math.pow(rgb[i], 1 / 2.4) - 0.055) : (12.92 * rgb[i]);
1074
+ rgb[i] = (rgb[i] > 0.0031308) ? (1.055 * Math.pow(rgb[i], 1 / 2.4) - 0.055) : (12.92 * rgb[i]);
1055
1075
  rgb[i] = Math.max(0, Math.min(1, rgb[i]));
1056
1076
  if (!normalizedOutput)
1057
1077
  rgb[i] = Math.round(rgb[i] * 255);
@@ -1061,8 +1081,10 @@ class Color extends Pt_1.Pt {
1061
1081
  }
1062
1082
  static XYZtoLAB(xyz, normalizedInput = false, normalizedOutput = false) {
1063
1083
  let c = (normalizedInput) ? xyz.$normalize(false) : xyz.clone();
1084
+ const eps = 0.00885645167;
1085
+ const kap = 903.296296296;
1064
1086
  c.divide(Color.D65);
1065
- let fn = (n) => (n > 0.008856) ? Math.pow(n, 1 / 3) : (7.787 * n) + 16 / 116;
1087
+ let fn = (n) => (n > eps) ? Math.pow(n, 1 / 3) : (kap * n + 16) / 116;
1066
1088
  let cy = fn(c[1]);
1067
1089
  let cc = Color.lab((116 * cy) - 16, 500 * (fn(c[0]) - cy), 200 * (cy - fn(c[2])), xyz.alpha);
1068
1090
  return (normalizedOutput) ? cc.normalize() : cc;
@@ -1072,12 +1094,12 @@ class Color extends Pt_1.Pt {
1072
1094
  let y = (c[0] + 16) / 116;
1073
1095
  let x = (c[1] / 500) + y;
1074
1096
  let z = y - c[2] / 200;
1075
- let fn = (n) => {
1076
- let nnn = n * n * n;
1077
- return (nnn > 0.008856) ? nnn : (n - 16 / 116) / 7.787;
1078
- };
1097
+ const eps = 0.00885645167;
1098
+ const kap = 903.296296296;
1079
1099
  let d = Color.D65;
1080
- let cc = Color.xyz(Math.max(0, d[0] * fn(x)), Math.max(0, d[1] * fn(y)), Math.max(0, d[2] * fn(z)), lab.alpha);
1100
+ const xxx = Math.pow(x, 3);
1101
+ const zzz = Math.pow(z, 3);
1102
+ let cc = Color.xyz(d[0] * ((xxx > eps) ? xxx : (116 * x - 16) / kap), d[1] * ((c[0] > kap * eps) ? Math.pow((c[0] + 16) / 116, 3) : c[0] / kap), d[2] * ((zzz > eps) ? zzz : (116 * z - 16) / kap), lab.alpha);
1081
1103
  return (normalizedOutput) ? cc.normalize() : cc;
1082
1104
  }
1083
1105
  static XYZtoLUV(xyz, normalizedInput = false, normalizedOutput = false) {
@@ -1140,7 +1162,7 @@ Color.ranges = {
1140
1162
 
1141
1163
  "use strict";
1142
1164
 
1143
- /*! Source code licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
1165
+ /*! Pts.js is licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
1144
1166
  Object.defineProperty(exports, "__esModule", { value: true });
1145
1167
  exports.Delaunay = exports.Noise = exports.Create = void 0;
1146
1168
  const Pt_1 = __webpack_require__(/*! ./Pt */ "./src/Pt.ts");
@@ -1152,11 +1174,11 @@ class Create {
1152
1174
  static distributeRandom(bound, count, dimensions = 2) {
1153
1175
  let pts = new Pt_1.Group();
1154
1176
  for (let i = 0; i < count; i++) {
1155
- let p = [bound.x + Math.random() * bound.width];
1177
+ let p = [bound.x + Num_1.Num.random() * bound.width];
1156
1178
  if (dimensions > 1)
1157
- p.push(bound.y + Math.random() * bound.height);
1179
+ p.push(bound.y + Num_1.Num.random() * bound.height);
1158
1180
  if (dimensions > 2)
1159
- p.push(bound.z + Math.random() * bound.depth);
1181
+ p.push(bound.z + Num_1.Num.random() * bound.depth);
1160
1182
  pts.push(new Pt_1.Pt(p));
1161
1183
  }
1162
1184
  return pts;
@@ -1202,7 +1224,7 @@ class Create {
1202
1224
  return g;
1203
1225
  }
1204
1226
  static noisePts(pts, dx = 0.01, dy = 0.01, rows = 0, columns = 0) {
1205
- let seed = Math.random();
1227
+ let seed = Num_1.Num.random();
1206
1228
  let g = new Pt_1.Group();
1207
1229
  let i = 0;
1208
1230
  for (let p of pts) {
@@ -1432,7 +1454,7 @@ exports.Delaunay = Delaunay;
1432
1454
 
1433
1455
  "use strict";
1434
1456
 
1435
- /*! Source code licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
1457
+ /*! Pts.js is licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
1436
1458
  Object.defineProperty(exports, "__esModule", { value: true });
1437
1459
  exports.HTMLForm = exports.HTMLSpace = exports.DOMSpace = void 0;
1438
1460
  const Space_1 = __webpack_require__(/*! ./Space */ "./src/Space.ts");
@@ -1897,7 +1919,7 @@ HTMLForm.domID = 0;
1897
1919
 
1898
1920
  "use strict";
1899
1921
 
1900
- /*! Source code licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
1922
+ /*! Pts.js is licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
1901
1923
  Object.defineProperty(exports, "__esModule", { value: true });
1902
1924
  exports.Font = exports.VisualForm = exports.Form = void 0;
1903
1925
  class Form {
@@ -2086,6 +2108,8 @@ class Img {
2086
2108
  }
2087
2109
  filter(css) {
2088
2110
  this._ctx.filter = css;
2111
+ this._ctx.drawImage(this._cv, 0, 0);
2112
+ this._ctx.filter = "none";
2089
2113
  return this;
2090
2114
  }
2091
2115
  cleanup() {
@@ -2161,7 +2185,7 @@ exports.Img = Img;
2161
2185
 
2162
2186
  "use strict";
2163
2187
 
2164
- /*! Source code licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
2188
+ /*! Pts.js is licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
2165
2189
  Object.defineProperty(exports, "__esModule", { value: true });
2166
2190
  exports.Mat = exports.Vec = void 0;
2167
2191
  const Pt_1 = __webpack_require__(/*! ./Pt */ "./src/Pt.ts");
@@ -2428,13 +2452,14 @@ exports.Mat = Mat;
2428
2452
 
2429
2453
  "use strict";
2430
2454
 
2431
- /*! Source code licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
2455
+ /*! Pts.js is licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
2432
2456
  Object.defineProperty(exports, "__esModule", { value: true });
2433
2457
  exports.Range = exports.Shaping = exports.Geom = exports.Num = void 0;
2434
2458
  const Util_1 = __webpack_require__(/*! ./Util */ "./src/Util.ts");
2435
2459
  const Op_1 = __webpack_require__(/*! ./Op */ "./src/Op.ts");
2436
2460
  const Pt_1 = __webpack_require__(/*! ./Pt */ "./src/Pt.ts");
2437
2461
  const LinearAlgebra_1 = __webpack_require__(/*! ./LinearAlgebra */ "./src/LinearAlgebra.ts");
2462
+ const uheprng_1 = __webpack_require__(/*! ./uheprng */ "./src/uheprng.ts");
2438
2463
  class Num {
2439
2464
  static equals(a, b, threshold = 0.00001) {
2440
2465
  return Math.abs(a - b) < threshold;
@@ -2459,14 +2484,14 @@ class Num {
2459
2484
  }
2460
2485
  static randomRange(a, b = 0) {
2461
2486
  let r = (a > b) ? (a - b) : (b - a);
2462
- return a + Math.random() * r;
2487
+ return a + Num.random() * r;
2463
2488
  }
2464
2489
  static randomPt(a, b) {
2465
2490
  let p = new Pt_1.Pt(a.length);
2466
2491
  let range = b ? LinearAlgebra_1.Vec.subtract(b, a) : a;
2467
2492
  let start = b ? a : new Pt_1.Pt(a.length).fill(0);
2468
2493
  for (let i = 0, len = p.length; i < len; i++) {
2469
- p[i] = Math.random() * range[i] + start[i];
2494
+ p[i] = Num.random() * range[i] + start[i];
2470
2495
  }
2471
2496
  return p;
2472
2497
  }
@@ -2497,6 +2522,14 @@ class Num {
2497
2522
  let max = Math.max(targetA, targetB);
2498
2523
  return Num.normalizeValue(n, currA, currB) * (max - min) + min;
2499
2524
  }
2525
+ static seed(seed) {
2526
+ this.generator = uheprng_1.default(seed);
2527
+ }
2528
+ static random() {
2529
+ return this.generator
2530
+ ? this.generator.random()
2531
+ : Math.random();
2532
+ }
2500
2533
  }
2501
2534
  exports.Num = Num;
2502
2535
  class Geom {
@@ -2914,7 +2947,7 @@ exports.Range = Range;
2914
2947
 
2915
2948
  "use strict";
2916
2949
 
2917
- /*! Source code licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
2950
+ /*! Pts.js is licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
2918
2951
  Object.defineProperty(exports, "__esModule", { value: true });
2919
2952
  exports.Curve = exports.Polygon = exports.Triangle = exports.Circle = exports.Rectangle = exports.Line = void 0;
2920
2953
  const Util_1 = __webpack_require__(/*! ./Util */ "./src/Util.ts");
@@ -3912,7 +3945,7 @@ exports.Curve = Curve;
3912
3945
 
3913
3946
  "use strict";
3914
3947
 
3915
- /*! Source code licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
3948
+ /*! Pts.js is licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
3916
3949
  Object.defineProperty(exports, "__esModule", { value: true });
3917
3950
  exports.Body = exports.Particle = exports.World = void 0;
3918
3951
  const Pt_1 = __webpack_require__(/*! ./Pt */ "./src/Pt.ts");
@@ -4667,7 +4700,7 @@ exports.Sound = Sound;
4667
4700
 
4668
4701
  "use strict";
4669
4702
 
4670
- /*! Source code licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
4703
+ /*! Pts.js is licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
4671
4704
  Object.defineProperty(exports, "__esModule", { value: true });
4672
4705
  exports.Bound = exports.Group = exports.Pt = void 0;
4673
4706
  const Util_1 = __webpack_require__(/*! ./Util */ "./src/Util.ts");
@@ -4688,7 +4721,7 @@ class Pt extends Float32Array {
4688
4721
  p.fill(defaultValue);
4689
4722
  if (randomize) {
4690
4723
  for (let i = 0, len = p.length; i < len; i++) {
4691
- p[i] = p[i] * Math.random();
4724
+ p[i] = p[i] * Num_1.Num.random();
4692
4725
  }
4693
4726
  }
4694
4727
  return new Pt(p);
@@ -5144,7 +5177,7 @@ exports.Bound = Bound;
5144
5177
 
5145
5178
  "use strict";
5146
5179
 
5147
- /*! Source code licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
5180
+ /*! Pts.js is licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
5148
5181
  Object.defineProperty(exports, "__esModule", { value: true });
5149
5182
  exports.MultiTouchSpace = exports.Space = void 0;
5150
5183
  const Pt_1 = __webpack_require__(/*! ./Pt */ "./src/Pt.ts");
@@ -5239,7 +5272,7 @@ class Space {
5239
5272
  this._time.end = t;
5240
5273
  return this;
5241
5274
  }
5242
- playOnce(duration = 5000) {
5275
+ playOnce(duration = 0) {
5243
5276
  this.play();
5244
5277
  this.stop(duration);
5245
5278
  return this;
@@ -5276,44 +5309,50 @@ class MultiTouchSpace extends Space {
5276
5309
  bindCanvas(evt, callback, options = {}) {
5277
5310
  this._canvas.addEventListener(evt, callback, options);
5278
5311
  }
5279
- unbindCanvas(evt, callback) {
5280
- this._canvas.removeEventListener(evt, callback);
5312
+ unbindCanvas(evt, callback, options = {}) {
5313
+ this._canvas.removeEventListener(evt, callback, options);
5281
5314
  }
5282
5315
  bindMouse(_bind = true) {
5283
5316
  if (_bind) {
5284
- this.bindCanvas("mousedown", this._mouseDown.bind(this));
5285
- this.bindCanvas("mouseup", this._mouseUp.bind(this));
5286
- this.bindCanvas("mouseover", this._mouseOver.bind(this));
5287
- this.bindCanvas("mouseout", this._mouseOut.bind(this));
5288
- this.bindCanvas("mousemove", this._mouseMove.bind(this));
5289
- this.bindCanvas("click", this._mouseClick.bind(this));
5290
- this.bindCanvas("contextmenu", this._contextMenu.bind(this));
5317
+ this._mouseDown = this._mouseDown.bind(this);
5318
+ this._mouseUp = this._mouseUp.bind(this);
5319
+ this._mouseOver = this._mouseOver.bind(this);
5320
+ this._mouseMove = this._mouseMove.bind(this);
5321
+ this._mouseClick = this._mouseClick.bind(this);
5322
+ this._contextMenu = this._contextMenu.bind(this);
5323
+ this.bindCanvas("mousedown", this._mouseDown);
5324
+ this.bindCanvas("mouseup", this._mouseUp);
5325
+ this.bindCanvas("mouseover", this._mouseOver);
5326
+ this.bindCanvas("mouseout", this._mouseOut);
5327
+ this.bindCanvas("mousemove", this._mouseMove);
5328
+ this.bindCanvas("click", this._mouseClick);
5329
+ this.bindCanvas("contextmenu", this._contextMenu);
5291
5330
  this._hasMouse = true;
5292
5331
  }
5293
5332
  else {
5294
- this.unbindCanvas("mousedown", this._mouseDown.bind(this));
5295
- this.unbindCanvas("mouseup", this._mouseUp.bind(this));
5296
- this.unbindCanvas("mouseover", this._mouseOver.bind(this));
5297
- this.unbindCanvas("mouseout", this._mouseOut.bind(this));
5298
- this.unbindCanvas("mousemove", this._mouseMove.bind(this));
5299
- this.unbindCanvas("click", this._mouseClick.bind(this));
5300
- this.unbindCanvas("contextmenu", this._contextMenu.bind(this));
5333
+ this.unbindCanvas("mousedown", this._mouseDown);
5334
+ this.unbindCanvas("mouseup", this._mouseUp);
5335
+ this.unbindCanvas("mouseover", this._mouseOver);
5336
+ this.unbindCanvas("mouseout", this._mouseOut);
5337
+ this.unbindCanvas("mousemove", this._mouseMove);
5338
+ this.unbindCanvas("click", this._mouseClick);
5339
+ this.unbindCanvas("contextmenu", this._contextMenu);
5301
5340
  this._hasMouse = false;
5302
5341
  }
5303
5342
  return this;
5304
5343
  }
5305
- bindTouch(_bind = true) {
5306
- if (_bind) {
5307
- this.bindCanvas("touchstart", this._touchStart.bind(this), { passive: true });
5344
+ bindTouch(bind = true, passive = false) {
5345
+ if (bind) {
5346
+ this.bindCanvas("touchstart", this._touchStart.bind(this), { passive: passive });
5308
5347
  this.bindCanvas("touchend", this._mouseUp.bind(this));
5309
- this.bindCanvas("touchmove", this._touchMove.bind(this), { passive: true });
5348
+ this.bindCanvas("touchmove", this._touchMove.bind(this), { passive: passive });
5310
5349
  this.bindCanvas("touchcancel", this._mouseOut.bind(this));
5311
5350
  this._hasTouch = true;
5312
5351
  }
5313
5352
  else {
5314
- this.unbindCanvas("touchstart", this._touchStart.bind(this));
5353
+ this.unbindCanvas("touchstart", this._touchStart.bind(this), { passive: passive });
5315
5354
  this.unbindCanvas("touchend", this._mouseUp.bind(this));
5316
- this.unbindCanvas("touchmove", this._touchMove.bind(this));
5355
+ this.unbindCanvas("touchmove", this._touchMove.bind(this), { passive: passive });
5317
5356
  this.unbindCanvas("touchcancel", this._mouseOut.bind(this));
5318
5357
  this._hasTouch = false;
5319
5358
  }
@@ -5430,7 +5469,7 @@ exports.MultiTouchSpace = MultiTouchSpace;
5430
5469
 
5431
5470
  "use strict";
5432
5471
 
5433
- /*! Source code licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
5472
+ /*! Pts.js is licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
5434
5473
  Object.defineProperty(exports, "__esModule", { value: true });
5435
5474
  exports.SVGForm = exports.SVGSpace = void 0;
5436
5475
  const Form_1 = __webpack_require__(/*! ./Form */ "./src/Form.ts");
@@ -5813,7 +5852,7 @@ SVGForm.domID = 0;
5813
5852
 
5814
5853
  "use strict";
5815
5854
 
5816
- /*! Source code licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
5855
+ /*! Pts.js is licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
5817
5856
  Object.defineProperty(exports, "__esModule", { value: true });
5818
5857
 
5819
5858
 
@@ -5828,7 +5867,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
5828
5867
 
5829
5868
  "use strict";
5830
5869
 
5831
- /*! Source code licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
5870
+ /*! Pts.js is licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
5832
5871
  Object.defineProperty(exports, "__esModule", { value: true });
5833
5872
  exports.Typography = void 0;
5834
5873
  const Pt_1 = __webpack_require__(/*! ./Pt */ "./src/Pt.ts");
@@ -5883,7 +5922,7 @@ exports.Typography = Typography;
5883
5922
 
5884
5923
  "use strict";
5885
5924
 
5886
- /*! Source code licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
5925
+ /*! Pts.js is licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
5887
5926
  Object.defineProperty(exports, "__esModule", { value: true });
5888
5927
  exports.UIDragger = exports.UIButton = exports.UI = exports.UIPointerActions = exports.UIShape = void 0;
5889
5928
  const Pt_1 = __webpack_require__(/*! ./Pt */ "./src/Pt.ts");
@@ -6169,9 +6208,10 @@ exports.UIDragger = UIDragger;
6169
6208
 
6170
6209
  "use strict";
6171
6210
 
6172
- /*! Source code licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
6211
+ /*! Pts.js is licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
6173
6212
  Object.defineProperty(exports, "__esModule", { value: true });
6174
6213
  exports.Util = exports.Const = void 0;
6214
+ const Num_1 = __webpack_require__(/*! ./Num */ "./src/Num.ts");
6175
6215
  const Pt_1 = __webpack_require__(/*! ./Pt */ "./src/Pt.ts");
6176
6216
  exports.Const = {
6177
6217
  xy: "xy",
@@ -6243,7 +6283,7 @@ class Util {
6243
6283
  }
6244
6284
  static randomInt(range, start = 0) {
6245
6285
  Util.warn("Util.randomInt is deprecated. Please use `Num.randomRange`");
6246
- return Math.floor(Math.random() * range) + start;
6286
+ return Math.floor(Num_1.Num.random() * range) + start;
6247
6287
  }
6248
6288
  static split(pts, size, stride, loopBack = false, matchSize = true) {
6249
6289
  let chunks = [];
@@ -6430,6 +6470,88 @@ let quickStart = (id, bg = "#9ab") => {
6430
6470
  exports.quickStart = quickStart;
6431
6471
 
6432
6472
 
6473
+ /***/ }),
6474
+
6475
+ /***/ "./src/uheprng.ts":
6476
+ /*!************************!*\
6477
+ !*** ./src/uheprng.ts ***!
6478
+ \************************/
6479
+ /*! no static exports found */
6480
+ /***/ (function(module, exports, __webpack_require__) {
6481
+
6482
+ "use strict";
6483
+
6484
+ Object.defineProperty(exports, "__esModule", { value: true });
6485
+ function Mash() {
6486
+ var n = 0xefc8249d;
6487
+ var mash = function (data) {
6488
+ if (data) {
6489
+ data = data.toString();
6490
+ for (var i = 0; i < data.length; i++) {
6491
+ n += data.charCodeAt(i);
6492
+ var h = 0.02519603282416938 * n;
6493
+ n = h >>> 0;
6494
+ h -= n;
6495
+ h *= n;
6496
+ n = h >>> 0;
6497
+ h -= n;
6498
+ n += h * 0x100000000;
6499
+ }
6500
+ return (n >>> 0) * 2.3283064365386963e-10;
6501
+ }
6502
+ else
6503
+ n = 0xefc8249d;
6504
+ };
6505
+ return mash;
6506
+ }
6507
+ function default_1(seed) {
6508
+ var o = 48;
6509
+ var c = 1;
6510
+ var p = o;
6511
+ var s = new Array(o);
6512
+ var i, j, k = 0;
6513
+ var mash = Mash();
6514
+ for (i = 0; i < o; i++)
6515
+ s[i] = mash(Math.random().toString());
6516
+ function initState() {
6517
+ mash();
6518
+ for (i = 0; i < o; i++)
6519
+ s[i] = mash(' ');
6520
+ c = 1;
6521
+ p = o;
6522
+ }
6523
+ function cleanString(inStr) {
6524
+ inStr = inStr.replace(/(^\s*)|(\s*$)/gi, '');
6525
+ inStr = inStr.replace(/[\x00-\x1F]/gi, '');
6526
+ inStr = inStr.replace(/\n /, '\n');
6527
+ return inStr;
6528
+ }
6529
+ function hashString(inStr) {
6530
+ inStr = cleanString(inStr);
6531
+ mash(inStr);
6532
+ for (i = 0; i < inStr.length; i++) {
6533
+ k = inStr.charCodeAt(i);
6534
+ for (j = 0; j < o; j++) {
6535
+ s[j] -= mash(k.toString());
6536
+ if (s[j] < 0)
6537
+ s[j] += 1;
6538
+ }
6539
+ }
6540
+ }
6541
+ initState();
6542
+ hashString(seed);
6543
+ return {
6544
+ random() {
6545
+ if (++p >= o)
6546
+ p = 0;
6547
+ var t = 1768863 * s[p] + c * 2.3283064365386963e-10;
6548
+ return (s[p] = t - (c = t | 0));
6549
+ }
6550
+ };
6551
+ }
6552
+ exports.default = default_1;
6553
+
6554
+
6433
6555
  /***/ })
6434
6556
 
6435
6557
  /******/ });