pts 0.10.7 → 0.10.10
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 +27 -12
- package/dist/es2015/Canvas.js.map +1 -0
- package/dist/es2015/Color.js +1 -1
- package/dist/es2015/Color.js.map +1 -0
- package/dist/es2015/Create.js +1 -1
- package/dist/es2015/Create.js.map +1 -0
- package/dist/es2015/Dom.js +1 -1
- package/dist/es2015/Dom.js.map +1 -0
- package/dist/es2015/Form.js +1 -1
- package/dist/es2015/Form.js.map +1 -0
- package/dist/es2015/Image.js +78 -12
- package/dist/es2015/Image.js.map +1 -0
- package/dist/es2015/LinearAlgebra.js +36 -1
- package/dist/es2015/LinearAlgebra.js.map +1 -0
- package/dist/es2015/Num.js +1 -1
- package/dist/es2015/Num.js.map +1 -0
- package/dist/es2015/Op.js +1 -1
- package/dist/es2015/Op.js.map +1 -0
- package/dist/es2015/Physics.js +1 -1
- package/dist/es2015/Physics.js.map +1 -0
- package/dist/es2015/Play.js.map +1 -0
- package/dist/es2015/Pt.js +4 -1
- package/dist/es2015/Pt.js.map +1 -0
- package/dist/es2015/Space.js +95 -34
- package/dist/es2015/Space.js.map +1 -0
- package/dist/es2015/Svg.js +1 -1
- package/dist/es2015/Svg.js.map +1 -0
- package/dist/es2015/Types.js +1 -1
- package/dist/es2015/Types.js.map +1 -0
- package/dist/es2015/Typography.js +1 -1
- package/dist/es2015/Typography.js.map +1 -0
- package/dist/es2015/UI.js +6 -2
- package/dist/es2015/UI.js.map +1 -0
- package/dist/es2015/Util.js +14 -1
- package/dist/es2015/Util.js.map +1 -0
- package/dist/es2015/_lib.js.map +1 -0
- package/dist/es2015/_module.js.map +1 -0
- package/dist/es2015/uheprng.js.map +1 -0
- package/dist/es5.js +393 -70
- package/dist/es5.js.map +1 -0
- package/dist/index.js +270 -73
- package/dist/index.js.map +1 -0
- package/dist/pts.d.ts +42 -7
- package/dist/pts.js +271 -74
- package/dist/pts.js.map +1 -0
- package/dist/pts.min.js +2 -2
- package/dist/pts.min.js.map +1 -0
- package/dist/pts.module.js.map +1 -0
- package/package.json +1 -1
package/dist/es5.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* pts.js 0.10.
|
|
2
|
+
* pts.js 0.10.10 - Copyright © 2017-2022 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
|
|
|
115
115
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
116
116
|
|
|
@@ -234,13 +234,13 @@ var CanvasSpace = function (_Space_1$MultiTouchSp) {
|
|
|
234
234
|
key: "resize",
|
|
235
235
|
value: function resize(b, evt) {
|
|
236
236
|
this.bound = b;
|
|
237
|
-
this._canvas.width = this.bound.size.x * this._pixelScale;
|
|
238
|
-
this._canvas.height = this.bound.size.y * this._pixelScale;
|
|
239
|
-
this._canvas.style.width = Math.
|
|
240
|
-
this._canvas.style.height = Math.
|
|
237
|
+
this._canvas.width = Math.ceil(this.bound.size.x) * this._pixelScale;
|
|
238
|
+
this._canvas.height = Math.ceil(this.bound.size.y) * this._pixelScale;
|
|
239
|
+
this._canvas.style.width = Math.ceil(this.bound.size.x) + "px";
|
|
240
|
+
this._canvas.style.height = Math.ceil(this.bound.size.y) + "px";
|
|
241
241
|
if (this._offscreen) {
|
|
242
|
-
this._offCanvas.width = this.bound.size.x * this._pixelScale;
|
|
243
|
-
this._offCanvas.height = this.bound.size.y * this._pixelScale;
|
|
242
|
+
this._offCanvas.width = Math.ceil(this.bound.size.x) * this._pixelScale;
|
|
243
|
+
this._offCanvas.height = Math.ceil(this.bound.size.y) * this._pixelScale;
|
|
244
244
|
}
|
|
245
245
|
if (this._pixelScale != 1) {
|
|
246
246
|
this._ctx.scale(this._pixelScale, this._pixelScale);
|
|
@@ -279,14 +279,15 @@ var CanvasSpace = function (_Space_1$MultiTouchSp) {
|
|
|
279
279
|
value: function clear(bg) {
|
|
280
280
|
if (bg) this._bgcolor = bg;
|
|
281
281
|
var lastColor = this._ctx.fillStyle;
|
|
282
|
+
var px = Math.ceil(this.pixelScale);
|
|
282
283
|
if (!this._bgcolor || this._bgcolor === "transparent") {
|
|
283
|
-
this._ctx.clearRect(-
|
|
284
|
+
this._ctx.clearRect(-px, -px, this._canvas.width + px, this._canvas.height + px);
|
|
284
285
|
} else {
|
|
285
286
|
if (this._bgcolor.indexOf("rgba") === 0 || this._bgcolor.length === 9 && this._bgcolor.indexOf("#") === 0) {
|
|
286
|
-
this._ctx.clearRect(-
|
|
287
|
+
this._ctx.clearRect(-px, -px, this._canvas.width + px, this._canvas.height + px);
|
|
287
288
|
}
|
|
288
289
|
this._ctx.fillStyle = this._bgcolor;
|
|
289
|
-
this._ctx.fillRect(-
|
|
290
|
+
this._ctx.fillRect(-px, -px, this._canvas.width + px, this._canvas.height + px);
|
|
290
291
|
}
|
|
291
292
|
this._ctx.fillStyle = lastColor;
|
|
292
293
|
return this;
|
|
@@ -295,11 +296,12 @@ var CanvasSpace = function (_Space_1$MultiTouchSp) {
|
|
|
295
296
|
key: "clearOffscreen",
|
|
296
297
|
value: function clearOffscreen(bg) {
|
|
297
298
|
if (this._offscreen) {
|
|
299
|
+
var px = Math.ceil(this.pixelScale);
|
|
298
300
|
if (bg) {
|
|
299
301
|
this._offCtx.fillStyle = bg;
|
|
300
|
-
this._offCtx.fillRect(-
|
|
302
|
+
this._offCtx.fillRect(-px, -px, this._canvas.width + px, this._canvas.height + px);
|
|
301
303
|
} else {
|
|
302
|
-
this._offCtx.clearRect(-
|
|
304
|
+
this._offCtx.clearRect(-px, -px, this._offCanvas.width + px, this._offCanvas.height + px);
|
|
303
305
|
}
|
|
304
306
|
}
|
|
305
307
|
return this;
|
|
@@ -513,6 +515,23 @@ var CanvasForm = function (_Form_1$VisualForm) {
|
|
|
513
515
|
}
|
|
514
516
|
return this;
|
|
515
517
|
}
|
|
518
|
+
}, {
|
|
519
|
+
key: "applyFillStroke",
|
|
520
|
+
value: function applyFillStroke() {
|
|
521
|
+
var filled = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
522
|
+
var stroked = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
523
|
+
var strokeWidth = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
|
|
524
|
+
|
|
525
|
+
if (filled) {
|
|
526
|
+
if (typeof filled === 'string') this.fill(filled);
|
|
527
|
+
this._ctx.fill();
|
|
528
|
+
}
|
|
529
|
+
if (stroked) {
|
|
530
|
+
if (typeof stroked === 'string') this.stroke(stroked, strokeWidth);
|
|
531
|
+
this._ctx.stroke();
|
|
532
|
+
}
|
|
533
|
+
return this;
|
|
534
|
+
}
|
|
516
535
|
}, {
|
|
517
536
|
key: "gradient",
|
|
518
537
|
value: function gradient(stops) {
|
|
@@ -999,7 +1018,7 @@ exports.CanvasForm = CanvasForm;
|
|
|
999
1018
|
|
|
1000
1019
|
"use strict";
|
|
1001
1020
|
|
|
1002
|
-
/*!
|
|
1021
|
+
/*! Pts.js is licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
|
|
1003
1022
|
|
|
1004
1023
|
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
|
|
1005
1024
|
|
|
@@ -1620,7 +1639,7 @@ Color.ranges = {
|
|
|
1620
1639
|
|
|
1621
1640
|
"use strict";
|
|
1622
1641
|
|
|
1623
|
-
/*!
|
|
1642
|
+
/*! Pts.js is licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
|
|
1624
1643
|
|
|
1625
1644
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
1626
1645
|
|
|
@@ -2028,7 +2047,7 @@ exports.Delaunay = Delaunay;
|
|
|
2028
2047
|
|
|
2029
2048
|
"use strict";
|
|
2030
2049
|
|
|
2031
|
-
/*!
|
|
2050
|
+
/*! Pts.js is licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
|
|
2032
2051
|
|
|
2033
2052
|
var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
|
|
2034
2053
|
|
|
@@ -2637,7 +2656,7 @@ HTMLForm.domID = 0;
|
|
|
2637
2656
|
|
|
2638
2657
|
"use strict";
|
|
2639
2658
|
|
|
2640
|
-
/*!
|
|
2659
|
+
/*! Pts.js is licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
|
|
2641
2660
|
|
|
2642
2661
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
2643
2662
|
|
|
@@ -2836,14 +2855,43 @@ var _createClass = function () { function defineProperties(target, props) { for
|
|
|
2836
2855
|
|
|
2837
2856
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
2838
2857
|
|
|
2858
|
+
var __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {
|
|
2859
|
+
function adopt(value) {
|
|
2860
|
+
return value instanceof P ? value : new P(function (resolve) {
|
|
2861
|
+
resolve(value);
|
|
2862
|
+
});
|
|
2863
|
+
}
|
|
2864
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
2865
|
+
function fulfilled(value) {
|
|
2866
|
+
try {
|
|
2867
|
+
step(generator.next(value));
|
|
2868
|
+
} catch (e) {
|
|
2869
|
+
reject(e);
|
|
2870
|
+
}
|
|
2871
|
+
}
|
|
2872
|
+
function rejected(value) {
|
|
2873
|
+
try {
|
|
2874
|
+
step(generator["throw"](value));
|
|
2875
|
+
} catch (e) {
|
|
2876
|
+
reject(e);
|
|
2877
|
+
}
|
|
2878
|
+
}
|
|
2879
|
+
function step(result) {
|
|
2880
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
2881
|
+
}
|
|
2882
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
2883
|
+
});
|
|
2884
|
+
};
|
|
2839
2885
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2840
2886
|
exports.Img = void 0;
|
|
2887
|
+
var Canvas_1 = __webpack_require__(/*! ./Canvas */ "./src/Canvas.ts");
|
|
2841
2888
|
var Pt_1 = __webpack_require__(/*! ./Pt */ "./src/Pt.ts");
|
|
2889
|
+
var LinearAlgebra_1 = __webpack_require__(/*! ./LinearAlgebra */ "./src/LinearAlgebra.ts");
|
|
2842
2890
|
|
|
2843
2891
|
var Img = function () {
|
|
2844
2892
|
function Img() {
|
|
2845
2893
|
var editable = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
2846
|
-
var
|
|
2894
|
+
var space = arguments[1];
|
|
2847
2895
|
var crossOrigin = arguments[2];
|
|
2848
2896
|
|
|
2849
2897
|
_classCallCheck(this, Img);
|
|
@@ -2851,7 +2899,8 @@ var Img = function () {
|
|
|
2851
2899
|
this._scale = 1;
|
|
2852
2900
|
this._loaded = false;
|
|
2853
2901
|
this._editable = editable;
|
|
2854
|
-
this.
|
|
2902
|
+
this._space = space;
|
|
2903
|
+
this._scale = this._space ? this._space.pixelScale : 1;
|
|
2855
2904
|
this._img = new Image();
|
|
2856
2905
|
if (crossOrigin) this._img.crossOrigin = "Anonymous";
|
|
2857
2906
|
}
|
|
@@ -2862,6 +2911,9 @@ var Img = function () {
|
|
|
2862
2911
|
var _this = this;
|
|
2863
2912
|
|
|
2864
2913
|
return new Promise(function (resolve, reject) {
|
|
2914
|
+
if (_this._editable && !document) {
|
|
2915
|
+
reject("Cannot create html canvas element. document not found.");
|
|
2916
|
+
}
|
|
2865
2917
|
_this._img.src = src;
|
|
2866
2918
|
_this._img.onload = function () {
|
|
2867
2919
|
if (_this._editable) {
|
|
@@ -2880,14 +2932,27 @@ var Img = function () {
|
|
|
2880
2932
|
}, {
|
|
2881
2933
|
key: "_drawToScale",
|
|
2882
2934
|
value: function _drawToScale(canvasScale, img) {
|
|
2883
|
-
var cms = typeof canvasScale === 'number' ? [canvasScale, canvasScale] : canvasScale;
|
|
2884
2935
|
var nw = img.width;
|
|
2885
2936
|
var nh = img.height;
|
|
2886
|
-
this.
|
|
2887
|
-
this._cv.height = nh * cms[1];
|
|
2888
|
-
this._ctx = this._cv.getContext('2d');
|
|
2937
|
+
this.initCanvas(nw, nh, canvasScale);
|
|
2889
2938
|
if (img) this._ctx.drawImage(img, 0, 0, nw, nh, 0, 0, this._cv.width, this._cv.height);
|
|
2890
2939
|
}
|
|
2940
|
+
}, {
|
|
2941
|
+
key: "initCanvas",
|
|
2942
|
+
value: function initCanvas(width, height) {
|
|
2943
|
+
var canvasScale = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
|
|
2944
|
+
|
|
2945
|
+
if (!this._editable) {
|
|
2946
|
+
console.error('Cannot initiate canvas because this Img is not set to be editable');
|
|
2947
|
+
return;
|
|
2948
|
+
}
|
|
2949
|
+
if (!this._cv) this._cv = document.createElement("canvas");
|
|
2950
|
+
var cms = typeof canvasScale === 'number' ? [canvasScale, canvasScale] : canvasScale;
|
|
2951
|
+
this._cv.width = width * cms[0];
|
|
2952
|
+
this._cv.height = height * cms[1];
|
|
2953
|
+
this._ctx = this._cv.getContext('2d');
|
|
2954
|
+
this._loaded = true;
|
|
2955
|
+
}
|
|
2891
2956
|
}, {
|
|
2892
2957
|
key: "bitmap",
|
|
2893
2958
|
value: function bitmap(size) {
|
|
@@ -2895,6 +2960,15 @@ var Img = function () {
|
|
|
2895
2960
|
var h = size ? size[1] : this._cv.height;
|
|
2896
2961
|
return createImageBitmap(this._cv, 0, 0, w, h);
|
|
2897
2962
|
}
|
|
2963
|
+
}, {
|
|
2964
|
+
key: "pattern",
|
|
2965
|
+
value: function pattern() {
|
|
2966
|
+
var reptition = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'repeat';
|
|
2967
|
+
var dynamic = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
2968
|
+
|
|
2969
|
+
if (!this._space) throw "Cannot find CanvasSpace ctx to create image pattern";
|
|
2970
|
+
return this._space.ctx.createPattern(dynamic ? this._cv : this._img, reptition);
|
|
2971
|
+
}
|
|
2898
2972
|
}, {
|
|
2899
2973
|
key: "sync",
|
|
2900
2974
|
value: function sync() {
|
|
@@ -2965,6 +3039,14 @@ var Img = function () {
|
|
|
2965
3039
|
});
|
|
2966
3040
|
});
|
|
2967
3041
|
}
|
|
3042
|
+
}, {
|
|
3043
|
+
key: "getForm",
|
|
3044
|
+
value: function getForm() {
|
|
3045
|
+
if (!this._editable) {
|
|
3046
|
+
console.error("Cannot get a CanvasForm because this Img is not editable");
|
|
3047
|
+
}
|
|
3048
|
+
return this._ctx ? new Canvas_1.CanvasForm(this._ctx) : undefined;
|
|
3049
|
+
}
|
|
2968
3050
|
}, {
|
|
2969
3051
|
key: "current",
|
|
2970
3052
|
get: function get() {
|
|
@@ -3003,26 +3085,98 @@ var Img = function () {
|
|
|
3003
3085
|
}, {
|
|
3004
3086
|
key: "imageSize",
|
|
3005
3087
|
get: function get() {
|
|
3006
|
-
|
|
3088
|
+
if (!this._img.width || !this._img.height) {
|
|
3089
|
+
return this.canvasSize.$divide(this._scale);
|
|
3090
|
+
} else {
|
|
3091
|
+
return new Pt_1.Pt(this._img.width, this._img.height);
|
|
3092
|
+
}
|
|
3007
3093
|
}
|
|
3008
3094
|
}, {
|
|
3009
3095
|
key: "canvasSize",
|
|
3010
3096
|
get: function get() {
|
|
3011
3097
|
return new Pt_1.Pt(this._cv.width, this._cv.height);
|
|
3012
3098
|
}
|
|
3099
|
+
}, {
|
|
3100
|
+
key: "scaledMatrix",
|
|
3101
|
+
get: function get() {
|
|
3102
|
+
var s = 1 / this._scale;
|
|
3103
|
+
return new LinearAlgebra_1.Mat().scale2D([s, s]);
|
|
3104
|
+
}
|
|
3013
3105
|
}], [{
|
|
3014
3106
|
key: "load",
|
|
3015
3107
|
value: function load(src) {
|
|
3016
3108
|
var editable = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
3017
|
-
var
|
|
3109
|
+
var space = arguments[2];
|
|
3018
3110
|
var ready = arguments[3];
|
|
3019
3111
|
|
|
3020
|
-
var img = new Img(editable,
|
|
3112
|
+
var img = new Img(editable, space);
|
|
3021
3113
|
img.load(src).then(function (res) {
|
|
3022
3114
|
if (ready) ready(res);
|
|
3023
3115
|
});
|
|
3024
3116
|
return img;
|
|
3025
3117
|
}
|
|
3118
|
+
}, {
|
|
3119
|
+
key: "loadAsync",
|
|
3120
|
+
value: function loadAsync(src) {
|
|
3121
|
+
var editable = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
3122
|
+
var space = arguments[2];
|
|
3123
|
+
|
|
3124
|
+
return __awaiter(this, void 0, void 0, regeneratorRuntime.mark(function _callee() {
|
|
3125
|
+
var img;
|
|
3126
|
+
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
3127
|
+
while (1) {
|
|
3128
|
+
switch (_context.prev = _context.next) {
|
|
3129
|
+
case 0:
|
|
3130
|
+
_context.next = 2;
|
|
3131
|
+
return new Img(editable, space).load(src);
|
|
3132
|
+
|
|
3133
|
+
case 2:
|
|
3134
|
+
img = _context.sent;
|
|
3135
|
+
return _context.abrupt("return", img);
|
|
3136
|
+
|
|
3137
|
+
case 4:
|
|
3138
|
+
case "end":
|
|
3139
|
+
return _context.stop();
|
|
3140
|
+
}
|
|
3141
|
+
}
|
|
3142
|
+
}, _callee, this);
|
|
3143
|
+
}));
|
|
3144
|
+
}
|
|
3145
|
+
}, {
|
|
3146
|
+
key: "loadPattern",
|
|
3147
|
+
value: function loadPattern(src, space) {
|
|
3148
|
+
var repeat = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'repeat';
|
|
3149
|
+
var editable = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
3150
|
+
|
|
3151
|
+
return __awaiter(this, void 0, void 0, regeneratorRuntime.mark(function _callee2() {
|
|
3152
|
+
var img;
|
|
3153
|
+
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
3154
|
+
while (1) {
|
|
3155
|
+
switch (_context2.prev = _context2.next) {
|
|
3156
|
+
case 0:
|
|
3157
|
+
_context2.next = 2;
|
|
3158
|
+
return Img.loadAsync(src, editable, space);
|
|
3159
|
+
|
|
3160
|
+
case 2:
|
|
3161
|
+
img = _context2.sent;
|
|
3162
|
+
return _context2.abrupt("return", img.pattern(repeat));
|
|
3163
|
+
|
|
3164
|
+
case 4:
|
|
3165
|
+
case "end":
|
|
3166
|
+
return _context2.stop();
|
|
3167
|
+
}
|
|
3168
|
+
}
|
|
3169
|
+
}, _callee2, this);
|
|
3170
|
+
}));
|
|
3171
|
+
}
|
|
3172
|
+
}, {
|
|
3173
|
+
key: "blank",
|
|
3174
|
+
value: function blank(size, space, scale) {
|
|
3175
|
+
var img = new Img(true, space);
|
|
3176
|
+
var s = scale ? scale : space.pixelScale;
|
|
3177
|
+
img.initCanvas(size[0], size[1], s);
|
|
3178
|
+
return img;
|
|
3179
|
+
}
|
|
3026
3180
|
}, {
|
|
3027
3181
|
key: "getPixel",
|
|
3028
3182
|
value: function getPixel(imgData, p) {
|
|
@@ -3037,15 +3191,18 @@ var Img = function () {
|
|
|
3037
3191
|
key: "fromBlob",
|
|
3038
3192
|
value: function fromBlob(blob) {
|
|
3039
3193
|
var editable = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
3040
|
-
var
|
|
3194
|
+
var space = arguments[2];
|
|
3041
3195
|
|
|
3042
3196
|
var url = URL.createObjectURL(blob);
|
|
3043
|
-
return new Img(editable,
|
|
3197
|
+
return new Img(editable, space).load(url);
|
|
3044
3198
|
}
|
|
3045
3199
|
}, {
|
|
3046
3200
|
key: "imageDataToBlob",
|
|
3047
3201
|
value: function imageDataToBlob(data) {
|
|
3048
|
-
return new Promise(function (resolve) {
|
|
3202
|
+
return new Promise(function (resolve, reject) {
|
|
3203
|
+
if (!document) {
|
|
3204
|
+
reject("Cannot create html canvas element. document not found.");
|
|
3205
|
+
}
|
|
3049
3206
|
var cv = document.createElement("canvas");
|
|
3050
3207
|
cv.width = data.width;
|
|
3051
3208
|
cv.height = data.height;
|
|
@@ -3074,7 +3231,7 @@ exports.Img = Img;
|
|
|
3074
3231
|
|
|
3075
3232
|
"use strict";
|
|
3076
3233
|
|
|
3077
|
-
/*!
|
|
3234
|
+
/*! Pts.js is licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
|
|
3078
3235
|
|
|
3079
3236
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
3080
3237
|
|
|
@@ -3255,9 +3412,60 @@ exports.Vec = Vec;
|
|
|
3255
3412
|
var Mat = function () {
|
|
3256
3413
|
function Mat() {
|
|
3257
3414
|
_classCallCheck(this, Mat);
|
|
3415
|
+
|
|
3416
|
+
this.reset();
|
|
3258
3417
|
}
|
|
3259
3418
|
|
|
3260
|
-
_createClass(Mat,
|
|
3419
|
+
_createClass(Mat, [{
|
|
3420
|
+
key: "reset",
|
|
3421
|
+
value: function reset() {
|
|
3422
|
+
this._33 = Mat.scale2DMatrix(1, 1);
|
|
3423
|
+
}
|
|
3424
|
+
}, {
|
|
3425
|
+
key: "scale2D",
|
|
3426
|
+
value: function scale2D(val) {
|
|
3427
|
+
var at = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [0, 0];
|
|
3428
|
+
|
|
3429
|
+
var m = Mat.scaleAt2DMatrix(val[0] || 1, val[1] || 1, at);
|
|
3430
|
+
this._33 = Mat.multiply(this._33, m);
|
|
3431
|
+
return this;
|
|
3432
|
+
}
|
|
3433
|
+
}, {
|
|
3434
|
+
key: "rotate2D",
|
|
3435
|
+
value: function rotate2D(ang) {
|
|
3436
|
+
var at = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [0, 0];
|
|
3437
|
+
|
|
3438
|
+
var m = Mat.rotateAt2DMatrix(Math.cos(ang), Math.sin(ang), at);
|
|
3439
|
+
this._33 = Mat.multiply(this._33, m);
|
|
3440
|
+
return this;
|
|
3441
|
+
}
|
|
3442
|
+
}, {
|
|
3443
|
+
key: "translate2D",
|
|
3444
|
+
value: function translate2D(val) {
|
|
3445
|
+
var m = Mat.translate2DMatrix(val[0] || 0, val[1] || 0);
|
|
3446
|
+
this._33 = Mat.multiply(this._33, m);
|
|
3447
|
+
return this;
|
|
3448
|
+
}
|
|
3449
|
+
}, {
|
|
3450
|
+
key: "shear2D",
|
|
3451
|
+
value: function shear2D(val) {
|
|
3452
|
+
var at = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [0, 0];
|
|
3453
|
+
|
|
3454
|
+
var m = Mat.shearAt2DMatrix(Math.tan(val[0] || 0), Math.tan(val[1] || 1), at);
|
|
3455
|
+
this._33 = Mat.multiply(this._33, m);
|
|
3456
|
+
return this;
|
|
3457
|
+
}
|
|
3458
|
+
}, {
|
|
3459
|
+
key: "value",
|
|
3460
|
+
get: function get() {
|
|
3461
|
+
return this._33;
|
|
3462
|
+
}
|
|
3463
|
+
}, {
|
|
3464
|
+
key: "domMatrix",
|
|
3465
|
+
get: function get() {
|
|
3466
|
+
return new DOMMatrix(Mat.toDOMMatrix(this._33));
|
|
3467
|
+
}
|
|
3468
|
+
}], [{
|
|
3261
3469
|
key: "add",
|
|
3262
3470
|
value: function add(a, b) {
|
|
3263
3471
|
if (typeof b != "number") {
|
|
@@ -3338,6 +3546,11 @@ var Mat = function () {
|
|
|
3338
3546
|
|
|
3339
3547
|
return Mat.zip(g, defaultValue, useLongest);
|
|
3340
3548
|
}
|
|
3549
|
+
}, {
|
|
3550
|
+
key: "toDOMMatrix",
|
|
3551
|
+
value: function toDOMMatrix(m) {
|
|
3552
|
+
return [m[0][0], m[0][1], m[1][0], m[1][1], m[2][0], m[2][1]];
|
|
3553
|
+
}
|
|
3341
3554
|
}, {
|
|
3342
3555
|
key: "transform2D",
|
|
3343
3556
|
value: function transform2D(pt, m) {
|
|
@@ -3421,7 +3634,7 @@ exports.Mat = Mat;
|
|
|
3421
3634
|
|
|
3422
3635
|
"use strict";
|
|
3423
3636
|
|
|
3424
|
-
/*!
|
|
3637
|
+
/*! Pts.js is licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
|
|
3425
3638
|
|
|
3426
3639
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
3427
3640
|
|
|
@@ -4211,7 +4424,7 @@ exports.Range = Range;
|
|
|
4211
4424
|
|
|
4212
4425
|
"use strict";
|
|
4213
4426
|
|
|
4214
|
-
/*!
|
|
4427
|
+
/*! Pts.js is licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
|
|
4215
4428
|
|
|
4216
4429
|
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
|
|
4217
4430
|
|
|
@@ -5574,7 +5787,7 @@ exports.Curve = Curve;
|
|
|
5574
5787
|
|
|
5575
5788
|
"use strict";
|
|
5576
5789
|
|
|
5577
|
-
/*!
|
|
5790
|
+
/*! Pts.js is licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
|
|
5578
5791
|
|
|
5579
5792
|
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
|
|
5580
5793
|
|
|
@@ -6746,7 +6959,7 @@ exports.Sound = Sound;
|
|
|
6746
6959
|
|
|
6747
6960
|
"use strict";
|
|
6748
6961
|
|
|
6749
|
-
/*!
|
|
6962
|
+
/*! Pts.js is licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
|
|
6750
6963
|
|
|
6751
6964
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
6752
6965
|
|
|
@@ -7501,6 +7714,11 @@ var Group = function (_extendableBuiltin4) {
|
|
|
7501
7714
|
|
|
7502
7715
|
return LinearAlgebra_1.Mat.zip(this, defaultValue, useLongest);
|
|
7503
7716
|
}
|
|
7717
|
+
}, {
|
|
7718
|
+
key: "toBound",
|
|
7719
|
+
value: function toBound() {
|
|
7720
|
+
return Bound.fromGroup(this);
|
|
7721
|
+
}
|
|
7504
7722
|
}, {
|
|
7505
7723
|
key: "toString",
|
|
7506
7724
|
value: function toString() {
|
|
@@ -7799,7 +8017,7 @@ exports.Bound = Bound;
|
|
|
7799
8017
|
|
|
7800
8018
|
"use strict";
|
|
7801
8019
|
|
|
7802
|
-
/*!
|
|
8020
|
+
/*! Pts.js is licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
|
|
7803
8021
|
|
|
7804
8022
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
7805
8023
|
|
|
@@ -7820,7 +8038,7 @@ var Space = function () {
|
|
|
7820
8038
|
|
|
7821
8039
|
this.id = "space";
|
|
7822
8040
|
this.bound = new Pt_1.Bound();
|
|
7823
|
-
this._time = { prev: 0, diff: 0, end: -1 };
|
|
8041
|
+
this._time = { prev: 0, diff: 0, end: -1, min: 0 };
|
|
7824
8042
|
this.players = {};
|
|
7825
8043
|
this.playerCount = 0;
|
|
7826
8044
|
this._animID = -1;
|
|
@@ -7837,6 +8055,13 @@ var Space = function () {
|
|
|
7837
8055
|
this._refresh = b;
|
|
7838
8056
|
return this;
|
|
7839
8057
|
}
|
|
8058
|
+
}, {
|
|
8059
|
+
key: "minFrameTime",
|
|
8060
|
+
value: function minFrameTime() {
|
|
8061
|
+
var ms = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
8062
|
+
|
|
8063
|
+
this._time.min = ms;
|
|
8064
|
+
}
|
|
7840
8065
|
}, {
|
|
7841
8066
|
key: "add",
|
|
7842
8067
|
value: function add(p) {
|
|
@@ -7872,6 +8097,7 @@ var Space = function () {
|
|
|
7872
8097
|
this._animID = requestAnimationFrame(this.play.bind(this));
|
|
7873
8098
|
if (this._pause) return this;
|
|
7874
8099
|
this._time.diff = time - this._time.prev;
|
|
8100
|
+
if (this._time.diff < this._time.min) return this;
|
|
7875
8101
|
this._time.prev = time;
|
|
7876
8102
|
try {
|
|
7877
8103
|
this.playItems(time);
|
|
@@ -7930,7 +8156,7 @@ var Space = function () {
|
|
|
7930
8156
|
}, {
|
|
7931
8157
|
key: "playOnce",
|
|
7932
8158
|
value: function playOnce() {
|
|
7933
|
-
var duration = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] :
|
|
8159
|
+
var duration = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
7934
8160
|
|
|
7935
8161
|
this.play();
|
|
7936
8162
|
this.stop(duration);
|
|
@@ -8004,6 +8230,7 @@ var MultiTouchSpace = function (_Space) {
|
|
|
8004
8230
|
_this._dragged = false;
|
|
8005
8231
|
_this._hasMouse = false;
|
|
8006
8232
|
_this._hasTouch = false;
|
|
8233
|
+
_this._hasKeyboard = false;
|
|
8007
8234
|
return _this;
|
|
8008
8235
|
}
|
|
8009
8236
|
|
|
@@ -8011,38 +8238,68 @@ var MultiTouchSpace = function (_Space) {
|
|
|
8011
8238
|
key: "bindCanvas",
|
|
8012
8239
|
value: function bindCanvas(evt, callback) {
|
|
8013
8240
|
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
8241
|
+
var customTarget = arguments[3];
|
|
8014
8242
|
|
|
8015
|
-
this._canvas
|
|
8243
|
+
var target = customTarget ? customTarget : this._canvas;
|
|
8244
|
+
target.addEventListener(evt, callback, options);
|
|
8016
8245
|
}
|
|
8017
8246
|
}, {
|
|
8018
8247
|
key: "unbindCanvas",
|
|
8019
8248
|
value: function unbindCanvas(evt, callback) {
|
|
8020
8249
|
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
8250
|
+
var customTarget = arguments[3];
|
|
8021
8251
|
|
|
8022
|
-
this._canvas
|
|
8252
|
+
var target = customTarget ? customTarget : this._canvas;
|
|
8253
|
+
target.removeEventListener(evt, callback, options);
|
|
8254
|
+
}
|
|
8255
|
+
}, {
|
|
8256
|
+
key: "bindDoc",
|
|
8257
|
+
value: function bindDoc(evt, callback) {
|
|
8258
|
+
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
8259
|
+
|
|
8260
|
+
if (document) {
|
|
8261
|
+
document.addEventListener(evt, callback, options);
|
|
8262
|
+
}
|
|
8263
|
+
}
|
|
8264
|
+
}, {
|
|
8265
|
+
key: "unbindDoc",
|
|
8266
|
+
value: function unbindDoc(evt, callback) {
|
|
8267
|
+
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
8268
|
+
|
|
8269
|
+
if (document) {
|
|
8270
|
+
document.removeEventListener(evt, callback, options);
|
|
8271
|
+
}
|
|
8023
8272
|
}
|
|
8024
8273
|
}, {
|
|
8025
8274
|
key: "bindMouse",
|
|
8026
8275
|
value: function bindMouse() {
|
|
8027
|
-
var
|
|
8028
|
-
|
|
8029
|
-
|
|
8030
|
-
|
|
8031
|
-
this.
|
|
8032
|
-
this.
|
|
8033
|
-
this.
|
|
8034
|
-
this.
|
|
8035
|
-
this.
|
|
8036
|
-
this.
|
|
8276
|
+
var bind = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
8277
|
+
var customTarget = arguments[1];
|
|
8278
|
+
|
|
8279
|
+
if (bind) {
|
|
8280
|
+
this._mouseDown = this._mouseDown.bind(this);
|
|
8281
|
+
this._mouseUp = this._mouseUp.bind(this);
|
|
8282
|
+
this._mouseOver = this._mouseOver.bind(this);
|
|
8283
|
+
this._mouseOut = this._mouseOut.bind(this);
|
|
8284
|
+
this._mouseMove = this._mouseMove.bind(this);
|
|
8285
|
+
this._mouseClick = this._mouseClick.bind(this);
|
|
8286
|
+
this._contextMenu = this._contextMenu.bind(this);
|
|
8287
|
+
this.bindCanvas("mousedown", this._mouseDown, {}, customTarget);
|
|
8288
|
+
this.bindCanvas("mouseup", this._mouseUp, {}, customTarget);
|
|
8289
|
+
this.bindCanvas("mouseover", this._mouseOver, {}, customTarget);
|
|
8290
|
+
this.bindCanvas("mouseout", this._mouseOut, {}, customTarget);
|
|
8291
|
+
this.bindCanvas("mousemove", this._mouseMove, {}, customTarget);
|
|
8292
|
+
this.bindCanvas("click", this._mouseClick, {}, customTarget);
|
|
8293
|
+
this.bindCanvas("contextmenu", this._contextMenu, {}, customTarget);
|
|
8037
8294
|
this._hasMouse = true;
|
|
8038
8295
|
} else {
|
|
8039
|
-
this.unbindCanvas("mousedown", this._mouseDown
|
|
8040
|
-
this.unbindCanvas("mouseup", this._mouseUp
|
|
8041
|
-
this.unbindCanvas("mouseover", this._mouseOver
|
|
8042
|
-
this.unbindCanvas("mouseout", this._mouseOut
|
|
8043
|
-
this.unbindCanvas("mousemove", this._mouseMove
|
|
8044
|
-
this.unbindCanvas("click", this._mouseClick
|
|
8045
|
-
this.unbindCanvas("contextmenu", this._contextMenu
|
|
8296
|
+
this.unbindCanvas("mousedown", this._mouseDown, {}, customTarget);
|
|
8297
|
+
this.unbindCanvas("mouseup", this._mouseUp, {}, customTarget);
|
|
8298
|
+
this.unbindCanvas("mouseover", this._mouseOver, {}, customTarget);
|
|
8299
|
+
this.unbindCanvas("mouseout", this._mouseOut, {}, customTarget);
|
|
8300
|
+
this.unbindCanvas("mousemove", this._mouseMove, {}, customTarget);
|
|
8301
|
+
this.unbindCanvas("click", this._mouseClick, {}, customTarget);
|
|
8302
|
+
this.unbindCanvas("contextmenu", this._contextMenu, {}, customTarget);
|
|
8046
8303
|
this._hasMouse = false;
|
|
8047
8304
|
}
|
|
8048
8305
|
return this;
|
|
@@ -8052,22 +8309,41 @@ var MultiTouchSpace = function (_Space) {
|
|
|
8052
8309
|
value: function bindTouch() {
|
|
8053
8310
|
var bind = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
8054
8311
|
var passive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
8312
|
+
var customTarget = arguments[2];
|
|
8055
8313
|
|
|
8056
8314
|
if (bind) {
|
|
8057
|
-
this.bindCanvas("touchstart", this._touchStart.bind(this), { passive: passive });
|
|
8058
|
-
this.bindCanvas("touchend", this._mouseUp.bind(this));
|
|
8059
|
-
this.bindCanvas("touchmove", this._touchMove.bind(this), { passive: passive });
|
|
8060
|
-
this.bindCanvas("touchcancel", this._mouseOut.bind(this));
|
|
8315
|
+
this.bindCanvas("touchstart", this._touchStart.bind(this), { passive: passive }, customTarget);
|
|
8316
|
+
this.bindCanvas("touchend", this._mouseUp.bind(this), {}, customTarget);
|
|
8317
|
+
this.bindCanvas("touchmove", this._touchMove.bind(this), { passive: passive }, customTarget);
|
|
8318
|
+
this.bindCanvas("touchcancel", this._mouseOut.bind(this), {}, customTarget);
|
|
8061
8319
|
this._hasTouch = true;
|
|
8062
8320
|
} else {
|
|
8063
|
-
this.unbindCanvas("touchstart", this._touchStart.bind(this), { passive: passive });
|
|
8064
|
-
this.unbindCanvas("touchend", this._mouseUp.bind(this));
|
|
8065
|
-
this.unbindCanvas("touchmove", this._touchMove.bind(this), { passive: passive });
|
|
8066
|
-
this.unbindCanvas("touchcancel", this._mouseOut.bind(this));
|
|
8321
|
+
this.unbindCanvas("touchstart", this._touchStart.bind(this), { passive: passive }, customTarget);
|
|
8322
|
+
this.unbindCanvas("touchend", this._mouseUp.bind(this), {}, customTarget);
|
|
8323
|
+
this.unbindCanvas("touchmove", this._touchMove.bind(this), { passive: passive }, customTarget);
|
|
8324
|
+
this.unbindCanvas("touchcancel", this._mouseOut.bind(this), {}, customTarget);
|
|
8067
8325
|
this._hasTouch = false;
|
|
8068
8326
|
}
|
|
8069
8327
|
return this;
|
|
8070
8328
|
}
|
|
8329
|
+
}, {
|
|
8330
|
+
key: "bindKeyboard",
|
|
8331
|
+
value: function bindKeyboard() {
|
|
8332
|
+
var bind = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
8333
|
+
|
|
8334
|
+
if (bind) {
|
|
8335
|
+
this._keyDownBind = this._keyDown.bind(this);
|
|
8336
|
+
this._keyUpBind = this._keyUp.bind(this);
|
|
8337
|
+
this.bindDoc("keydown", this._keyDownBind, {});
|
|
8338
|
+
this.bindDoc("keyup", this._keyUpBind, {});
|
|
8339
|
+
this._hasKeyboard = true;
|
|
8340
|
+
} else {
|
|
8341
|
+
this.unbindDoc("keydown", this._keyDownBind, {});
|
|
8342
|
+
this.unbindDoc("keyup", this._keyUpBind, {});
|
|
8343
|
+
this._hasKeyboard = false;
|
|
8344
|
+
}
|
|
8345
|
+
return this;
|
|
8346
|
+
}
|
|
8071
8347
|
}, {
|
|
8072
8348
|
key: "touchesToPoints",
|
|
8073
8349
|
value: function touchesToPoints(evt) {
|
|
@@ -8084,6 +8360,7 @@ var MultiTouchSpace = function (_Space) {
|
|
|
8084
8360
|
}, {
|
|
8085
8361
|
key: "_mouseAction",
|
|
8086
8362
|
value: function _mouseAction(type, evt) {
|
|
8363
|
+
if (!this.isPlaying) return;
|
|
8087
8364
|
var px = 0,
|
|
8088
8365
|
py = 0;
|
|
8089
8366
|
if (evt instanceof MouseEvent) {
|
|
@@ -8183,6 +8460,29 @@ var MultiTouchSpace = function (_Space) {
|
|
|
8183
8460
|
evt.preventDefault();
|
|
8184
8461
|
return false;
|
|
8185
8462
|
}
|
|
8463
|
+
}, {
|
|
8464
|
+
key: "_keyDown",
|
|
8465
|
+
value: function _keyDown(evt) {
|
|
8466
|
+
this._keyboardAction(UI_1.UIPointerActions.keydown, evt);
|
|
8467
|
+
return false;
|
|
8468
|
+
}
|
|
8469
|
+
}, {
|
|
8470
|
+
key: "_keyUp",
|
|
8471
|
+
value: function _keyUp(evt) {
|
|
8472
|
+
this._keyboardAction(UI_1.UIPointerActions.keyup, evt);
|
|
8473
|
+
return false;
|
|
8474
|
+
}
|
|
8475
|
+
}, {
|
|
8476
|
+
key: "_keyboardAction",
|
|
8477
|
+
value: function _keyboardAction(type, evt) {
|
|
8478
|
+
if (!this.isPlaying) return;
|
|
8479
|
+
for (var k in this.players) {
|
|
8480
|
+
if (this.players.hasOwnProperty(k)) {
|
|
8481
|
+
var v = this.players[k];
|
|
8482
|
+
if (v.action) v.action(type, evt.shiftKey ? 1 : 0, evt.altKey ? 1 : 0, evt);
|
|
8483
|
+
}
|
|
8484
|
+
}
|
|
8485
|
+
}
|
|
8186
8486
|
}, {
|
|
8187
8487
|
key: "pointer",
|
|
8188
8488
|
get: function get() {
|
|
@@ -8208,7 +8508,7 @@ exports.MultiTouchSpace = MultiTouchSpace;
|
|
|
8208
8508
|
|
|
8209
8509
|
"use strict";
|
|
8210
8510
|
|
|
8211
|
-
/*!
|
|
8511
|
+
/*! Pts.js is licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
|
|
8212
8512
|
|
|
8213
8513
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
8214
8514
|
|
|
@@ -8716,7 +9016,7 @@ SVGForm.domID = 0;
|
|
|
8716
9016
|
|
|
8717
9017
|
"use strict";
|
|
8718
9018
|
|
|
8719
|
-
/*!
|
|
9019
|
+
/*! Pts.js is licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
|
|
8720
9020
|
|
|
8721
9021
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
8722
9022
|
|
|
@@ -8801,7 +9101,7 @@ exports.Typography = Typography;
|
|
|
8801
9101
|
|
|
8802
9102
|
"use strict";
|
|
8803
9103
|
|
|
8804
|
-
/*!
|
|
9104
|
+
/*! Pts.js is licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
|
|
8805
9105
|
|
|
8806
9106
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
8807
9107
|
|
|
@@ -8821,7 +9121,11 @@ exports.UIShape = {
|
|
|
8821
9121
|
rectangle: "rectangle", circle: "circle", polygon: "polygon", polyline: "polyline", line: "line"
|
|
8822
9122
|
};
|
|
8823
9123
|
exports.UIPointerActions = {
|
|
8824
|
-
up: "up", down: "down", move: "move",
|
|
9124
|
+
up: "up", down: "down", move: "move",
|
|
9125
|
+
drag: "drag", uidrag: "uidrag", drop: "drop", uidrop: "uidrop",
|
|
9126
|
+
over: "over", out: "out", enter: "enter", leave: "leave", click: "click",
|
|
9127
|
+
keydown: 'keydown', keyup: 'keyup',
|
|
9128
|
+
contextmenu: "contextmenu", all: "all"
|
|
8825
9129
|
};
|
|
8826
9130
|
|
|
8827
9131
|
var UI = function () {
|
|
@@ -9189,7 +9493,7 @@ exports.UIDragger = UIDragger;
|
|
|
9189
9493
|
|
|
9190
9494
|
"use strict";
|
|
9191
9495
|
|
|
9192
|
-
/*!
|
|
9496
|
+
/*! Pts.js is licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
|
|
9193
9497
|
|
|
9194
9498
|
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
|
|
9195
9499
|
|
|
@@ -9392,6 +9696,25 @@ var Util = function () {
|
|
|
9392
9696
|
};
|
|
9393
9697
|
request.send();
|
|
9394
9698
|
}
|
|
9699
|
+
}, {
|
|
9700
|
+
key: "download",
|
|
9701
|
+
value: function download(space) {
|
|
9702
|
+
var filename = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'pts_canvas_image';
|
|
9703
|
+
var filetype = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "png";
|
|
9704
|
+
var quality = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1;
|
|
9705
|
+
|
|
9706
|
+
var ftype = filetype === 'jpg' ? 'jpeg' : filetype;
|
|
9707
|
+
space.element.toBlob(function (blob) {
|
|
9708
|
+
var link = document.createElement('a');
|
|
9709
|
+
var url = URL.createObjectURL(blob);
|
|
9710
|
+
link.href = url;
|
|
9711
|
+
link.download = filename + "." + filetype;
|
|
9712
|
+
document.body.appendChild(link);
|
|
9713
|
+
link.click();
|
|
9714
|
+
document.body.removeChild(link);
|
|
9715
|
+
URL.revokeObjectURL(url);
|
|
9716
|
+
}, "image/" + ftype, quality);
|
|
9717
|
+
}
|
|
9395
9718
|
}, {
|
|
9396
9719
|
key: "performance",
|
|
9397
9720
|
value: function performance() {
|