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/es2015/Canvas.js +34 -14
- package/dist/es2015/Color.js +13 -11
- package/dist/es2015/Create.js +5 -5
- package/dist/es2015/Dom.js +1 -1
- package/dist/es2015/Form.js +1 -1
- package/dist/es2015/Image.js +2 -0
- package/dist/es2015/LinearAlgebra.js +1 -1
- package/dist/es2015/Num.js +12 -3
- package/dist/es2015/Op.js +1 -1
- package/dist/es2015/Physics.js +1 -1
- package/dist/es2015/Pt.js +2 -2
- package/dist/es2015/Space.js +30 -24
- package/dist/es2015/Svg.js +1 -1
- package/dist/es2015/Types.js +1 -1
- package/dist/es2015/Typography.js +1 -1
- package/dist/es2015/UI.js +1 -1
- package/dist/es2015/Util.js +3 -2
- package/dist/es2015/_module.js +1 -0
- package/dist/es2015/uheprng.js +69 -0
- package/dist/es5.js +198 -66
- package/dist/index.js +193 -70
- package/dist/pts.d.ts +19 -9
- package/dist/pts.js +193 -71
- package/dist/pts.min.js +2 -2
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* pts.js 0.10.
|
|
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
|
-
/*!
|
|
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.
|
|
224
|
-
this._canvas.style.height = Math.
|
|
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(-
|
|
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(-
|
|
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(-
|
|
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(-
|
|
304
|
+
this._offCtx.fillRect(-px, -px, this._canvas.width + px, this._canvas.height + px);
|
|
300
305
|
}
|
|
301
306
|
else {
|
|
302
|
-
this._offCtx.clearRect(-
|
|
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
|
-
/*!
|
|
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.
|
|
1050
|
-
x * -0.
|
|
1051
|
-
x * 0.
|
|
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]
|
|
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 >
|
|
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
|
-
|
|
1076
|
-
|
|
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
|
-
|
|
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
|
-
/*!
|
|
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 +
|
|
1177
|
+
let p = [bound.x + Num_1.Num.random() * bound.width];
|
|
1156
1178
|
if (dimensions > 1)
|
|
1157
|
-
p.push(bound.y +
|
|
1179
|
+
p.push(bound.y + Num_1.Num.random() * bound.height);
|
|
1158
1180
|
if (dimensions > 2)
|
|
1159
|
-
p.push(bound.z +
|
|
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 =
|
|
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
|
-
/*!
|
|
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
|
-
/*!
|
|
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
|
-
/*!
|
|
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
|
-
/*!
|
|
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 +
|
|
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] =
|
|
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
|
-
/*!
|
|
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
|
-
/*!
|
|
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
|
-
/*!
|
|
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] *
|
|
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
|
-
/*!
|
|
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 =
|
|
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.
|
|
5285
|
-
this.
|
|
5286
|
-
this.
|
|
5287
|
-
this.
|
|
5288
|
-
this.
|
|
5289
|
-
this.
|
|
5290
|
-
this.bindCanvas("
|
|
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
|
|
5295
|
-
this.unbindCanvas("mouseup", this._mouseUp
|
|
5296
|
-
this.unbindCanvas("mouseover", this._mouseOver
|
|
5297
|
-
this.unbindCanvas("mouseout", this._mouseOut
|
|
5298
|
-
this.unbindCanvas("mousemove", this._mouseMove
|
|
5299
|
-
this.unbindCanvas("click", this._mouseClick
|
|
5300
|
-
this.unbindCanvas("contextmenu", this._contextMenu
|
|
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(
|
|
5306
|
-
if (
|
|
5307
|
-
this.bindCanvas("touchstart", this._touchStart.bind(this), { passive:
|
|
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:
|
|
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
|
-
/*!
|
|
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
|
-
/*!
|
|
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
|
exports.Typography = void 0;
|
|
5819
5858
|
const Pt_1 = __webpack_require__(/*! ./Pt */ "./src/Pt.ts");
|
|
@@ -5868,7 +5907,7 @@ exports.Typography = Typography;
|
|
|
5868
5907
|
|
|
5869
5908
|
"use strict";
|
|
5870
5909
|
|
|
5871
|
-
/*!
|
|
5910
|
+
/*! Pts.js is licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
|
|
5872
5911
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5873
5912
|
exports.UIDragger = exports.UIButton = exports.UI = exports.UIPointerActions = exports.UIShape = void 0;
|
|
5874
5913
|
const Pt_1 = __webpack_require__(/*! ./Pt */ "./src/Pt.ts");
|
|
@@ -6154,9 +6193,10 @@ exports.UIDragger = UIDragger;
|
|
|
6154
6193
|
|
|
6155
6194
|
"use strict";
|
|
6156
6195
|
|
|
6157
|
-
/*!
|
|
6196
|
+
/*! Pts.js is licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
|
|
6158
6197
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6159
6198
|
exports.Util = exports.Const = void 0;
|
|
6199
|
+
const Num_1 = __webpack_require__(/*! ./Num */ "./src/Num.ts");
|
|
6160
6200
|
const Pt_1 = __webpack_require__(/*! ./Pt */ "./src/Pt.ts");
|
|
6161
6201
|
exports.Const = {
|
|
6162
6202
|
xy: "xy",
|
|
@@ -6228,7 +6268,7 @@ class Util {
|
|
|
6228
6268
|
}
|
|
6229
6269
|
static randomInt(range, start = 0) {
|
|
6230
6270
|
Util.warn("Util.randomInt is deprecated. Please use `Num.randomRange`");
|
|
6231
|
-
return Math.floor(
|
|
6271
|
+
return Math.floor(Num_1.Num.random() * range) + start;
|
|
6232
6272
|
}
|
|
6233
6273
|
static split(pts, size, stride, loopBack = false, matchSize = true) {
|
|
6234
6274
|
let chunks = [];
|
|
@@ -6382,6 +6422,89 @@ __exportStar(__webpack_require__(/*! ./Typography */ "./src/Typography.ts"), exp
|
|
|
6382
6422
|
__exportStar(__webpack_require__(/*! ./Physics */ "./src/Physics.ts"), exports);
|
|
6383
6423
|
__exportStar(__webpack_require__(/*! ./Play */ "./src/Play.ts"), exports);
|
|
6384
6424
|
__exportStar(__webpack_require__(/*! ./UI */ "./src/UI.ts"), exports);
|
|
6425
|
+
__exportStar(__webpack_require__(/*! ./Image */ "./src/Image.ts"), exports);
|
|
6426
|
+
|
|
6427
|
+
|
|
6428
|
+
/***/ }),
|
|
6429
|
+
|
|
6430
|
+
/***/ "./src/uheprng.ts":
|
|
6431
|
+
/*!************************!*\
|
|
6432
|
+
!*** ./src/uheprng.ts ***!
|
|
6433
|
+
\************************/
|
|
6434
|
+
/*! no static exports found */
|
|
6435
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
6436
|
+
|
|
6437
|
+
"use strict";
|
|
6438
|
+
|
|
6439
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6440
|
+
function Mash() {
|
|
6441
|
+
var n = 0xefc8249d;
|
|
6442
|
+
var mash = function (data) {
|
|
6443
|
+
if (data) {
|
|
6444
|
+
data = data.toString();
|
|
6445
|
+
for (var i = 0; i < data.length; i++) {
|
|
6446
|
+
n += data.charCodeAt(i);
|
|
6447
|
+
var h = 0.02519603282416938 * n;
|
|
6448
|
+
n = h >>> 0;
|
|
6449
|
+
h -= n;
|
|
6450
|
+
h *= n;
|
|
6451
|
+
n = h >>> 0;
|
|
6452
|
+
h -= n;
|
|
6453
|
+
n += h * 0x100000000;
|
|
6454
|
+
}
|
|
6455
|
+
return (n >>> 0) * 2.3283064365386963e-10;
|
|
6456
|
+
}
|
|
6457
|
+
else
|
|
6458
|
+
n = 0xefc8249d;
|
|
6459
|
+
};
|
|
6460
|
+
return mash;
|
|
6461
|
+
}
|
|
6462
|
+
function default_1(seed) {
|
|
6463
|
+
var o = 48;
|
|
6464
|
+
var c = 1;
|
|
6465
|
+
var p = o;
|
|
6466
|
+
var s = new Array(o);
|
|
6467
|
+
var i, j, k = 0;
|
|
6468
|
+
var mash = Mash();
|
|
6469
|
+
for (i = 0; i < o; i++)
|
|
6470
|
+
s[i] = mash(Math.random().toString());
|
|
6471
|
+
function initState() {
|
|
6472
|
+
mash();
|
|
6473
|
+
for (i = 0; i < o; i++)
|
|
6474
|
+
s[i] = mash(' ');
|
|
6475
|
+
c = 1;
|
|
6476
|
+
p = o;
|
|
6477
|
+
}
|
|
6478
|
+
function cleanString(inStr) {
|
|
6479
|
+
inStr = inStr.replace(/(^\s*)|(\s*$)/gi, '');
|
|
6480
|
+
inStr = inStr.replace(/[\x00-\x1F]/gi, '');
|
|
6481
|
+
inStr = inStr.replace(/\n /, '\n');
|
|
6482
|
+
return inStr;
|
|
6483
|
+
}
|
|
6484
|
+
function hashString(inStr) {
|
|
6485
|
+
inStr = cleanString(inStr);
|
|
6486
|
+
mash(inStr);
|
|
6487
|
+
for (i = 0; i < inStr.length; i++) {
|
|
6488
|
+
k = inStr.charCodeAt(i);
|
|
6489
|
+
for (j = 0; j < o; j++) {
|
|
6490
|
+
s[j] -= mash(k.toString());
|
|
6491
|
+
if (s[j] < 0)
|
|
6492
|
+
s[j] += 1;
|
|
6493
|
+
}
|
|
6494
|
+
}
|
|
6495
|
+
}
|
|
6496
|
+
initState();
|
|
6497
|
+
hashString(seed);
|
|
6498
|
+
return {
|
|
6499
|
+
random() {
|
|
6500
|
+
if (++p >= o)
|
|
6501
|
+
p = 0;
|
|
6502
|
+
var t = 1768863 * s[p] + c * 2.3283064365386963e-10;
|
|
6503
|
+
return (s[p] = t - (c = t | 0));
|
|
6504
|
+
}
|
|
6505
|
+
};
|
|
6506
|
+
}
|
|
6507
|
+
exports.default = default_1;
|
|
6385
6508
|
|
|
6386
6509
|
|
|
6387
6510
|
/***/ })
|
package/dist/pts.d.ts
CHANGED
|
@@ -16,12 +16,7 @@ export class CanvasSpace extends MultiTouchSpace {
|
|
|
16
16
|
protected _initialResize: boolean;
|
|
17
17
|
constructor(elem: string | Element, callback?: Function);
|
|
18
18
|
protected _createElement(elem: string, id: any): HTMLElement;
|
|
19
|
-
setup(opt:
|
|
20
|
-
bgcolor?: string;
|
|
21
|
-
resize?: boolean;
|
|
22
|
-
retina?: boolean;
|
|
23
|
-
offscreen?: boolean;
|
|
24
|
-
}): this;
|
|
19
|
+
setup(opt: CanvasSpaceOptions): this;
|
|
25
20
|
set autoResize(auto: boolean);
|
|
26
21
|
get autoResize(): boolean;
|
|
27
22
|
resize(b: Bound, evt?: Event): this;
|
|
@@ -41,7 +36,7 @@ export class CanvasSpace extends MultiTouchSpace {
|
|
|
41
36
|
clearOffscreen(bg?: string): this;
|
|
42
37
|
protected playItems(time: number): void;
|
|
43
38
|
dispose(): this;
|
|
44
|
-
recorder(downloadOrCallback: boolean | ((blobURL: string) => {}), filetype?: string): MediaRecorder;
|
|
39
|
+
recorder(downloadOrCallback: boolean | ((blobURL: string) => {}), filetype?: string, bitrate?: number): MediaRecorder;
|
|
45
40
|
}
|
|
46
41
|
export class CanvasForm extends VisualForm {
|
|
47
42
|
protected _space: CanvasSpace;
|
|
@@ -56,6 +51,7 @@ export class CanvasForm extends VisualForm {
|
|
|
56
51
|
alpha(a: number): this;
|
|
57
52
|
fill(c: string | boolean | CanvasGradient | CanvasPattern): this;
|
|
58
53
|
stroke(c: string | boolean | CanvasGradient | CanvasPattern, width?: number, linejoin?: CanvasLineJoin, linecap?: CanvasLineCap): this;
|
|
54
|
+
applyFillStroke(filled?: boolean | string, stroked?: boolean | string, strokeWidth?: number): this;
|
|
59
55
|
gradient(stops: [number, string][] | string[]): ((area1: GroupLike, area2?: GroupLike) => CanvasGradient);
|
|
60
56
|
composite(mode?: string): this;
|
|
61
57
|
clip(): this;
|
|
@@ -410,6 +406,7 @@ export class Mat {
|
|
|
410
406
|
}
|
|
411
407
|
|
|
412
408
|
export class Num {
|
|
409
|
+
static generator: any;
|
|
413
410
|
static equals(a: number, b: number, threshold?: number): boolean;
|
|
414
411
|
static lerp(a: number, b: number, t: number): number;
|
|
415
412
|
static clamp(val: number, min: number, max: number): number;
|
|
@@ -422,6 +419,8 @@ export class Num {
|
|
|
422
419
|
static average(pts: PtLikeIterable): Pt;
|
|
423
420
|
static cycle(t: number, method?: (t: number) => number): number;
|
|
424
421
|
static mapToRange(n: number, currA: number, currB: number, targetA: number, targetB: number): number;
|
|
422
|
+
static seed(seed: string): void;
|
|
423
|
+
static random(): number;
|
|
425
424
|
}
|
|
426
425
|
export class Geom {
|
|
427
426
|
static boundAngle(angle: number): number;
|
|
@@ -962,9 +961,9 @@ export abstract class MultiTouchSpace extends Space {
|
|
|
962
961
|
protected _canvas: EventTarget;
|
|
963
962
|
get pointer(): Pt;
|
|
964
963
|
bindCanvas(evt: string, callback: EventListener, options?: any): void;
|
|
965
|
-
unbindCanvas(evt: string, callback: EventListener): void;
|
|
964
|
+
unbindCanvas(evt: string, callback: EventListener, options?: any): void;
|
|
966
965
|
bindMouse(_bind?: boolean): this;
|
|
967
|
-
bindTouch(
|
|
966
|
+
bindTouch(bind?: boolean, passive?: boolean): this;
|
|
968
967
|
touchesToPoints(evt: TouchEvent, which?: TouchPointsKey): Pt[];
|
|
969
968
|
protected _mouseAction(type: string, evt: MouseEvent | TouchEvent): void;
|
|
970
969
|
protected _mouseDown(evt: MouseEvent | TouchEvent): boolean;
|
|
@@ -1081,6 +1080,13 @@ export interface PtsCanvasRenderingContext2D extends CanvasRenderingContext2D {
|
|
|
1081
1080
|
oBackingStorePixelRatio?: number;
|
|
1082
1081
|
backingStorePixelRatio?: number;
|
|
1083
1082
|
}
|
|
1083
|
+
export type CanvasSpaceOptions = {
|
|
1084
|
+
bgcolor?: string;
|
|
1085
|
+
resize?: boolean;
|
|
1086
|
+
retina?: boolean;
|
|
1087
|
+
offscreen?: boolean;
|
|
1088
|
+
pixelDensity?: number;
|
|
1089
|
+
};
|
|
1084
1090
|
export type ColorType = "rgb" | "hsl" | "hsb" | "lab" | "lch" | "luv" | "xyz";
|
|
1085
1091
|
export type DelaunayShape = {
|
|
1086
1092
|
i: number;
|
|
@@ -1148,6 +1154,10 @@ export class Typography {
|
|
|
1148
1154
|
static fontSizeToThreshold(threshold: number, direction?: number): (a: number, b: number) => number;
|
|
1149
1155
|
}
|
|
1150
1156
|
|
|
1157
|
+
export default function (seed: string): {
|
|
1158
|
+
random(): number;
|
|
1159
|
+
};
|
|
1160
|
+
|
|
1151
1161
|
export const UIShape: {
|
|
1152
1162
|
rectangle: string;
|
|
1153
1163
|
circle: string;
|