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.
@@ -1,4 +1,4 @@
1
- /*! Source code licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
1
+ /*! Pts.js is licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
2
2
  import { MultiTouchSpace } from './Space';
3
3
  import { VisualForm, Font } from "./Form";
4
4
  import { Pt, Group, Bound } from "./Pt";
@@ -88,6 +88,9 @@ export class CanvasSpace extends MultiTouchSpace {
88
88
  else {
89
89
  this._offscreen = false;
90
90
  }
91
+ if (opt.pixelDensity) {
92
+ this._pixelScale = opt.pixelDensity;
93
+ }
91
94
  return this;
92
95
  }
93
96
  set autoResize(auto) {
@@ -104,13 +107,13 @@ export class CanvasSpace extends MultiTouchSpace {
104
107
  get autoResize() { return this._autoResize; }
105
108
  resize(b, evt) {
106
109
  this.bound = b;
107
- this._canvas.width = this.bound.size.x * this._pixelScale;
108
- this._canvas.height = this.bound.size.y * this._pixelScale;
109
- this._canvas.style.width = Math.floor(this.bound.size.x) + "px";
110
- this._canvas.style.height = Math.floor(this.bound.size.y) + "px";
110
+ this._canvas.width = Math.ceil(this.bound.size.x) * this._pixelScale;
111
+ this._canvas.height = Math.ceil(this.bound.size.y) * this._pixelScale;
112
+ this._canvas.style.width = Math.ceil(this.bound.size.x) + "px";
113
+ this._canvas.style.height = Math.ceil(this.bound.size.y) + "px";
111
114
  if (this._offscreen) {
112
- this._offCanvas.width = this.bound.size.x * this._pixelScale;
113
- this._offCanvas.height = this.bound.size.y * this._pixelScale;
115
+ this._offCanvas.width = Math.ceil(this.bound.size.x) * this._pixelScale;
116
+ this._offCanvas.height = Math.ceil(this.bound.size.y) * this._pixelScale;
114
117
  }
115
118
  if (this._pixelScale != 1) {
116
119
  this._ctx.scale(this._pixelScale, this._pixelScale);
@@ -165,27 +168,29 @@ export class CanvasSpace extends MultiTouchSpace {
165
168
  if (bg)
166
169
  this._bgcolor = bg;
167
170
  const lastColor = this._ctx.fillStyle;
171
+ const px = Math.ceil(this.pixelScale);
168
172
  if (!this._bgcolor || this._bgcolor === "transparent") {
169
- this._ctx.clearRect(-1, -1, this._canvas.width + 1, this._canvas.height + 1);
173
+ this._ctx.clearRect(-px, -px, this._canvas.width + px, this._canvas.height + px);
170
174
  }
171
175
  else {
172
176
  if (this._bgcolor.indexOf("rgba") === 0 || (this._bgcolor.length === 9 && this._bgcolor.indexOf("#") === 0)) {
173
- this._ctx.clearRect(-1, -1, this._canvas.width + 1, this._canvas.height + 1);
177
+ this._ctx.clearRect(-px, -px, this._canvas.width + px, this._canvas.height + px);
174
178
  }
175
179
  this._ctx.fillStyle = this._bgcolor;
176
- this._ctx.fillRect(-1, -1, this._canvas.width + 1, this._canvas.height + 1);
180
+ this._ctx.fillRect(-px, -px, this._canvas.width + px, this._canvas.height + px);
177
181
  }
178
182
  this._ctx.fillStyle = lastColor;
179
183
  return this;
180
184
  }
181
185
  clearOffscreen(bg) {
182
186
  if (this._offscreen) {
187
+ const px = Math.ceil(this.pixelScale);
183
188
  if (bg) {
184
189
  this._offCtx.fillStyle = bg;
185
- this._offCtx.fillRect(-1, -1, this._canvas.width + 1, this._canvas.height + 1);
190
+ this._offCtx.fillRect(-px, -px, this._canvas.width + px, this._canvas.height + px);
186
191
  }
187
192
  else {
188
- this._offCtx.clearRect(-1, -1, this._offCanvas.width + 1, this._offCanvas.height + 1);
193
+ this._offCtx.clearRect(-px, -px, this._offCanvas.width + px, this._offCanvas.height + px);
189
194
  }
190
195
  }
191
196
  return this;
@@ -210,9 +215,9 @@ export class CanvasSpace extends MultiTouchSpace {
210
215
  this.removeAll();
211
216
  return this;
212
217
  }
213
- recorder(downloadOrCallback, filetype = "webm") {
218
+ recorder(downloadOrCallback, filetype = "webm", bitrate = 15000000) {
214
219
  let stream = this._canvas.captureStream();
215
- const recorder = new MediaRecorder(stream, { mimeType: `video/${filetype}` });
220
+ const recorder = new MediaRecorder(stream, { mimeType: `video/${filetype}`, bitsPerSecond: bitrate });
216
221
  recorder.ondataavailable = function (d) {
217
222
  let url = URL.createObjectURL(new Blob([d.data], { type: `video/${filetype}` }));
218
223
  if (typeof downloadOrCallback === "function") {
@@ -237,6 +242,8 @@ export class CanvasForm extends VisualForm {
237
242
  lineWidth: 1, lineJoin: "bevel", lineCap: "butt",
238
243
  globalAlpha: 1
239
244
  };
245
+ if (!space)
246
+ return this;
240
247
  const _setup = (ctx) => {
241
248
  this._ctx = ctx;
242
249
  this._ctx.fillStyle = this._style.fillStyle;
@@ -307,6 +314,19 @@ export class CanvasForm extends VisualForm {
307
314
  }
308
315
  return this;
309
316
  }
317
+ applyFillStroke(filled = true, stroked = true, strokeWidth = 1) {
318
+ if (filled) {
319
+ if (typeof filled === 'string')
320
+ this.fill(filled);
321
+ this._ctx.fill();
322
+ }
323
+ if (stroked) {
324
+ if (typeof stroked === 'string')
325
+ this.stroke(stroked, strokeWidth);
326
+ this._ctx.stroke();
327
+ }
328
+ return this;
329
+ }
310
330
  gradient(stops) {
311
331
  let vals = [];
312
332
  if (stops.length < 2)
@@ -1,4 +1,4 @@
1
- /*! Source code licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
1
+ /*! Pts.js is licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
2
2
  import { Pt, Group } from "./Pt";
3
3
  import { Util } from "./Util";
4
4
  import { Num, Geom } from "./Num";
@@ -252,12 +252,12 @@ export class Color extends Pt {
252
252
  static XYZtoRGB(xyz, normalizedInput = false, normalizedOutput = false) {
253
253
  let [x, y, z] = (!normalizedInput) ? xyz.$normalize() : xyz;
254
254
  let rgb = [
255
- x * 3.2404542 + y * -1.5371385 + z * -0.4985314,
256
- x * -0.9692660 + y * 1.8760108 + z * 0.0415560,
257
- x * 0.0556434 + y * -0.2040259 + z * 1.0572252
255
+ x * 3.2406254773200533 + y * -1.5372079722103187 + z * -0.4986285986982479,
256
+ x * -0.9689307147293197 + y * 1.8757560608852415 + z * 0.041517523842953964,
257
+ x * 0.055710120445510616 + y * -0.2040210505984867 + z * 1.0569959422543882
258
258
  ];
259
259
  for (let i = 0; i < 3; i++) {
260
- 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]);
260
+ rgb[i] = (rgb[i] > 0.0031308) ? (1.055 * Math.pow(rgb[i], 1 / 2.4) - 0.055) : (12.92 * rgb[i]);
261
261
  rgb[i] = Math.max(0, Math.min(1, rgb[i]));
262
262
  if (!normalizedOutput)
263
263
  rgb[i] = Math.round(rgb[i] * 255);
@@ -267,8 +267,10 @@ export class Color extends Pt {
267
267
  }
268
268
  static XYZtoLAB(xyz, normalizedInput = false, normalizedOutput = false) {
269
269
  let c = (normalizedInput) ? xyz.$normalize(false) : xyz.clone();
270
+ const eps = 0.00885645167;
271
+ const kap = 903.296296296;
270
272
  c.divide(Color.D65);
271
- let fn = (n) => (n > 0.008856) ? Math.pow(n, 1 / 3) : (7.787 * n) + 16 / 116;
273
+ let fn = (n) => (n > eps) ? Math.pow(n, 1 / 3) : (kap * n + 16) / 116;
272
274
  let cy = fn(c[1]);
273
275
  let cc = Color.lab((116 * cy) - 16, 500 * (fn(c[0]) - cy), 200 * (cy - fn(c[2])), xyz.alpha);
274
276
  return (normalizedOutput) ? cc.normalize() : cc;
@@ -278,12 +280,12 @@ export class Color extends Pt {
278
280
  let y = (c[0] + 16) / 116;
279
281
  let x = (c[1] / 500) + y;
280
282
  let z = y - c[2] / 200;
281
- let fn = (n) => {
282
- let nnn = n * n * n;
283
- return (nnn > 0.008856) ? nnn : (n - 16 / 116) / 7.787;
284
- };
283
+ const eps = 0.00885645167;
284
+ const kap = 903.296296296;
285
285
  let d = Color.D65;
286
- 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);
286
+ const xxx = Math.pow(x, 3);
287
+ const zzz = Math.pow(z, 3);
288
+ 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);
287
289
  return (normalizedOutput) ? cc.normalize() : cc;
288
290
  }
289
291
  static XYZtoLUV(xyz, normalizedInput = false, normalizedOutput = false) {
@@ -1,4 +1,4 @@
1
- /*! Source code licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
1
+ /*! Pts.js is licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
2
2
  import { Pt, Group } from "./Pt";
3
3
  import { Line, Triangle } from "./Op";
4
4
  import { Const, Util } from "./Util";
@@ -8,11 +8,11 @@ export class Create {
8
8
  static distributeRandom(bound, count, dimensions = 2) {
9
9
  let pts = new Group();
10
10
  for (let i = 0; i < count; i++) {
11
- let p = [bound.x + Math.random() * bound.width];
11
+ let p = [bound.x + Num.random() * bound.width];
12
12
  if (dimensions > 1)
13
- p.push(bound.y + Math.random() * bound.height);
13
+ p.push(bound.y + Num.random() * bound.height);
14
14
  if (dimensions > 2)
15
- p.push(bound.z + Math.random() * bound.depth);
15
+ p.push(bound.z + Num.random() * bound.depth);
16
16
  pts.push(new Pt(p));
17
17
  }
18
18
  return pts;
@@ -58,7 +58,7 @@ export class Create {
58
58
  return g;
59
59
  }
60
60
  static noisePts(pts, dx = 0.01, dy = 0.01, rows = 0, columns = 0) {
61
- let seed = Math.random();
61
+ let seed = Num.random();
62
62
  let g = new Group();
63
63
  let i = 0;
64
64
  for (let p of pts) {
@@ -1,4 +1,4 @@
1
- /*! Source code licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
1
+ /*! Pts.js is licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
2
2
  import { MultiTouchSpace } from './Space';
3
3
  import { VisualForm, Font } from "./Form";
4
4
  import { Util } from './Util';
@@ -1,4 +1,4 @@
1
- /*! Source code licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
1
+ /*! Pts.js is licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
2
2
  export class Form {
3
3
  constructor() {
4
4
  this._ready = false;
@@ -88,6 +88,8 @@ export class Img {
88
88
  }
89
89
  filter(css) {
90
90
  this._ctx.filter = css;
91
+ this._ctx.drawImage(this._cv, 0, 0);
92
+ this._ctx.filter = "none";
91
93
  return this;
92
94
  }
93
95
  cleanup() {
@@ -1,4 +1,4 @@
1
- /*! Source code licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
1
+ /*! Pts.js is licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
2
2
  import { Pt, Group } from "./Pt";
3
3
  import { Line } from "./Op";
4
4
  export class Vec {
@@ -1,8 +1,9 @@
1
- /*! Source code licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
1
+ /*! Pts.js is licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
2
2
  import { Const, Util } from "./Util";
3
3
  import { Curve } from "./Op";
4
4
  import { Pt, Group } from "./Pt";
5
5
  import { Vec, Mat } from "./LinearAlgebra";
6
+ import generator from './uheprng';
6
7
  export class Num {
7
8
  static equals(a, b, threshold = 0.00001) {
8
9
  return Math.abs(a - b) < threshold;
@@ -27,14 +28,14 @@ export class Num {
27
28
  }
28
29
  static randomRange(a, b = 0) {
29
30
  let r = (a > b) ? (a - b) : (b - a);
30
- return a + Math.random() * r;
31
+ return a + Num.random() * r;
31
32
  }
32
33
  static randomPt(a, b) {
33
34
  let p = new Pt(a.length);
34
35
  let range = b ? Vec.subtract(b, a) : a;
35
36
  let start = b ? a : new Pt(a.length).fill(0);
36
37
  for (let i = 0, len = p.length; i < len; i++) {
37
- p[i] = Math.random() * range[i] + start[i];
38
+ p[i] = Num.random() * range[i] + start[i];
38
39
  }
39
40
  return p;
40
41
  }
@@ -65,6 +66,14 @@ export class Num {
65
66
  let max = Math.max(targetA, targetB);
66
67
  return Num.normalizeValue(n, currA, currB) * (max - min) + min;
67
68
  }
69
+ static seed(seed) {
70
+ this.generator = generator(seed);
71
+ }
72
+ static random() {
73
+ return this.generator
74
+ ? this.generator.random()
75
+ : Math.random();
76
+ }
68
77
  }
69
78
  export class Geom {
70
79
  static boundAngle(angle) {
package/dist/es2015/Op.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! Source code licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
1
+ /*! Pts.js is licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
2
2
  import { Util } from "./Util";
3
3
  import { Geom, Num } from "./Num";
4
4
  import { Pt, Group } from "./Pt";
@@ -1,4 +1,4 @@
1
- /*! Source code licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
1
+ /*! Pts.js is licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
2
2
  import { Pt, Group, Bound } from "./Pt";
3
3
  import { Polygon, Circle } from "./Op";
4
4
  import { Geom } from "./Num";
package/dist/es2015/Pt.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! Source code licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
1
+ /*! Pts.js is licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
2
2
  import { Util, Const } from "./Util";
3
3
  import { Geom, Num } from "./Num";
4
4
  import { Vec, Mat } from "./LinearAlgebra";
@@ -17,7 +17,7 @@ export class Pt extends Float32Array {
17
17
  p.fill(defaultValue);
18
18
  if (randomize) {
19
19
  for (let i = 0, len = p.length; i < len; i++) {
20
- p[i] = p[i] * Math.random();
20
+ p[i] = p[i] * Num.random();
21
21
  }
22
22
  }
23
23
  return new Pt(p);
@@ -1,4 +1,4 @@
1
- /*! Source code licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
1
+ /*! Pts.js is licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
2
2
  import { Pt, Bound } from "./Pt";
3
3
  import { UIPointerActions as UIA } from "./UI";
4
4
  export class Space {
@@ -91,7 +91,7 @@ export class Space {
91
91
  this._time.end = t;
92
92
  return this;
93
93
  }
94
- playOnce(duration = 5000) {
94
+ playOnce(duration = 0) {
95
95
  this.play();
96
96
  this.stop(duration);
97
97
  return this;
@@ -127,44 +127,50 @@ export class MultiTouchSpace extends Space {
127
127
  bindCanvas(evt, callback, options = {}) {
128
128
  this._canvas.addEventListener(evt, callback, options);
129
129
  }
130
- unbindCanvas(evt, callback) {
131
- this._canvas.removeEventListener(evt, callback);
130
+ unbindCanvas(evt, callback, options = {}) {
131
+ this._canvas.removeEventListener(evt, callback, options);
132
132
  }
133
133
  bindMouse(_bind = true) {
134
134
  if (_bind) {
135
- this.bindCanvas("mousedown", this._mouseDown.bind(this));
136
- this.bindCanvas("mouseup", this._mouseUp.bind(this));
137
- this.bindCanvas("mouseover", this._mouseOver.bind(this));
138
- this.bindCanvas("mouseout", this._mouseOut.bind(this));
139
- this.bindCanvas("mousemove", this._mouseMove.bind(this));
140
- this.bindCanvas("click", this._mouseClick.bind(this));
141
- this.bindCanvas("contextmenu", this._contextMenu.bind(this));
135
+ this._mouseDown = this._mouseDown.bind(this);
136
+ this._mouseUp = this._mouseUp.bind(this);
137
+ this._mouseOver = this._mouseOver.bind(this);
138
+ this._mouseMove = this._mouseMove.bind(this);
139
+ this._mouseClick = this._mouseClick.bind(this);
140
+ this._contextMenu = this._contextMenu.bind(this);
141
+ this.bindCanvas("mousedown", this._mouseDown);
142
+ this.bindCanvas("mouseup", this._mouseUp);
143
+ this.bindCanvas("mouseover", this._mouseOver);
144
+ this.bindCanvas("mouseout", this._mouseOut);
145
+ this.bindCanvas("mousemove", this._mouseMove);
146
+ this.bindCanvas("click", this._mouseClick);
147
+ this.bindCanvas("contextmenu", this._contextMenu);
142
148
  this._hasMouse = true;
143
149
  }
144
150
  else {
145
- this.unbindCanvas("mousedown", this._mouseDown.bind(this));
146
- this.unbindCanvas("mouseup", this._mouseUp.bind(this));
147
- this.unbindCanvas("mouseover", this._mouseOver.bind(this));
148
- this.unbindCanvas("mouseout", this._mouseOut.bind(this));
149
- this.unbindCanvas("mousemove", this._mouseMove.bind(this));
150
- this.unbindCanvas("click", this._mouseClick.bind(this));
151
- this.unbindCanvas("contextmenu", this._contextMenu.bind(this));
151
+ this.unbindCanvas("mousedown", this._mouseDown);
152
+ this.unbindCanvas("mouseup", this._mouseUp);
153
+ this.unbindCanvas("mouseover", this._mouseOver);
154
+ this.unbindCanvas("mouseout", this._mouseOut);
155
+ this.unbindCanvas("mousemove", this._mouseMove);
156
+ this.unbindCanvas("click", this._mouseClick);
157
+ this.unbindCanvas("contextmenu", this._contextMenu);
152
158
  this._hasMouse = false;
153
159
  }
154
160
  return this;
155
161
  }
156
- bindTouch(_bind = true) {
157
- if (_bind) {
158
- this.bindCanvas("touchstart", this._touchStart.bind(this), { passive: true });
162
+ bindTouch(bind = true, passive = false) {
163
+ if (bind) {
164
+ this.bindCanvas("touchstart", this._touchStart.bind(this), { passive: passive });
159
165
  this.bindCanvas("touchend", this._mouseUp.bind(this));
160
- this.bindCanvas("touchmove", this._touchMove.bind(this), { passive: true });
166
+ this.bindCanvas("touchmove", this._touchMove.bind(this), { passive: passive });
161
167
  this.bindCanvas("touchcancel", this._mouseOut.bind(this));
162
168
  this._hasTouch = true;
163
169
  }
164
170
  else {
165
- this.unbindCanvas("touchstart", this._touchStart.bind(this));
171
+ this.unbindCanvas("touchstart", this._touchStart.bind(this), { passive: passive });
166
172
  this.unbindCanvas("touchend", this._mouseUp.bind(this));
167
- this.unbindCanvas("touchmove", this._touchMove.bind(this));
173
+ this.unbindCanvas("touchmove", this._touchMove.bind(this), { passive: passive });
168
174
  this.unbindCanvas("touchcancel", this._mouseOut.bind(this));
169
175
  this._hasTouch = false;
170
176
  }
@@ -1,4 +1,4 @@
1
- /*! Source code licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
1
+ /*! Pts.js is licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
2
2
  import { VisualForm, Font } from "./Form";
3
3
  import { Geom } from './Num';
4
4
  import { Const, Util } from './Util';
@@ -1,3 +1,3 @@
1
- /*! Source code licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
1
+ /*! Pts.js is licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
2
2
  export {};
3
3
  //# sourceMappingURL=Types.js.map
@@ -1,4 +1,4 @@
1
- /*! Source code licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
1
+ /*! Pts.js is licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
2
2
  import { Pt, Bound } from "./Pt";
3
3
  export class Typography {
4
4
  static textWidthEstimator(fn, samples = ["M", "n", "."], distribution = [0.06, 0.8, 0.14]) {
package/dist/es2015/UI.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! Source code licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
1
+ /*! Pts.js is licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
2
2
  import { Pt, Group } from "./Pt";
3
3
  import { Rectangle, Circle, Polygon } from "./Op";
4
4
  export const UIShape = {
@@ -1,4 +1,5 @@
1
- /*! Source code licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
1
+ /*! Pts.js is licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
2
+ import { Num } from "./Num";
2
3
  import { Group } from "./Pt";
3
4
  export const Const = {
4
5
  xy: "xy",
@@ -70,7 +71,7 @@ export class Util {
70
71
  }
71
72
  static randomInt(range, start = 0) {
72
73
  Util.warn("Util.randomInt is deprecated. Please use `Num.randomRange`");
73
- return Math.floor(Math.random() * range) + start;
74
+ return Math.floor(Num.random() * range) + start;
74
75
  }
75
76
  static split(pts, size, stride, loopBack = false, matchSize = true) {
76
77
  let chunks = [];
@@ -14,4 +14,5 @@ export * from "./Typography";
14
14
  export * from "./Physics";
15
15
  export * from "./Play";
16
16
  export * from "./UI";
17
+ export * from "./Image";
17
18
  //# sourceMappingURL=_module.js.map
@@ -0,0 +1,69 @@
1
+ 'use strict';
2
+ function Mash() {
3
+ var n = 0xefc8249d;
4
+ var mash = function (data) {
5
+ if (data) {
6
+ data = data.toString();
7
+ for (var i = 0; i < data.length; i++) {
8
+ n += data.charCodeAt(i);
9
+ var h = 0.02519603282416938 * n;
10
+ n = h >>> 0;
11
+ h -= n;
12
+ h *= n;
13
+ n = h >>> 0;
14
+ h -= n;
15
+ n += h * 0x100000000;
16
+ }
17
+ return (n >>> 0) * 2.3283064365386963e-10;
18
+ }
19
+ else
20
+ n = 0xefc8249d;
21
+ };
22
+ return mash;
23
+ }
24
+ export default function (seed) {
25
+ var o = 48;
26
+ var c = 1;
27
+ var p = o;
28
+ var s = new Array(o);
29
+ var i, j, k = 0;
30
+ var mash = Mash();
31
+ for (i = 0; i < o; i++)
32
+ s[i] = mash(Math.random().toString());
33
+ function initState() {
34
+ mash();
35
+ for (i = 0; i < o; i++)
36
+ s[i] = mash(' ');
37
+ c = 1;
38
+ p = o;
39
+ }
40
+ function cleanString(inStr) {
41
+ inStr = inStr.replace(/(^\s*)|(\s*$)/gi, '');
42
+ inStr = inStr.replace(/[\x00-\x1F]/gi, '');
43
+ inStr = inStr.replace(/\n /, '\n');
44
+ return inStr;
45
+ }
46
+ function hashString(inStr) {
47
+ inStr = cleanString(inStr);
48
+ mash(inStr);
49
+ for (i = 0; i < inStr.length; i++) {
50
+ k = inStr.charCodeAt(i);
51
+ for (j = 0; j < o; j++) {
52
+ s[j] -= mash(k.toString());
53
+ if (s[j] < 0)
54
+ s[j] += 1;
55
+ }
56
+ }
57
+ }
58
+ initState();
59
+ hashString(seed);
60
+ return {
61
+ random() {
62
+ if (++p >= o)
63
+ p = 0;
64
+ var t = 1768863 * s[p] + c * 2.3283064365386963e-10;
65
+ return (s[p] = t - (c = t | 0));
66
+ }
67
+ };
68
+ }
69
+ //# sourceMappingURL=uheprng.js.map