pts 0.10.12 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/dist/{pts.d.ts → index.d.ts} +1245 -1207
  2. package/dist/index.js +6825 -6660
  3. package/dist/index.mjs +6785 -0
  4. package/package.json +12 -33
  5. package/tsup.browser.js +21 -0
  6. package/tsup.min.js +23 -0
  7. package/tsup.module.js +15 -0
  8. package/dist/es2015/Canvas.js +0 -684
  9. package/dist/es2015/Canvas.js.map +0 -1
  10. package/dist/es2015/Color.js +0 -337
  11. package/dist/es2015/Color.js.map +0 -1
  12. package/dist/es2015/Create.js +0 -275
  13. package/dist/es2015/Create.js.map +0 -1
  14. package/dist/es2015/Dom.js +0 -448
  15. package/dist/es2015/Dom.js.map +0 -1
  16. package/dist/es2015/Form.js +0 -80
  17. package/dist/es2015/Form.js.map +0 -1
  18. package/dist/es2015/Image.js +0 -220
  19. package/dist/es2015/Image.js.map +0 -1
  20. package/dist/es2015/LinearAlgebra.js +0 -286
  21. package/dist/es2015/LinearAlgebra.js.map +0 -1
  22. package/dist/es2015/Num.js +0 -477
  23. package/dist/es2015/Num.js.map +0 -1
  24. package/dist/es2015/Op.js +0 -978
  25. package/dist/es2015/Op.js.map +0 -1
  26. package/dist/es2015/Physics.js +0 -383
  27. package/dist/es2015/Physics.js.map +0 -1
  28. package/dist/es2015/Play.js +0 -339
  29. package/dist/es2015/Play.js.map +0 -1
  30. package/dist/es2015/Pt.js +0 -463
  31. package/dist/es2015/Pt.js.map +0 -1
  32. package/dist/es2015/Space.js +0 -331
  33. package/dist/es2015/Space.js.map +0 -1
  34. package/dist/es2015/Svg.js +0 -367
  35. package/dist/es2015/Svg.js.map +0 -1
  36. package/dist/es2015/Types.js +0 -3
  37. package/dist/es2015/Types.js.map +0 -1
  38. package/dist/es2015/Typography.js +0 -40
  39. package/dist/es2015/Typography.js.map +0 -1
  40. package/dist/es2015/UI.js +0 -273
  41. package/dist/es2015/UI.js.map +0 -1
  42. package/dist/es2015/Util.js +0 -200
  43. package/dist/es2015/Util.js.map +0 -1
  44. package/dist/es2015/_lib.js +0 -45
  45. package/dist/es2015/_lib.js.map +0 -1
  46. package/dist/es2015/_module.js +0 -18
  47. package/dist/es2015/_module.js.map +0 -1
  48. package/dist/es2015/uheprng.js +0 -69
  49. package/dist/es2015/uheprng.js.map +0 -1
  50. package/dist/index.js.map +0 -1
@@ -1,1012 +1,1130 @@
1
- // Generated by dts-bundle v0.7.3
1
+ /*! Pts.js is licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
2
2
 
3
- export let namespace: (scope: any) => void;
4
- export let quickStart: (id: string, bg?: string) => (animate?: any, start?: any, action?: any, resize?: any) => void;
5
-
6
- export class CanvasSpace extends MultiTouchSpace {
7
- protected _canvas: HTMLCanvasElement;
8
- protected _container: Element;
9
- protected _pixelScale: number;
10
- protected _autoResize: boolean;
11
- protected _bgcolor: string;
12
- protected _ctx: PtsCanvasRenderingContext2D;
13
- protected _offscreen: boolean;
14
- protected _offCanvas: HTMLCanvasElement;
15
- protected _offCtx: PtsCanvasRenderingContext2D;
16
- protected _initialResize: boolean;
17
- constructor(elem: string | Element, callback?: Function);
18
- protected _createElement(elem: string, id: any): HTMLElement;
19
- setup(opt: CanvasSpaceOptions): this;
20
- set autoResize(auto: boolean);
21
- get autoResize(): boolean;
22
- resize(b: Bound, evt?: Event): this;
23
- protected _resizeHandler(evt: Event): void;
24
- set background(bg: string);
25
- get background(): string;
26
- get pixelScale(): number;
27
- get hasOffscreen(): boolean;
28
- get offscreenCtx(): PtsCanvasRenderingContext2D;
29
- get offscreenCanvas(): HTMLCanvasElement;
30
- getForm(): CanvasForm;
31
- get element(): HTMLCanvasElement;
32
- get parent(): Element;
33
- get ready(): boolean;
34
- get ctx(): PtsCanvasRenderingContext2D;
35
- clear(bg?: string): this;
36
- clearOffscreen(bg?: string): this;
37
- protected playItems(time: number): void;
38
- dispose(): this;
39
- recorder(downloadOrCallback: boolean | ((blobURL: string) => {}), filetype?: string, bitrate?: number): MediaRecorder;
3
+ declare const UIShape: {
4
+ rectangle: string;
5
+ circle: string;
6
+ polygon: string;
7
+ polyline: string;
8
+ line: string;
9
+ };
10
+ declare const UIPointerActions: {
11
+ up: string;
12
+ down: string;
13
+ move: string;
14
+ drag: string;
15
+ uidrag: string;
16
+ drop: string;
17
+ uidrop: string;
18
+ over: string;
19
+ out: string;
20
+ enter: string;
21
+ leave: string;
22
+ click: string;
23
+ keydown: string;
24
+ keyup: string;
25
+ contextmenu: string;
26
+ all: string;
27
+ };
28
+ declare class UI {
29
+ _group: Group;
30
+ _shape: string;
31
+ protected static _counter: number;
32
+ protected _id: string;
33
+ protected _actions: {
34
+ [type: string]: UIHandler[];
35
+ };
36
+ protected _states: {
37
+ [key: string]: any;
38
+ };
39
+ protected _holds: Map<number, string>;
40
+ constructor(group: PtLikeIterable, shape: string, states?: {
41
+ [key: string]: any;
42
+ }, id?: string);
43
+ static fromRectangle(group: PtLikeIterable, states: {}, id?: string): UI;
44
+ static fromCircle(group: PtLikeIterable, states: {}, id?: string): UI;
45
+ static fromPolygon(group: PtLikeIterable, states: {}, id?: string): UI;
46
+ static fromUI(ui: UI, states?: object, id?: string): UI;
47
+ get id(): string;
48
+ set id(d: string);
49
+ get group(): Group;
50
+ set group(d: Group);
51
+ get shape(): string;
52
+ set shape(d: string);
53
+ state(key: string, value?: any): any;
54
+ on(type: string, fn: UIHandler): number;
55
+ off(type: string, which?: number): boolean;
56
+ listen(type: string, p: PtLike, evt: MouseEvent): boolean;
57
+ protected hold(type: string): number;
58
+ protected unhold(key?: number): void;
59
+ static track(uis: UI[], type: string, p: PtLike, evt: MouseEvent): void;
60
+ render(fn: (group: Group, states: {
61
+ [key: string]: any;
62
+ }) => void): void;
63
+ toString(): string;
64
+ protected _within(p: PtLike): boolean;
65
+ protected static _trigger(fns: UIHandler[], target: UI, pt: PtLike, type: string, evt: MouseEvent): void;
66
+ protected static _addHandler(fns: UIHandler[], fn: UIHandler): number;
67
+ protected static _removeHandler(fns: UIHandler[], index: number): boolean;
40
68
  }
41
- export class CanvasForm extends VisualForm {
42
- protected _space: CanvasSpace;
43
- protected _ctx: CanvasRenderingContext2D;
44
- protected _estimateTextWidth: (string: any) => number;
45
- protected _style: DefaultFormStyle;
46
- constructor(space: CanvasSpace | CanvasRenderingContext2D);
47
- get space(): CanvasSpace;
48
- get ctx(): PtsCanvasRenderingContext2D;
49
- useOffscreen(off?: boolean, clear?: boolean | string): this;
50
- renderOffscreen(offset?: PtLike): void;
51
- alpha(a: number): this;
52
- fill(c: string | boolean | CanvasGradient | CanvasPattern): this;
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;
55
- gradient(stops: [number, string][] | string[]): ((area1: GroupLike, area2?: GroupLike) => CanvasGradient);
56
- composite(mode?: string): this;
57
- clip(): this;
58
- dash(segments?: PtLike | boolean, offset?: number): this;
59
- font(sizeOrFont: number | Font, weight?: string, style?: string, lineHeight?: number, family?: string): this;
60
- fontWidthEstimate(estimate?: boolean): this;
61
- getTextWidth(c: string): number;
62
- protected _textTruncate(str: string, width: number, tail?: string): [string, number];
63
- protected _textAlign(box: PtLikeIterable, vertical: string, offset?: PtLike, center?: Pt): Pt;
64
- reset(): this;
65
- protected _paint(): void;
66
- static point(ctx: CanvasRenderingContext2D, p: PtLike, radius?: number, shape?: string): void;
67
- point(p: PtLike, radius?: number, shape?: string): this;
68
- static circle(ctx: CanvasRenderingContext2D, pt: PtLike, radius?: number): void;
69
- circle(pts: PtLikeIterable): this;
70
- static ellipse(ctx: CanvasRenderingContext2D, pt: PtLike, radius: PtLike, rotation?: number, startAngle?: number, endAngle?: number, cc?: boolean): void;
71
- ellipse(pt: PtLike, radius: PtLike, rotation?: number, startAngle?: number, endAngle?: number, cc?: boolean): this;
72
- static arc(ctx: CanvasRenderingContext2D, pt: PtLike, radius: number, startAngle: number, endAngle: number, cc?: boolean): void;
73
- arc(pt: PtLike, radius: number, startAngle: number, endAngle: number, cc?: boolean): this;
74
- static square(ctx: CanvasRenderingContext2D, pt: PtLike, halfsize: number): void;
75
- square(pt: PtLike, halfsize: number): this;
76
- static line(ctx: CanvasRenderingContext2D, pts: PtLikeIterable): void;
77
- line(pts: PtLikeIterable): this;
78
- static polygon(ctx: CanvasRenderingContext2D, pts: PtLikeIterable): void;
79
- polygon(pts: PtLikeIterable): this;
80
- static rect(ctx: CanvasRenderingContext2D, pts: PtLikeIterable): void;
81
- rect(pts: PtLikeIterable): this;
82
- static image(ctx: CanvasRenderingContext2D, ptOrRect: PtLike | PtLikeIterable, img: CanvasImageSource | Img, orig?: PtLikeIterable): void;
83
- image(ptOrRect: PtLike | PtLikeIterable, img: CanvasImageSource | Img, orig?: PtLikeIterable): this;
84
- static imageData(ctx: CanvasRenderingContext2D, ptOrRect: PtLike | PtLikeIterable, img: ImageData): void;
85
- imageData(ptOrRect: PtLike | PtLikeIterable, img: ImageData): this;
86
- static text(ctx: CanvasRenderingContext2D, pt: PtLike, txt: string, maxWidth?: number): void;
87
- text(pt: PtLike, txt: string, maxWidth?: number): this;
88
- textBox(box: PtIterable, txt: string, verticalAlign?: string, tail?: string, overrideBaseline?: boolean): this;
89
- paragraphBox(box: PtLikeIterable, txt: string, lineHeight?: number, verticalAlign?: string, crop?: boolean): this;
90
- alignText(alignment?: CanvasTextAlign, baseline?: CanvasTextBaseline): this;
91
- log(txt: any): this;
69
+ declare class UIButton extends UI {
70
+ private _hoverID;
71
+ constructor(group: PtLikeIterable, shape: string, states?: {
72
+ [key: string]: any;
73
+ }, id?: string);
74
+ onClick(fn: UIHandler): number;
75
+ offClick(id: number): boolean;
76
+ onContextMenu(fn: UIHandler): number;
77
+ offContextMenu(id: number): boolean;
78
+ onHover(enter?: UIHandler, leave?: UIHandler): number[];
79
+ offHover(enterID?: number, leaveID?: number): boolean[];
92
80
  }
93
-
94
- export class Color extends Pt {
95
- protected _mode: ColorType;
96
- static ranges: {
97
- [name: string]: Group;
98
- };
99
- constructor(...args: any[]);
100
- static from(...args: any[]): Color;
101
- static fromHex(hex: string): Color;
102
- static rgb(...args: any[]): Color;
103
- static hsl(...args: any[]): Color;
104
- static hsb(...args: any[]): Color;
105
- static lab(...args: any[]): Color;
106
- static lch(...args: any[]): Color;
107
- static luv(...args: any[]): Color;
108
- static xyz(...args: any[]): Color;
109
- static maxValues(mode: string): Pt;
110
- get hex(): string;
111
- get rgb(): string;
112
- get rgba(): string;
113
- clone(): Color;
114
- toMode(mode: ColorType, convert?: boolean): this;
115
- get mode(): ColorType;
116
- get r(): number;
117
- set r(n: number);
118
- get g(): number;
119
- set g(n: number);
120
- get b(): number;
121
- set b(n: number);
122
- get h(): number;
123
- set h(n: number);
124
- get s(): number;
125
- set s(n: number);
126
- get l(): number;
127
- set l(n: number);
128
- get a(): number;
129
- set a(n: number);
130
- get c(): number;
131
- set c(n: number);
132
- get u(): number;
133
- set u(n: number);
134
- get v(): number;
135
- set v(n: number);
136
- set alpha(n: number);
137
- get alpha(): number;
138
- get normalized(): boolean;
139
- set normalized(b: boolean);
140
- normalize(toNorm?: boolean): Color;
141
- $normalize(toNorm?: boolean): Color;
142
- toString(format?: ("hex" | "rgb" | "rgba" | "mode")): string;
143
- static RGBtoHSL(rgb: Color, normalizedInput?: boolean, normalizedOutput?: boolean): Color;
144
- static HSLtoRGB(hsl: Color, normalizedInput?: boolean, normalizedOutput?: boolean): Color;
145
- static RGBtoHSB(rgb: Color, normalizedInput?: boolean, normalizedOutput?: boolean): Color;
146
- static HSBtoRGB(hsb: Color, normalizedInput?: boolean, normalizedOutput?: boolean): Color;
147
- static RGBtoLAB(rgb: Color, normalizedInput?: boolean, normalizedOutput?: boolean): Color;
148
- static LABtoRGB(lab: Color, normalizedInput?: boolean, normalizedOutput?: boolean): Color;
149
- static RGBtoLCH(rgb: Color, normalizedInput?: boolean, normalizedOutput?: boolean): Color;
150
- static LCHtoRGB(lch: Color, normalizedInput?: boolean, normalizedOutput?: boolean): Color;
151
- static RGBtoLUV(rgb: Color, normalizedInput?: boolean, normalizedOutput?: boolean): Color;
152
- static LUVtoRGB(luv: Color, normalizedInput?: boolean, normalizedOutput?: boolean): Color;
153
- static RGBtoXYZ(rgb: Color, normalizedInput?: boolean, normalizedOutput?: boolean): Color;
154
- static XYZtoRGB(xyz: Color, normalizedInput?: boolean, normalizedOutput?: boolean): Color;
155
- static XYZtoLAB(xyz: Color, normalizedInput?: boolean, normalizedOutput?: boolean): Color;
156
- static LABtoXYZ(lab: Color, normalizedInput?: boolean, normalizedOutput?: boolean): Color;
157
- static XYZtoLUV(xyz: Color, normalizedInput?: boolean, normalizedOutput?: boolean): Color;
158
- static LUVtoXYZ(luv: Color, normalizedInput?: boolean, normalizedOutput?: boolean): Color;
159
- static LABtoLCH(lab: Color, normalizedInput?: boolean, normalizedOutput?: boolean): Color;
160
- static LCHtoLAB(lch: Color, normalizedInput?: boolean, normalizedOutput?: boolean): Color;
81
+ declare class UIDragger extends UIButton {
82
+ private _draggingID;
83
+ private _moveHoldID;
84
+ private _dropHoldID;
85
+ private _upHoldID;
86
+ constructor(group: PtLikeIterable, shape: string, states?: {
87
+ [key: string]: any;
88
+ }, id?: string);
89
+ onDrag(fn: UIHandler): number;
90
+ offDrag(id: number): boolean;
91
+ onDrop(fn: UIHandler): number;
92
+ offDrop(id: number): boolean;
161
93
  }
162
94
 
163
- export class Create {
164
- static distributeRandom(bound: Bound, count: number, dimensions?: number): Group;
165
- static distributeLinear(line: PtIterable, count: number): Group;
166
- static gridPts(bound: Bound, columns: number, rows: number, orientation?: PtLike): Group;
167
- static gridCells(bound: Bound, columns: number, rows: number): Group[];
168
- static radialPts(center: PtLike, radius: number, count: number, angleOffset?: number): Group;
169
- static noisePts(pts: PtIterable, dx?: number, dy?: number, rows?: number, columns?: number): Group;
170
- static delaunay(pts: GroupLike): Delaunay;
95
+ /*! Pts.js is licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
96
+
97
+ interface IPt {
98
+ x?: number;
99
+ y?: number;
100
+ z?: number;
101
+ w?: number;
171
102
  }
172
- export class Noise extends Pt {
173
- protected perm: number[];
174
- constructor(...args: any[]);
175
- initNoise(...args: any[]): this;
176
- step(x?: number, y?: number): this;
177
- seed(s: any): this;
178
- noise2D(): number;
103
+ declare type PtLike = Pt | Float32Array | number[];
104
+ declare type GroupLike = Group | Pt[];
105
+ declare type PtIterable = GroupLike | Pt[] | Iterable<Pt>;
106
+ declare type PtLikeIterable = GroupLike | PtLike[] | Iterable<PtLike>;
107
+ declare type AnimateCallbackFn = (time?: number, frameTime?: number, currentSpace?: any) => void;
108
+ interface IPlayer {
109
+ animateID?: string;
110
+ animate?: AnimateCallbackFn;
111
+ resize?(bound: Bound, evt?: Event): void;
112
+ action?(type: string, px: number, py: number, evt: Event): void;
113
+ start?(bound: Bound, space: Space): void;
179
114
  }
180
- export class Delaunay extends Group {
181
- delaunay(triangleOnly?: boolean): GroupLike[] | DelaunayShape[];
182
- voronoi(): Group[];
183
- mesh(): DelaunayMesh;
184
- neighborPts(i: number, sort?: boolean): GroupLike;
185
- neighbors(i: number): DelaunayShape[];
186
- protected _cache(o: any): void;
187
- protected _superTriangle(): Group;
188
- protected _triangle(i: number, j: number, k: number, pts?: GroupLike): Group;
189
- protected _circum(i: number, j: number, k: number, tri: GroupLike | false, pts?: GroupLike): DelaunayShape;
190
- protected static _dedupe(edges: number[]): number[];
191
- }
192
-
193
- export class DOMSpace extends MultiTouchSpace {
194
- protected _canvas: HTMLElement | SVGElement;
195
- protected _container: Element;
196
- id: string;
197
- protected _autoResize: boolean;
198
- protected _bgcolor: string;
199
- protected _css: {};
200
- constructor(elem: string | Element, callback?: Function);
201
- static createElement(elem: string, id: string, appendTo?: Element): Element;
202
- setup(opt: {
203
- bgcolor?: string;
204
- resize?: boolean;
205
- }): this;
206
- getForm(): Form;
207
- set autoResize(auto: boolean);
208
- get autoResize(): boolean;
209
- resize(b: Bound, evt?: Event): this;
210
- protected _resizeHandler(evt: Event): void;
211
- get element(): Element;
212
- get parent(): Element;
213
- get ready(): boolean;
214
- clear(bg?: string): this;
215
- set background(bg: string);
216
- get background(): string;
217
- style(key: string, val: string, update?: boolean): this;
218
- styles(styles: object, update?: boolean): this;
219
- static setAttr(elem: Element, data: object): Element;
220
- static getInlineStyles(data: object): string;
221
- dispose(): this;
222
- }
223
- export class HTMLSpace extends DOMSpace {
224
- getForm(): Form;
225
- static htmlElement(parent: Element, name: string, id?: string, autoClass?: boolean): HTMLElement;
226
- remove(player: IPlayer): this;
227
- removeAll(): this;
228
- }
229
- export class HTMLForm extends VisualForm {
230
- protected _style: {
231
- filled: boolean;
232
- stroked: boolean;
233
- background: string;
234
- "border-color": string;
235
- color: string;
236
- "border-width": string;
237
- "border-radius": string;
238
- "border-style": string;
239
- opacity: number;
240
- position: string;
241
- top: number;
242
- left: number;
243
- width: number;
244
- height: number;
245
- };
246
- protected _ctx: DOMFormContext;
247
- static groupID: number;
248
- static domID: number;
249
- protected _space: HTMLSpace;
250
- protected _ready: boolean;
251
- constructor(space: HTMLSpace);
252
- get space(): HTMLSpace;
253
- protected styleTo(k: any, v: any, unit?: string): void;
254
- alpha(a: number): this;
255
- fill(c: string | boolean): this;
256
- stroke(c: string | boolean, width?: number, linejoin?: string, linecap?: string): this;
257
- fillText(c: string): this;
258
- cls(c: string | boolean): this;
259
- font(sizeOrFont: number | Font, weight?: string, style?: string, lineHeight?: number, family?: string): this;
260
- reset(): this;
261
- updateScope(group_id: string, group?: Element): object;
262
- scope(item: IPlayer): object;
263
- nextID(): string;
264
- static getID(ctx: any): string;
265
- static scopeID(item: IPlayer): string;
266
- static style(elem: Element, styles: object): Element;
267
- static rectStyle(ctx: DOMFormContext, pt: PtLike, size: PtLike): DOMFormContext;
268
- static textStyle(ctx: DOMFormContext, pt: PtLike): DOMFormContext;
269
- static point(ctx: DOMFormContext, pt: PtLike, radius?: number, shape?: string): Element;
270
- point(pt: PtLike, radius?: number, shape?: string): this;
271
- static circle(ctx: DOMFormContext, pt: PtLike, radius?: number): Element;
272
- circle(pts: GroupLike | number[][]): this;
273
- static square(ctx: DOMFormContext, pt: PtLike, halfsize: number): HTMLElement;
274
- square(pt: PtLike, halfsize: number): this;
275
- static rect(ctx: DOMFormContext, pts: PtLikeIterable): Element;
276
- rect(pts: PtLikeIterable): this;
277
- static text(ctx: DOMFormContext, pt: PtLike, txt: string): Element;
278
- text(pt: PtLike, txt: string): this;
279
- log(txt: any): this;
280
- arc(pt: PtLike, radius: number, startAngle: number, endAngle: number, cc?: boolean): this;
281
- line(pts: GroupLike | number[][]): this;
282
- polygon(pts: GroupLike | number[][]): this;
115
+ interface ISpacePlayers {
116
+ [key: string]: IPlayer;
283
117
  }
284
-
285
- export abstract class Form {
286
- protected _ready: boolean;
287
- get ready(): boolean;
118
+ interface ITimer {
119
+ prev: number;
120
+ diff: number;
121
+ end: number;
122
+ min: number;
288
123
  }
289
- export abstract class VisualForm extends Form {
290
- protected _filled: boolean;
291
- protected _stroked: boolean;
292
- protected _font: Font;
293
- get filled(): boolean;
294
- set filled(b: boolean);
295
- get stroked(): boolean;
296
- set stroked(b: boolean);
297
- get currentFont(): Font;
298
- protected _multiple(groups: GroupLike[], shape: string, ...rest: any[]): this;
299
- abstract reset(): this;
300
- alpha(a: number): this;
301
- fill(c: string | boolean): this;
302
- fillOnly(c: string | boolean): this;
303
- stroke(c: string | boolean, width?: number, linejoin?: string, linecap?: string): this;
304
- strokeOnly(c: string | boolean, width?: number, linejoin?: string, linecap?: string): this;
305
- abstract point(p: PtLike, radius: number, shape: string): this;
306
- points(pts: GroupLike | number[][], radius: number, shape: string): this;
307
- abstract circle(pts: GroupLike | number[][]): this;
308
- circles(groups: GroupLike[]): this;
309
- squares(groups: GroupLike[]): this;
310
- abstract arc(pt: PtLike, radius: number, startAngle: number, endAngle: number, cc?: boolean): this;
311
- abstract line(pts: GroupLike | number[][]): this;
312
- lines(groups: GroupLike[]): this;
313
- abstract polygon(pts: GroupLike | number[][]): this;
314
- polygons(groups: GroupLike[]): this;
315
- abstract rect(pts: number[][] | Pt[]): this;
316
- rects(groups: GroupLike[]): this;
317
- abstract text(pt: PtLike, txt: string, maxWidth?: number): this;
318
- abstract font(sizeOrFont: number | Font, weight?: string, style?: string, lineHeight?: number, family?: string): this;
124
+ declare type TouchPointsKey = "touches" | "changedTouches" | "targetTouches";
125
+ interface PtsCanvasRenderingContext2D extends CanvasRenderingContext2D {
126
+ webkitBackingStorePixelRatio?: number;
127
+ mozBackingStorePixelRatio?: number;
128
+ msBackingStorePixelRatio?: number;
129
+ oBackingStorePixelRatio?: number;
130
+ backingStorePixelRatio?: number;
319
131
  }
320
- export class Font {
132
+ declare type CanvasSpaceOptions = {
133
+ bgcolor?: string;
134
+ resize?: boolean;
135
+ retina?: boolean;
136
+ offscreen?: boolean;
137
+ pixelDensity?: number;
138
+ };
139
+ declare type ColorType = "rgb" | "hsl" | "hsb" | "lab" | "lch" | "luv" | "xyz";
140
+ declare type DelaunayShape = {
141
+ i: number;
142
+ j: number;
143
+ k: number;
144
+ triangle: GroupLike;
145
+ circle: Group;
146
+ };
147
+ declare type DelaunayMesh = {
148
+ [key: string]: DelaunayShape;
149
+ }[];
150
+ declare type DOMFormContext = {
151
+ group: Element;
152
+ groupID: string;
153
+ groupCount: number;
154
+ currentID: string;
155
+ currentClass?: string;
156
+ style: object;
157
+ };
158
+ declare type IntersectContext = {
159
+ which: number;
160
+ dist: number;
161
+ normal: Pt;
162
+ vertex: Pt;
163
+ edge: Group;
164
+ other?: any;
165
+ };
166
+ declare type UIHandler = (target: UI, pt: PtLike, type: string, evt: MouseEvent) => void;
167
+ declare type WarningType = "error" | "warn" | "mute";
168
+ declare type ITempoStartFn = (count: number) => void | boolean;
169
+ declare type ITempoProgressFn = (count: number, t: number, ms: number, start: boolean) => void | boolean;
170
+ declare type ITempoListener = {
171
+ name?: string;
172
+ beats?: number | number[];
173
+ period?: number;
174
+ duration?: number;
175
+ offset?: number;
176
+ continuous?: boolean;
177
+ index?: number;
178
+ fn: Function;
179
+ };
180
+ declare type ITempoResponses = {
181
+ start: (fn: ITempoStartFn, offset: number, name?: string) => string;
182
+ progress: (fn: ITempoProgressFn, offset: number, name?: string) => string;
183
+ };
184
+ declare type ISoundAnalyzer = {
185
+ node: AnalyserNode;
321
186
  size: number;
322
- lineHeight: number;
323
- face: string;
324
- style: string;
325
- weight: string;
326
- constructor(size?: number, face?: string, weight?: string, style?: string, lineHeight?: number);
327
- get value(): string;
328
- toString(): string;
329
- }
187
+ data: Uint8Array;
188
+ };
189
+ declare type SoundType = "file" | "gen" | "input";
190
+ declare type DefaultFormStyle = {
191
+ fillStyle?: string | CanvasGradient | CanvasPattern;
192
+ strokeStyle?: string | CanvasGradient | CanvasPattern;
193
+ lineWidth?: number;
194
+ lineJoin?: string;
195
+ lineCap?: string;
196
+ globalAlpha?: number;
197
+ };
198
+ declare type CanvasPatternRepetition = "repeat" | "repeat-x" | "repeat-y" | "no-repeat";
330
199
 
331
- export class Img {
332
- protected _img: HTMLImageElement;
333
- protected _data: ImageData;
334
- protected _cv: HTMLCanvasElement;
335
- protected _ctx: CanvasRenderingContext2D;
336
- protected _scale: number;
337
- protected _loaded: boolean;
338
- protected _editable: boolean;
339
- protected _space: CanvasSpace;
340
- constructor(editable?: boolean, space?: CanvasSpace, crossOrigin?: boolean);
341
- static load(src: string, editable?: boolean, space?: CanvasSpace, ready?: (img: any) => {}): Img;
342
- static loadAsync(src: string, editable?: boolean, space?: CanvasSpace): Promise<Img>;
343
- static loadPattern(src: string, space: CanvasSpace, repeat?: CanvasPatternRepetition, editable?: boolean): Promise<CanvasPattern>;
344
- static blank(size: PtLike, space: CanvasSpace, scale?: number): Img;
345
- load(src: string): Promise<Img>;
346
- protected _drawToScale(canvasScale: number | PtLike, img: CanvasImageSource): void;
347
- initCanvas(width: number, height: number, canvasScale?: number | PtLike): void;
348
- bitmap(size?: PtLike): Promise<ImageBitmap>;
349
- pattern(reptition?: CanvasPatternRepetition, dynamic?: boolean): CanvasPattern;
350
- sync(): void;
351
- pixel(p: PtLike, rescale?: boolean | number): Pt;
352
- static getPixel(imgData: ImageData, p: PtLike): Pt;
353
- resize(sizeOrScale: PtLike, asScale?: boolean): this;
354
- crop(box: Bound): ImageData;
355
- filter(css: string): this;
356
- cleanup(): void;
357
- static fromBlob(blob: Blob, editable?: boolean, space?: CanvasSpace): Promise<Img>;
358
- static imageDataToBlob(data: ImageData): Promise<Blob>;
359
- toBase64(): string;
360
- toBlob(): Promise<Blob>;
361
- getForm(): CanvasForm;
362
- get current(): CanvasImageSource;
363
- get image(): HTMLImageElement;
364
- get canvas(): HTMLCanvasElement;
365
- get data(): ImageData;
366
- get ctx(): CanvasRenderingContext2D;
367
- get loaded(): boolean;
368
- get pixelScale(): number;
369
- get imageSize(): Pt;
370
- get canvasSize(): Pt;
371
- get scaledMatrix(): Mat;
372
- }
200
+ /*! Pts.js is licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
373
201
 
374
- export class Vec {
375
- static add(a: PtLike, b: PtLike | number): PtLike;
376
- static subtract(a: PtLike, b: PtLike | number): PtLike;
377
- static multiply(a: PtLike, b: PtLike | number): PtLike;
378
- static divide(a: PtLike, b: PtLike | number): PtLike;
379
- static dot(a: PtLike, b: PtLike): number;
380
- static cross2D(a: PtLike, b: PtLike): number;
381
- static cross(a: PtLike, b: PtLike): Pt;
382
- static magnitude(a: PtLike): number;
383
- static unit(a: PtLike, magnitude?: number): PtLike;
384
- static abs(a: PtLike): PtLike;
385
- static floor(a: PtLike): PtLike;
386
- static ceil(a: PtLike): PtLike;
387
- static round(a: PtLike): PtLike;
388
- static max(a: PtLike): {
389
- value: any;
390
- index: any;
391
- };
392
- static min(a: PtLike): {
393
- value: any;
394
- index: any;
395
- };
396
- static sum(a: PtLike): number;
397
- static map(a: PtLike, fn: (n: number, index: number, arr: any) => number): PtLike;
398
- }
399
- export class Mat {
400
- protected _33: GroupLike;
401
- constructor();
402
- get value(): GroupLike;
403
- get domMatrix(): DOMMatrix;
404
- reset(): void;
405
- scale2D(val: PtLike, at?: PtLike): this;
406
- rotate2D(ang: number, at?: PtLike): this;
407
- translate2D(val: PtLike): this;
408
- shear2D(val: PtLike, at?: PtLike): this;
409
- static add(a: GroupLike, b: GroupLike | number[][] | number): Group;
410
- static multiply(a: GroupLike, b: GroupLike | number[][] | number, transposed?: boolean, elementwise?: boolean): Group;
411
- static zipSlice(g: GroupLike | number[][], index: number, defaultValue?: number | boolean): Pt;
412
- static zip(g: GroupLike | number[][], defaultValue?: number | boolean, useLongest?: boolean): Group;
413
- static transpose(g: GroupLike | number[][], defaultValue?: number | boolean, useLongest?: boolean): Group;
414
- static toDOMMatrix(m: GroupLike | number[][]): number[];
415
- static transform2D(pt: PtLike, m: GroupLike | number[][]): Pt;
416
- static scale2DMatrix(x: number, y: number): GroupLike;
417
- static rotate2DMatrix(cosA: number, sinA: number): GroupLike;
418
- static shear2DMatrix(tanX: number, tanY: number): GroupLike;
419
- static translate2DMatrix(x: number, y: number): GroupLike;
420
- static scaleAt2DMatrix(sx: number, sy: number, at: PtLike): GroupLike;
421
- static rotateAt2DMatrix(cosA: number, sinA: number, at: PtLike): GroupLike;
422
- static shearAt2DMatrix(tanX: number, tanY: number, at: PtLike): GroupLike;
423
- static reflectAt2DMatrix(p1: PtLike, p2: PtLike): Pt[];
424
- }
425
-
426
- export class Num {
427
- static generator: any;
428
- static equals(a: number, b: number, threshold?: number): boolean;
429
- static lerp(a: number, b: number, t: number): number;
430
- static clamp(val: number, min: number, max: number): number;
431
- static boundValue(val: number, min: number, max: number): number;
432
- static within(p: number, a: number, b: number): boolean;
433
- static randomRange(a: number, b?: number): number;
434
- static randomPt(a: PtLike, b?: PtLike): Pt;
435
- static normalizeValue(n: number, a: number, b: number): number;
436
- static sum(pts: PtLikeIterable): Pt;
437
- static average(pts: PtLikeIterable): Pt;
438
- static cycle(t: number, method?: (t: number) => number): number;
439
- static mapToRange(n: number, currA: number, currB: number, targetA: number, targetB: number): number;
440
- static seed(seed: string): void;
441
- static random(): number;
442
- }
443
- export class Geom {
444
- static boundAngle(angle: number): number;
445
- static boundRadian(radian: number): number;
446
- static toRadian(angle: number): number;
447
- static toDegree(radian: number): number;
448
- static boundingBox(pts: PtIterable): Group;
449
- static centroid(pts: PtLikeIterable): Pt;
450
- static anchor(pts: PtLikeIterable, ptOrIndex?: PtLike | number, direction?: ("to" | "from")): void;
451
- static interpolate(a: PtLike, b: PtLike, t?: number): Pt;
452
- static perpendicular(pt: PtLike, axis?: string | PtLike): Group;
453
- static isPerpendicular(p1: PtLike, p2: PtLike): boolean;
454
- static withinBound(pt: PtLike, boundPt1: PtLike, boundPt2: PtLike): boolean;
455
- static sortEdges(pts: PtIterable): GroupLike;
456
- static scale(ps: Pt | PtIterable, scale: number | PtLike, anchor?: PtLike): Geom;
457
- static rotate2D(ps: Pt | PtIterable, angle: number, anchor?: PtLike, axis?: string | PtLike): Geom;
458
- static shear2D(ps: Pt | PtIterable, scale: number | PtLike, anchor?: PtLike, axis?: string | PtLike): Geom;
459
- static reflect2D(ps: Pt | PtIterable, line: PtLikeIterable, axis?: string | PtLike): Geom;
460
- static cosTable(): {
461
- table: Float64Array;
462
- cos: (rad: number) => number;
202
+ declare class Pt extends Float32Array implements IPt, Iterable<number> {
203
+ protected _id: string;
204
+ constructor(...args: any[]);
205
+ static make(dimensions: number, defaultValue?: number, randomize?: boolean): Pt;
206
+ get id(): string;
207
+ set id(s: string);
208
+ get x(): number;
209
+ set x(n: number);
210
+ get y(): number;
211
+ set y(n: number);
212
+ get z(): number;
213
+ set z(n: number);
214
+ get w(): number;
215
+ set w(n: number);
216
+ clone(): Pt;
217
+ equals(p: PtLike, threshold?: number): boolean;
218
+ to(...args: any[]): this;
219
+ $to(...args: any[]): Pt;
220
+ toAngle(radian: number, magnitude?: number, anchorFromPt?: boolean): this;
221
+ op(fn: (p1: PtLike, ...rest: any[]) => any): (...rest: any[]) => any;
222
+ ops(fns: ((p1: PtLike, ...rest: any[]) => any)[]): ((...rest: any[]) => any)[];
223
+ $take(axis: string | number[]): Pt;
224
+ $concat(...args: any[]): Pt;
225
+ add(...args: any[]): this;
226
+ $add(...args: any[]): Pt;
227
+ subtract(...args: any[]): this;
228
+ $subtract(...args: any[]): Pt;
229
+ multiply(...args: any[]): this;
230
+ $multiply(...args: any[]): Pt;
231
+ divide(...args: any[]): this;
232
+ $divide(...args: any[]): Pt;
233
+ magnitudeSq(): number;
234
+ magnitude(): number;
235
+ unit(magnitude?: number): Pt;
236
+ $unit(magnitude?: number): Pt;
237
+ dot(...args: any[]): number;
238
+ $cross2D(...args: any[]): number;
239
+ $cross(...args: any[]): Pt;
240
+ $project(...args: any[]): Pt;
241
+ projectScalar(...args: any[]): number;
242
+ abs(): Pt;
243
+ $abs(): Pt;
244
+ floor(): Pt;
245
+ $floor(): Pt;
246
+ ceil(): Pt;
247
+ $ceil(): Pt;
248
+ round(): Pt;
249
+ $round(): Pt;
250
+ minValue(): {
251
+ value: number;
252
+ index: number;
463
253
  };
464
- static sinTable(): {
465
- table: Float64Array;
466
- sin: (rad: number) => number;
254
+ maxValue(): {
255
+ value: number;
256
+ index: number;
467
257
  };
258
+ $min(...args: any[]): Pt;
259
+ $max(...args: any[]): Pt;
260
+ angle(axis?: string | number[]): number;
261
+ angleBetween(p: Pt, axis?: string | number[]): number;
262
+ scale(scale: number | number[] | PtLike, anchor?: PtLike): this;
263
+ rotate2D(angle: number, anchor?: PtLike, axis?: string): this;
264
+ shear2D(scale: number | number[] | PtLike, anchor?: PtLike, axis?: string): this;
265
+ reflect2D(line: GroupLike, axis?: string): this;
266
+ toString(): string;
267
+ toArray(): number[];
268
+ toGroup(): Group;
269
+ toBound(): Bound;
468
270
  }
469
- export class Shaping {
470
- static linear(t: number, c?: number): number;
471
- static quadraticIn(t: number, c?: number): number;
472
- static quadraticOut(t: number, c?: number): number;
473
- static quadraticInOut(t: number, c?: number): number;
474
- static cubicIn(t: number, c?: number): number;
475
- static cubicOut(t: number, c?: number): number;
476
- static cubicInOut(t: number, c?: number): number;
477
- static exponentialIn(t: number, c?: number, p?: number): number;
478
- static exponentialOut(t: number, c?: number, p?: number): number;
479
- static sineIn(t: number, c?: number): number;
480
- static sineOut(t: number, c?: number): number;
481
- static sineInOut(t: number, c?: number): number;
482
- static cosineApprox(t: number, c?: number): number;
483
- static circularIn(t: number, c?: number): number;
484
- static circularOut(t: number, c?: number): number;
485
- static circularInOut(t: number, c?: number): number;
486
- static elasticIn(t: number, c?: number, p?: number): number;
487
- static elasticOut(t: number, c?: number, p?: number): number;
488
- static elasticInOut(t: number, c?: number, p?: number): number;
489
- static bounceIn(t: number, c?: number): number;
490
- static bounceOut(t: number, c?: number): number;
491
- static bounceInOut(t: number, c?: number): number;
492
- static sigmoid(t: number, c?: number, p?: number): number;
493
- static logSigmoid(t: number, c?: number, p?: number): number;
494
- static seat(t: number, c?: number, p?: number): number;
495
- static quadraticBezier(t: number, c?: number, p?: number | PtLike): number;
496
- static cubicBezier(t: number, c?: number, p1?: PtLike, p2?: PtLike): number;
497
- static quadraticTarget(t: number, c?: number, p1?: PtLike): number;
498
- static cliff(t: number, c?: number, p?: number): number;
499
- static step(fn: Function, steps: number, t: number, c: number, ...args: any[]): any;
271
+ declare class Group extends Array<Pt> {
272
+ protected _id: string;
273
+ constructor(...args: Pt[]);
274
+ get id(): string;
275
+ set id(s: string);
276
+ get p1(): Pt;
277
+ get p2(): Pt;
278
+ get p3(): Pt;
279
+ get p4(): Pt;
280
+ get q1(): Pt;
281
+ get q2(): Pt;
282
+ get q3(): Pt;
283
+ get q4(): Pt;
284
+ clone(): Group;
285
+ static fromArray(list: PtLikeIterable): Group;
286
+ static fromPtArray(list: PtIterable): Group;
287
+ split(chunkSize: number, stride?: number, loopBack?: boolean): Group[];
288
+ insert(pts: PtIterable, index?: number): this;
289
+ remove(index?: number, count?: number): Group;
290
+ segments(pts_per_segment?: number, stride?: number, loopBack?: boolean): Group[];
291
+ lines(): Group[];
292
+ centroid(): Pt;
293
+ boundingBox(): Group;
294
+ anchorTo(ptOrIndex?: PtLike | number): void;
295
+ anchorFrom(ptOrIndex?: PtLike | number): void;
296
+ op(fn: (g1: PtIterable, ...rest: any[]) => any): (...rest: any[]) => any;
297
+ ops(fns: ((g1: PtIterable, ...rest: any[]) => any)[]): ((...rest: any[]) => any)[];
298
+ interpolate(t: number): Pt;
299
+ moveBy(...args: any[]): this;
300
+ moveTo(...args: any[]): this;
301
+ scale(scale: number | number[] | PtLike, anchor?: PtLike): this;
302
+ rotate2D(angle: number, anchor?: PtLike, axis?: string): this;
303
+ shear2D(scale: number | number[] | PtLike, anchor?: PtLike, axis?: string): this;
304
+ reflect2D(line: PtLikeIterable, axis?: string): this;
305
+ sortByDimension(dim: number, desc?: boolean): this;
306
+ forEachPt(ptFn: string, ...args: any[]): this;
307
+ add(...args: any[]): this;
308
+ subtract(...args: any[]): this;
309
+ multiply(...args: any[]): this;
310
+ divide(...args: any[]): this;
311
+ $matrixAdd(g: GroupLike | number[][] | number): Group;
312
+ $matrixMultiply(g: GroupLike | number, transposed?: boolean, elementwise?: boolean): Group;
313
+ zipSlice(index: number, defaultValue?: number | boolean): Pt;
314
+ $zip(defaultValue?: number | boolean, useLongest?: boolean): Group;
315
+ toBound(): Group;
316
+ toString(): string;
500
317
  }
501
- export class Range {
502
- protected _source: Group;
503
- protected _max: Pt;
504
- protected _min: Pt;
505
- protected _mag: Pt;
506
- protected _dims: number;
507
- constructor(g: PtIterable);
508
- get max(): Pt;
509
- get min(): Pt;
510
- get magnitude(): Pt;
511
- calc(): this;
512
- mapTo(min: number, max: number, exclude?: boolean[]): Group;
513
- append(pts: PtLikeIterable, update?: boolean): this;
514
- ticks(count: number): Group;
318
+ declare class Bound extends Group implements IPt {
319
+ protected _center: Pt;
320
+ protected _size: Pt;
321
+ protected _topLeft: Pt;
322
+ protected _bottomRight: Pt;
323
+ protected _inited: boolean;
324
+ constructor(...args: Pt[]);
325
+ static fromBoundingRect(rect: ClientRect): Bound;
326
+ static fromGroup(g: PtLikeIterable): Bound;
327
+ protected init(): void;
328
+ clone(): Bound;
329
+ protected _updateSize(): void;
330
+ protected _updateCenter(): void;
331
+ protected _updatePosFromTop(): void;
332
+ protected _updatePosFromBottom(): void;
333
+ protected _updatePosFromCenter(): void;
334
+ get size(): Pt;
335
+ set size(p: Pt);
336
+ get center(): Pt;
337
+ set center(p: Pt);
338
+ get topLeft(): Pt;
339
+ set topLeft(p: Pt);
340
+ get bottomRight(): Pt;
341
+ set bottomRight(p: Pt);
342
+ get width(): number;
343
+ set width(w: number);
344
+ get height(): number;
345
+ set height(h: number);
346
+ get depth(): number;
347
+ set depth(d: number);
348
+ get x(): number;
349
+ get y(): number;
350
+ get z(): number;
351
+ get inited(): boolean;
352
+ update(): this;
515
353
  }
516
354
 
517
- export class Line {
518
- static fromAngle(anchor: PtLike, angle: number, magnitude: number): Group;
519
- static slope(p1: PtLike, p2: PtLike): number;
520
- static intercept(p1: PtLike, p2: PtLike): {
521
- slope: number;
522
- xi: number;
523
- yi: number;
524
- };
525
- static sideOfPt2D(line: PtLikeIterable, pt: PtLike): number;
526
- static collinear(p1: PtLike, p2: PtLike, p3: PtLike, threshold?: number): boolean;
527
- static magnitude(line: PtIterable): number;
528
- static magnitudeSq(line: PtIterable): number;
529
- static perpendicularFromPt(line: PtIterable, pt: PtLike, asProjection?: boolean): Pt;
530
- static distanceFromPt(line: GroupLike, pt: PtLike | number[]): number;
531
- static intersectRay2D(la: PtIterable, lb: PtIterable): Pt;
532
- static intersectLine2D(la: PtIterable, lb: PtIterable): Pt;
533
- static intersectLineWithRay2D(line: PtIterable, ray: PtIterable): Pt;
534
- static intersectPolygon2D(lineOrRay: PtIterable, poly: PtIterable, sourceIsRay?: boolean): Group;
535
- static intersectLines2D(lines1: Iterable<PtIterable>, lines2: Iterable<PtIterable>, isRay?: boolean): Group;
536
- static intersectGridWithRay2D(ray: PtIterable, gridPt: PtLike): Group;
537
- static intersectGridWithLine2D(line: GroupLike, gridPt: PtLike | number[]): Group;
538
- static intersectRect2D(line: GroupLike, rect: GroupLike): Group;
539
- static subpoints(line: PtLikeIterable, num: number): Group;
540
- static crop(line: PtIterable, size: PtLike, index?: number, cropAsCircle?: boolean): Pt;
541
- static marker(line: PtIterable, size: PtLike, graphic?: string, atTail?: boolean): Group;
542
- static toRect(line: GroupLike): Group;
355
+ /*! Pts.js is licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
356
+
357
+ declare abstract class Form {
358
+ protected _ready: boolean;
359
+ get ready(): boolean;
543
360
  }
544
- export class Rectangle {
545
- static from(topLeft: PtLike, widthOrSize: number | PtLike, height?: number): Group;
546
- static fromTopLeft(topLeft: PtLike, widthOrSize: number | PtLike, height?: number): Group;
547
- static fromCenter(center: PtLike, widthOrSize: number | PtLike, height?: number): Group;
548
- static toCircle(pts: PtIterable, within?: boolean): Group;
549
- static toSquare(pts: PtIterable, enclose?: boolean): Group;
550
- static size(pts: PtIterable): Pt;
551
- static center(pts: PtIterable): Pt;
552
- static corners(rect: PtIterable): Group;
553
- static sides(rect: PtIterable): Group[];
554
- static boundingBox(rects: Iterable<PtLikeIterable>): Group;
555
- static polygon(rect: PtIterable): Group;
556
- static quadrants(rect: PtIterable, center?: PtLike): Group[];
557
- static halves(rect: PtIterable, ratio?: number, asRows?: boolean): Group[];
558
- static withinBound(rect: GroupLike, pt: PtLike): boolean;
559
- static hasIntersectRect2D(rect1: GroupLike, rect2: GroupLike, resetBoundingBox?: boolean): boolean;
560
- static intersectRect2D(rect1: GroupLike, rect2: GroupLike): Group;
361
+ declare abstract class VisualForm extends Form {
362
+ protected _filled: boolean;
363
+ protected _stroked: boolean;
364
+ protected _font: Font;
365
+ get filled(): boolean;
366
+ set filled(b: boolean);
367
+ get stroked(): boolean;
368
+ set stroked(b: boolean);
369
+ get currentFont(): Font;
370
+ protected _multiple(groups: GroupLike[], shape: string, ...rest: any[]): this;
371
+ abstract reset(): this;
372
+ alpha(a: number): this;
373
+ fill(c: string | boolean): this;
374
+ fillOnly(c: string | boolean): this;
375
+ stroke(c: string | boolean, width?: number, linejoin?: string, linecap?: string): this;
376
+ strokeOnly(c: string | boolean, width?: number, linejoin?: string, linecap?: string): this;
377
+ abstract point(p: PtLike, radius: number, shape: string): this;
378
+ points(pts: GroupLike | number[][], radius: number, shape: string): this;
379
+ abstract circle(pts: GroupLike | number[][]): this;
380
+ circles(groups: GroupLike[]): this;
381
+ squares(groups: GroupLike[]): this;
382
+ abstract arc(pt: PtLike, radius: number, startAngle: number, endAngle: number, cc?: boolean): this;
383
+ abstract line(pts: GroupLike | number[][]): this;
384
+ lines(groups: GroupLike[]): this;
385
+ abstract polygon(pts: GroupLike | number[][]): this;
386
+ polygons(groups: GroupLike[]): this;
387
+ abstract rect(pts: number[][] | Pt[]): this;
388
+ rects(groups: GroupLike[]): this;
389
+ abstract text(pt: PtLike, txt: string, maxWidth?: number): this;
390
+ abstract font(sizeOrFont: number | Font, weight?: string, style?: string, lineHeight?: number, family?: string): this;
561
391
  }
562
- export class Circle {
563
- static fromRect(pts: PtLikeIterable, enclose?: boolean): Group;
564
- static fromTriangle(pts: PtIterable, enclose?: boolean): Group;
565
- static fromCenter(pt: PtLike, radius: number): Group;
566
- static withinBound(pts: PtIterable, pt: PtLike, threshold?: number): boolean;
567
- static intersectRay2D(circle: PtIterable, ray: PtIterable): Group;
568
- static intersectLine2D(circle: PtIterable, line: PtIterable): Group;
569
- static intersectCircle2D(circle1: PtIterable, circle2: PtIterable): Group;
570
- static intersectRect2D(circle: PtIterable, rect: PtIterable): Group;
571
- static toRect(circle: PtIterable, within?: boolean): Group;
572
- static toTriangle(circle: PtIterable, within?: boolean): Group;
392
+ declare class Font {
393
+ size: number;
394
+ lineHeight: number;
395
+ face: string;
396
+ style: string;
397
+ weight: string;
398
+ constructor(size?: number, face?: string, weight?: string, style?: string, lineHeight?: number);
399
+ get value(): string;
400
+ toString(): string;
573
401
  }
574
- export class Triangle {
575
- static fromRect(rect: PtIterable): Group;
576
- static fromCircle(circle: PtIterable): Group;
577
- static fromCenter(pt: PtLike, size: number): Group;
578
- static medial(tri: PtIterable): Group;
579
- static oppositeSide(tri: PtIterable, index: number): Group;
580
- static altitude(tri: PtIterable, index: number): Group;
581
- static orthocenter(tri: PtIterable): Pt;
582
- static incenter(tri: PtIterable): Pt;
583
- static incircle(tri: PtIterable, center?: Pt): Group;
584
- static circumcenter(tri: PtIterable): Pt;
585
- static circumcircle(tri: PtIterable, center?: Pt): Group;
402
+
403
+ /*! Pts.js is licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
404
+
405
+ declare abstract class Space {
406
+ id: string;
407
+ protected bound: Bound;
408
+ protected _time: ITimer;
409
+ protected players: ISpacePlayers;
410
+ protected playerCount: number;
411
+ protected _ctx: any;
412
+ private _animID;
413
+ private _pause;
414
+ private _refresh;
415
+ private _renderFunc;
416
+ protected _pointer: Pt;
417
+ protected _isReady: boolean;
418
+ protected _playing: boolean;
419
+ protected _keyDownBind: (evt: KeyboardEvent) => boolean;
420
+ protected _keyUpBind: (evt: KeyboardEvent) => boolean;
421
+ refresh(b: boolean): this;
422
+ minFrameTime(ms?: number): void;
423
+ add(p: IPlayer | AnimateCallbackFn): this;
424
+ remove(player: IPlayer): this;
425
+ removeAll(): this;
426
+ play(time?: number): this;
427
+ replay(): void;
428
+ protected playItems(time: number): void;
429
+ pause(toggle?: boolean): this;
430
+ resume(): this;
431
+ stop(t?: number): this;
432
+ playOnce(duration?: number): this;
433
+ protected render(context: any): this;
434
+ set customRendering(f: (context: any, self: Space) => null);
435
+ get customRendering(): (context: any, self: Space) => null;
436
+ get isPlaying(): boolean;
437
+ get outerBound(): Bound;
438
+ get innerBound(): Bound;
439
+ get size(): Pt;
440
+ get center(): Pt;
441
+ get width(): number;
442
+ get height(): number;
443
+ abstract resize(b: Bound, evt?: Event): this;
444
+ abstract clear(): this;
445
+ abstract getForm(): Form;
586
446
  }
587
- export class Polygon {
588
- static centroid(pts: PtLikeIterable): Pt;
589
- static rectangle(center: PtLike, widthOrSize: number | PtLike, height?: number): Group;
590
- static fromCenter(center: PtLike, radius: number, sides: number): Group;
591
- static lineAt(pts: PtLikeIterable, index: number): Group;
592
- static lines(poly: PtIterable, closePath?: boolean): Group[];
593
- static midpoints(poly: PtIterable, closePath?: boolean, t?: number): Group;
594
- static adjacentSides(poly: PtIterable, index: number, closePath?: boolean): Group[];
595
- static bisector(poly: PtIterable, index: number): Pt;
596
- static perimeter(poly: PtIterable, closePath?: boolean): {
597
- total: number;
598
- segments: Pt;
447
+ declare abstract class MultiTouchSpace extends Space {
448
+ protected _pressed: boolean;
449
+ protected _dragged: boolean;
450
+ protected _hasMouse: boolean;
451
+ protected _hasTouch: boolean;
452
+ protected _hasKeyboard: boolean;
453
+ protected _canvas: EventTarget;
454
+ get pointer(): Pt;
455
+ bindCanvas(evt: string, callback: EventListener, options?: any, customTarget?: Element): void;
456
+ unbindCanvas(evt: string, callback: EventListener, options?: any, customTarget?: Element): void;
457
+ bindDoc(evt: string, callback: EventListener, options?: any): void;
458
+ unbindDoc(evt: string, callback: EventListener, options?: any): void;
459
+ bindMouse(bind?: boolean, customTarget?: Element): this;
460
+ bindTouch(bind?: boolean, passive?: boolean, customTarget?: Element): this;
461
+ bindKeyboard(bind?: boolean): this;
462
+ touchesToPoints(evt: TouchEvent, which?: TouchPointsKey): Pt[];
463
+ protected _mouseAction(type: string, evt: MouseEvent | TouchEvent): void;
464
+ protected _mouseDown(evt: MouseEvent | TouchEvent): boolean;
465
+ protected _mouseUp(evt: MouseEvent | TouchEvent): boolean;
466
+ protected _mouseMove(evt: MouseEvent | TouchEvent): boolean;
467
+ protected _mouseOver(evt: MouseEvent | TouchEvent): boolean;
468
+ protected _mouseOut(evt: MouseEvent | TouchEvent): boolean;
469
+ protected _mouseClick(evt: MouseEvent | TouchEvent): boolean;
470
+ protected _contextMenu(evt: MouseEvent): boolean;
471
+ protected _touchMove(evt: TouchEvent): boolean;
472
+ protected _touchStart(evt: TouchEvent): boolean;
473
+ protected _keyDown(evt: KeyboardEvent): boolean;
474
+ protected _keyUp(evt: KeyboardEvent): boolean;
475
+ protected _keyboardAction(type: string, evt: KeyboardEvent): void;
476
+ }
477
+
478
+ /*! Pts.js is licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
479
+
480
+ declare class Vec {
481
+ static add(a: PtLike, b: PtLike | number): PtLike;
482
+ static subtract(a: PtLike, b: PtLike | number): PtLike;
483
+ static multiply(a: PtLike, b: PtLike | number): PtLike;
484
+ static divide(a: PtLike, b: PtLike | number): PtLike;
485
+ static dot(a: PtLike, b: PtLike): number;
486
+ static cross2D(a: PtLike, b: PtLike): number;
487
+ static cross(a: PtLike, b: PtLike): Pt;
488
+ static magnitude(a: PtLike): number;
489
+ static unit(a: PtLike, magnitude?: number): PtLike;
490
+ static abs(a: PtLike): PtLike;
491
+ static floor(a: PtLike): PtLike;
492
+ static ceil(a: PtLike): PtLike;
493
+ static round(a: PtLike): PtLike;
494
+ static max(a: PtLike): {
495
+ value: any;
496
+ index: any;
599
497
  };
600
- static area(pts: PtLikeIterable): any;
601
- static convexHull(pts: PtLikeIterable, sorted?: boolean): Group;
602
- static network(poly: PtIterable, originIndex?: number): Group[];
603
- static nearestPt(poly: PtIterable, pt: PtLike): number;
604
- static projectAxis(poly: PtIterable, unitAxis: Pt): Pt;
605
- protected static _axisOverlap(poly1: PtIterable, poly2: PtIterable, unitAxis: Pt): number;
606
- static hasIntersectPoint(poly: PtLikeIterable, pt: PtLike): boolean;
607
- static hasIntersectCircle(poly: PtIterable, circle: PtIterable): IntersectContext;
608
- static hasIntersectPolygon(poly1: PtIterable, poly2: PtIterable): IntersectContext;
609
- static intersectPolygon2D(poly1: PtIterable, poly2: PtIterable): Group;
610
- static toRects(polys: Iterable<PtIterable>): Group[];
498
+ static min(a: PtLike): {
499
+ value: any;
500
+ index: any;
501
+ };
502
+ static sum(a: PtLike): number;
503
+ static map(a: PtLike, fn: (n: number, index: number, arr: any) => number): PtLike;
611
504
  }
612
- export class Curve {
613
- static getSteps(steps: number): Group;
614
- static controlPoints(pts: PtLikeIterable, index?: number, copyStart?: boolean): Group;
615
- static _calcPt(ctrls: GroupLike, params: PtLike): Pt;
616
- static catmullRom(pts: PtLikeIterable, steps?: number): Group;
617
- static catmullRomStep(step: Pt, ctrls: GroupLike): Pt;
618
- static cardinal(pts: PtLikeIterable, steps?: number, tension?: number): Group;
619
- static cardinalStep(step: Pt, ctrls: GroupLike, tension?: number): Pt;
620
- static bezier(pts: GroupLike, steps?: number): Group;
621
- static bezierStep(step: Pt, ctrls: GroupLike): Pt;
622
- static bspline(pts: GroupLike, steps?: number, tension?: number): Group;
623
- static bsplineStep(step: Pt, ctrls: GroupLike): Pt;
624
- static bsplineTensionStep(step: Pt, ctrls: GroupLike, tension?: number): Pt;
505
+ declare class Mat {
506
+ protected _33: GroupLike;
507
+ constructor();
508
+ get value(): GroupLike;
509
+ get domMatrix(): DOMMatrix;
510
+ reset(): void;
511
+ scale2D(val: PtLike, at?: PtLike): this;
512
+ rotate2D(ang: number, at?: PtLike): this;
513
+ translate2D(val: PtLike): this;
514
+ shear2D(val: PtLike, at?: PtLike): this;
515
+ static add(a: GroupLike, b: GroupLike | number[][] | number): Group;
516
+ static multiply(a: GroupLike, b: GroupLike | number[][] | number, transposed?: boolean, elementwise?: boolean): Group;
517
+ static zipSlice(g: GroupLike | number[][], index: number, defaultValue?: number | boolean): Pt;
518
+ static zip(g: GroupLike | number[][], defaultValue?: number | boolean, useLongest?: boolean): Group;
519
+ static transpose(g: GroupLike | number[][], defaultValue?: number | boolean, useLongest?: boolean): Group;
520
+ static toDOMMatrix(m: GroupLike | number[][]): number[];
521
+ static transform2D(pt: PtLike, m: GroupLike | number[][]): Pt;
522
+ static scale2DMatrix(x: number, y: number): GroupLike;
523
+ static rotate2DMatrix(cosA: number, sinA: number): GroupLike;
524
+ static shear2DMatrix(tanX: number, tanY: number): GroupLike;
525
+ static translate2DMatrix(x: number, y: number): GroupLike;
526
+ static scaleAt2DMatrix(sx: number, sy: number, at: PtLike): GroupLike;
527
+ static rotateAt2DMatrix(cosA: number, sinA: number, at: PtLike): GroupLike;
528
+ static shearAt2DMatrix(tanX: number, tanY: number, at: PtLike): GroupLike;
529
+ static reflectAt2DMatrix(p1: PtLike, p2: PtLike): Pt[];
625
530
  }
626
531
 
627
- export class World {
628
- protected _gravity: Pt;
629
- protected _friction: number;
630
- protected _damping: number;
631
- protected _bound: Bound;
632
- protected _particles: Particle[];
633
- protected _bodies: Body[];
634
- protected _pnames: string[];
635
- protected _bnames: string[];
636
- protected _drawParticles: (p: Particle, i: number) => void;
637
- protected _drawBodies: (p: Body, i: number) => void;
638
- constructor(bound: PtIterable, friction?: number, gravity?: PtLike | number);
639
- get bound(): Bound;
640
- set bound(bound: Bound);
641
- get gravity(): Pt;
642
- set gravity(g: Pt);
643
- get friction(): number;
644
- set friction(f: number);
645
- get damping(): number;
646
- set damping(f: number);
647
- get bodyCount(): number;
648
- get particleCount(): number;
649
- body(id: number | string): any;
650
- particle(id: number | string): any;
651
- bodyIndex(name: string): number;
652
- particleIndex(name: string): number;
653
- update(ms: number): void;
654
- drawParticles(fn: (p: Particle, i: number) => void): void;
655
- drawBodies(fn: (p: Body, i: number) => void): void;
656
- add(p: Particle | Body, name?: string): this;
657
- removeBody(from: number | string, count?: number): this;
658
- removeParticle(from: number | string, count?: number): this;
659
- static edgeConstraint(p1: Particle, p2: Particle, dist: number, stiff?: number, precise?: boolean): Particle;
660
- static boundConstraint(p: Particle, rect: PtIterable, damping?: number): void;
661
- protected integrate(p: Particle, dt: number, prevDt?: number): Particle;
662
- protected _updateParticles(dt: number): void;
663
- protected _updateBodies(dt: number): void;
532
+ declare class Img {
533
+ protected _img: HTMLImageElement;
534
+ protected _data: ImageData;
535
+ protected _cv: HTMLCanvasElement;
536
+ protected _ctx: CanvasRenderingContext2D;
537
+ protected _scale: number;
538
+ protected _loaded: boolean;
539
+ protected _editable: boolean;
540
+ protected _space: CanvasSpace;
541
+ constructor(editable?: boolean, space?: CanvasSpace, crossOrigin?: boolean);
542
+ static load(src: string, editable?: boolean, space?: CanvasSpace, ready?: (img: any) => {}): Img;
543
+ static loadAsync(src: string, editable?: boolean, space?: CanvasSpace): Promise<Img>;
544
+ static loadPattern(src: string, space: CanvasSpace, repeat?: CanvasPatternRepetition, editable?: boolean): Promise<CanvasPattern>;
545
+ static blank(size: PtLike, space: CanvasSpace, scale?: number): Img;
546
+ load(src: string): Promise<Img>;
547
+ protected _drawToScale(canvasScale: number | PtLike, img: CanvasImageSource): void;
548
+ initCanvas(width: number, height: number, canvasScale?: number | PtLike): void;
549
+ bitmap(size?: PtLike): Promise<ImageBitmap>;
550
+ pattern(reptition?: CanvasPatternRepetition, dynamic?: boolean): CanvasPattern;
551
+ sync(): void;
552
+ pixel(p: PtLike, rescale?: boolean | number): Pt;
553
+ static getPixel(imgData: ImageData, p: PtLike): Pt;
554
+ resize(sizeOrScale: PtLike, asScale?: boolean): this;
555
+ crop(box: Bound): ImageData;
556
+ filter(css: string): this;
557
+ cleanup(): void;
558
+ static fromBlob(blob: Blob, editable?: boolean, space?: CanvasSpace): Promise<Img>;
559
+ static imageDataToBlob(data: ImageData): Promise<Blob>;
560
+ toBase64(): string;
561
+ toBlob(): Promise<Blob>;
562
+ getForm(): CanvasForm;
563
+ get current(): CanvasImageSource;
564
+ get image(): HTMLImageElement;
565
+ get canvas(): HTMLCanvasElement;
566
+ get data(): ImageData;
567
+ get ctx(): CanvasRenderingContext2D;
568
+ get loaded(): boolean;
569
+ get pixelScale(): number;
570
+ get imageSize(): Pt;
571
+ get canvasSize(): Pt;
572
+ get scaledMatrix(): Mat;
664
573
  }
665
- export class Particle extends Pt {
666
- protected _mass: number;
667
- protected _radius: number;
668
- protected _force: Pt;
669
- protected _prev: Pt;
670
- protected _body: Body;
671
- protected _lock: boolean;
672
- protected _lockPt: Pt;
673
- constructor(...args: any[]);
674
- get mass(): number;
675
- set mass(m: number);
676
- get radius(): number;
677
- set radius(f: number);
678
- get previous(): Pt;
679
- set previous(p: Pt);
680
- get force(): Pt;
681
- set force(g: Pt);
682
- get body(): Body;
683
- set body(b: Body);
684
- get lock(): boolean;
685
- set lock(b: boolean);
686
- get changed(): Pt;
687
- set position(p: Pt);
688
- size(r: number): this;
689
- addForce(...args: any[]): Pt;
690
- verlet(dt: number, friction: number, lastDt?: number): this;
691
- hit(...args: any[]): this;
692
- collide(p2: Particle, damp?: number): void;
693
- toString(): string;
574
+
575
+ /*! Pts.js is licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
576
+
577
+ declare class CanvasSpace extends MultiTouchSpace {
578
+ protected _canvas: HTMLCanvasElement;
579
+ protected _container: Element;
580
+ protected _pixelScale: number;
581
+ protected _autoResize: boolean;
582
+ protected _bgcolor: string;
583
+ protected _ctx: PtsCanvasRenderingContext2D;
584
+ protected _offscreen: boolean;
585
+ protected _offCanvas: HTMLCanvasElement;
586
+ protected _offCtx: PtsCanvasRenderingContext2D;
587
+ protected _initialResize: boolean;
588
+ constructor(elem: string | Element, callback?: Function);
589
+ protected _createElement(elem: string, id: any): HTMLElement;
590
+ private _ready;
591
+ setup(opt: CanvasSpaceOptions): this;
592
+ set autoResize(auto: boolean);
593
+ get autoResize(): boolean;
594
+ resize(b: Bound, evt?: Event): this;
595
+ protected _resizeHandler(evt: Event): void;
596
+ set background(bg: string);
597
+ get background(): string;
598
+ get pixelScale(): number;
599
+ get hasOffscreen(): boolean;
600
+ get offscreenCtx(): PtsCanvasRenderingContext2D;
601
+ get offscreenCanvas(): HTMLCanvasElement;
602
+ getForm(): CanvasForm;
603
+ get element(): HTMLCanvasElement;
604
+ get parent(): Element;
605
+ get ready(): boolean;
606
+ get ctx(): PtsCanvasRenderingContext2D;
607
+ clear(bg?: string): this;
608
+ clearOffscreen(bg?: string): this;
609
+ protected playItems(time: number): void;
610
+ dispose(): this;
611
+ recorder(downloadOrCallback: boolean | ((blobURL: string) => {}), filetype?: string, bitrate?: number): MediaRecorder;
694
612
  }
695
- export class Body extends Group {
696
- protected _cs: Array<number[]>;
697
- protected _stiff: number;
698
- protected _locks: {
699
- [index: string]: Particle;
700
- };
701
- protected _mass: number;
702
- constructor();
703
- static fromGroup(body: PtIterable, stiff?: number, autoLink?: boolean, autoMass?: boolean): Body;
704
- init(body: PtIterable, stiff?: number): this;
705
- get mass(): number;
706
- set mass(m: number);
707
- autoMass(): this;
708
- link(index1: number, index2: number, stiff?: number): this;
709
- linkAll(stiff: number): void;
710
- linksToLines(): Group[];
711
- processEdges(): void;
712
- processBody(b: Body): void;
713
- processParticle(b: Particle): void;
613
+ declare class CanvasForm extends VisualForm {
614
+ protected _space: CanvasSpace;
615
+ protected _ctx: CanvasRenderingContext2D;
616
+ protected _estimateTextWidth: (string: any) => number;
617
+ protected _style: DefaultFormStyle;
618
+ constructor(space: CanvasSpace | CanvasRenderingContext2D);
619
+ get space(): CanvasSpace;
620
+ get ctx(): PtsCanvasRenderingContext2D;
621
+ useOffscreen(off?: boolean, clear?: boolean | string): this;
622
+ renderOffscreen(offset?: PtLike): void;
623
+ alpha(a: number): this;
624
+ fill(c: string | boolean | CanvasGradient | CanvasPattern): this;
625
+ stroke(c: string | boolean | CanvasGradient | CanvasPattern, width?: number, linejoin?: CanvasLineJoin, linecap?: CanvasLineCap): this;
626
+ applyFillStroke(filled?: boolean | string, stroked?: boolean | string, strokeWidth?: number): this;
627
+ gradient(stops: [number, string][] | string[]): ((area1: GroupLike, area2?: GroupLike) => CanvasGradient);
628
+ composite(mode?: GlobalCompositeOperation): this;
629
+ clip(): this;
630
+ dash(segments?: PtLike | boolean, offset?: number): this;
631
+ font(sizeOrFont: number | Font, weight?: string, style?: string, lineHeight?: number, family?: string): this;
632
+ fontWidthEstimate(estimate?: boolean): this;
633
+ getTextWidth(c: string): number;
634
+ protected _textTruncate(str: string, width: number, tail?: string): [string, number];
635
+ protected _textAlign(box: PtLikeIterable, vertical: string, offset?: PtLike, center?: Pt): Pt;
636
+ reset(): this;
637
+ protected _paint(): void;
638
+ static point(ctx: CanvasRenderingContext2D, p: PtLike, radius?: number, shape?: string): void;
639
+ point(p: PtLike, radius?: number, shape?: string): this;
640
+ static circle(ctx: CanvasRenderingContext2D, pt: PtLike, radius?: number): void;
641
+ circle(pts: PtLikeIterable): this;
642
+ static ellipse(ctx: CanvasRenderingContext2D, pt: PtLike, radius: PtLike, rotation?: number, startAngle?: number, endAngle?: number, cc?: boolean): void;
643
+ ellipse(pt: PtLike, radius: PtLike, rotation?: number, startAngle?: number, endAngle?: number, cc?: boolean): this;
644
+ static arc(ctx: CanvasRenderingContext2D, pt: PtLike, radius: number, startAngle: number, endAngle: number, cc?: boolean): void;
645
+ arc(pt: PtLike, radius: number, startAngle: number, endAngle: number, cc?: boolean): this;
646
+ static square(ctx: CanvasRenderingContext2D, pt: PtLike, halfsize: number): void;
647
+ square(pt: PtLike, halfsize: number): this;
648
+ static line(ctx: CanvasRenderingContext2D, pts: PtLikeIterable): void;
649
+ line(pts: PtLikeIterable): this;
650
+ static polygon(ctx: CanvasRenderingContext2D, pts: PtLikeIterable): void;
651
+ polygon(pts: PtLikeIterable): this;
652
+ static rect(ctx: CanvasRenderingContext2D, pts: PtLikeIterable): void;
653
+ rect(pts: PtLikeIterable): this;
654
+ static image(ctx: CanvasRenderingContext2D, ptOrRect: PtLike | PtLikeIterable, img: CanvasImageSource | Img, orig?: PtLikeIterable): void;
655
+ image(ptOrRect: PtLike | PtLikeIterable, img: CanvasImageSource | Img, orig?: PtLikeIterable): this;
656
+ static imageData(ctx: CanvasRenderingContext2D, ptOrRect: PtLike | PtLikeIterable, img: ImageData): void;
657
+ imageData(ptOrRect: PtLike | PtLikeIterable, img: ImageData): this;
658
+ static text(ctx: CanvasRenderingContext2D, pt: PtLike, txt: string, maxWidth?: number): void;
659
+ text(pt: PtLike, txt: string, maxWidth?: number): this;
660
+ textBox(box: PtIterable, txt: string, verticalAlign?: string, tail?: string, overrideBaseline?: boolean): this;
661
+ paragraphBox(box: PtLikeIterable, txt: string, lineHeight?: number, verticalAlign?: string, crop?: boolean): this;
662
+ alignText(alignment?: CanvasTextAlign, baseline?: CanvasTextBaseline): this;
663
+ log(txt: any): this;
714
664
  }
715
665
 
716
- export class Tempo implements IPlayer {
717
- protected _bpm: number;
718
- protected _ms: number;
719
- protected _listeners: {
720
- [key: string]: ITempoListener;
721
- };
722
- protected _listenerInc: number;
723
- animateID: string;
724
- constructor(bpm: number);
725
- static fromBeat(ms: number): Tempo;
726
- get bpm(): number;
727
- set bpm(n: number);
728
- get ms(): number;
729
- set ms(n: number);
730
- protected _createID(listener: ITempoListener | Function): string;
731
- every(beats: number | number[]): ITempoResponses;
732
- track(time: any): void;
733
- stop(name: string): void;
734
- animate(time: any, ftime: any): void;
735
- resize(bound: Bound, evt?: Event): void;
736
- action(type: string, px: number, py: number, evt: Event): void;
666
+ /*! Pts.js is licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
667
+
668
+ declare class Create {
669
+ static distributeRandom(bound: Bound, count: number, dimensions?: number): Group;
670
+ static distributeLinear(line: PtIterable, count: number): Group;
671
+ static gridPts(bound: Bound, columns: number, rows: number, orientation?: PtLike): Group;
672
+ static gridCells(bound: Bound, columns: number, rows: number): Group[];
673
+ static radialPts(center: PtLike, radius: number, count: number, angleOffset?: number): Group;
674
+ static noisePts(pts: PtIterable, dx?: number, dy?: number, rows?: number, columns?: number): Group;
675
+ static delaunay(pts: GroupLike): Delaunay;
737
676
  }
738
- export class Sound {
739
- _ctx: AudioContext;
740
- _node: AudioNode;
741
- _outputNode: AudioNode;
742
- _stream: MediaStream;
743
- _source: HTMLMediaElement;
744
- _buffer: AudioBuffer;
745
- analyzer: ISoundAnalyzer;
746
- protected _playing: boolean;
747
- protected _timestamp: number;
748
- constructor(type: SoundType);
749
- static from(node: AudioNode, ctx: AudioContext, type?: SoundType, stream?: MediaStream): Sound;
750
- static load(source: HTMLMediaElement | string, crossOrigin?: string): Promise<Sound>;
751
- static loadAsBuffer(url: string): Promise<Sound>;
752
- protected createBuffer(buf: AudioBuffer): this;
753
- static generate(type: OscillatorType, val: number | PeriodicWave): Sound;
754
- protected _gen(type: OscillatorType, val: number | PeriodicWave): Sound;
755
- static input(constraint?: MediaStreamConstraints): Promise<Sound>;
756
- get ctx(): AudioContext;
757
- get node(): AudioNode;
758
- get outputNode(): AudioNode;
759
- get stream(): MediaStream;
760
- get source(): HTMLMediaElement;
761
- get buffer(): AudioBuffer;
762
- set buffer(b: AudioBuffer);
763
- get type(): SoundType;
764
- get playing(): boolean;
765
- get progress(): number;
766
- get playable(): boolean;
767
- get binSize(): number;
768
- get sampleRate(): number;
769
- get frequency(): number;
770
- set frequency(f: number);
771
- connect(node: AudioNode): this;
772
- setOutputNode(outputNode: AudioNode): this;
773
- removeOutputNode(): this;
774
- analyze(size?: number, minDb?: number, maxDb?: number, smooth?: number): this;
775
- protected _domain(time: boolean): Uint8Array;
776
- protected _domainTo(time: boolean, size: PtLike, position?: PtLike, trim?: number[]): Group;
777
- timeDomain(): Uint8Array;
778
- timeDomainTo(size: PtLike, position?: PtLike, trim?: number[]): Group;
779
- freqDomain(): Uint8Array;
780
- freqDomainTo(size: PtLike, position?: PtLike, trim?: number[]): Group;
781
- reset(): this;
782
- start(timeAt?: number): this;
783
- stop(): this;
784
- toggle(): this;
677
+ declare class Noise extends Pt {
678
+ protected perm: number[];
679
+ private _n;
680
+ constructor(...args: any[]);
681
+ initNoise(...args: any[]): this;
682
+ step(x?: number, y?: number): this;
683
+ seed(s: any): this;
684
+ noise2D(): number;
685
+ }
686
+ declare class Delaunay extends Group {
687
+ private _mesh;
688
+ delaunay(triangleOnly?: boolean): GroupLike[] | DelaunayShape[];
689
+ voronoi(): Group[];
690
+ mesh(): DelaunayMesh;
691
+ neighborPts(i: number, sort?: boolean): GroupLike;
692
+ neighbors(i: number): DelaunayShape[];
693
+ protected _cache(o: any): void;
694
+ protected _superTriangle(): Group;
695
+ protected _triangle(i: number, j: number, k: number, pts?: GroupLike): Group;
696
+ protected _circum(i: number, j: number, k: number, tri: GroupLike | false, pts?: GroupLike): DelaunayShape;
697
+ protected static _dedupe(edges: number[]): number[];
785
698
  }
786
699
 
787
- export class Pt extends Float32Array implements IPt, Iterable<number> {
788
- protected _id: string;
789
- constructor(...args: any[]);
790
- static make(dimensions: number, defaultValue?: number, randomize?: boolean): Pt;
791
- get id(): string;
792
- set id(s: string);
793
- get x(): number;
794
- set x(n: number);
795
- get y(): number;
796
- set y(n: number);
797
- get z(): number;
798
- set z(n: number);
799
- get w(): number;
800
- set w(n: number);
801
- clone(): Pt;
802
- equals(p: PtLike, threshold?: number): boolean;
803
- to(...args: any[]): this;
804
- $to(...args: any[]): Pt;
805
- toAngle(radian: number, magnitude?: number, anchorFromPt?: boolean): this;
806
- op(fn: (p1: PtLike, ...rest: any[]) => any): (...rest: any[]) => any;
807
- ops(fns: ((p1: PtLike, ...rest: any[]) => any)[]): ((...rest: any[]) => any)[];
808
- $take(axis: string | number[]): Pt;
809
- $concat(...args: any[]): Pt;
810
- add(...args: any[]): this;
811
- $add(...args: any[]): Pt;
812
- subtract(...args: any[]): this;
813
- $subtract(...args: any[]): Pt;
814
- multiply(...args: any[]): this;
815
- $multiply(...args: any[]): Pt;
816
- divide(...args: any[]): this;
817
- $divide(...args: any[]): Pt;
818
- magnitudeSq(): number;
819
- magnitude(): number;
820
- unit(magnitude?: number): Pt;
821
- $unit(magnitude?: number): Pt;
822
- dot(...args: any[]): number;
823
- $cross2D(...args: any[]): number;
824
- $cross(...args: any[]): Pt;
825
- $project(...args: any[]): Pt;
826
- projectScalar(...args: any[]): number;
827
- abs(): Pt;
828
- $abs(): Pt;
829
- floor(): Pt;
830
- $floor(): Pt;
831
- ceil(): Pt;
832
- $ceil(): Pt;
833
- round(): Pt;
834
- $round(): Pt;
835
- minValue(): {
836
- value: number;
837
- index: number;
700
+ /*! Pts.js is licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
701
+
702
+ declare class Num {
703
+ static generator: any;
704
+ static equals(a: number, b: number, threshold?: number): boolean;
705
+ static lerp(a: number, b: number, t: number): number;
706
+ static clamp(val: number, min: number, max: number): number;
707
+ static boundValue(val: number, min: number, max: number): number;
708
+ static within(p: number, a: number, b: number): boolean;
709
+ static randomRange(a: number, b?: number): number;
710
+ static randomPt(a: PtLike, b?: PtLike): Pt;
711
+ static normalizeValue(n: number, a: number, b: number): number;
712
+ static sum(pts: PtLikeIterable): Pt;
713
+ static average(pts: PtLikeIterable): Pt;
714
+ static cycle(t: number, method?: (t: number) => number): number;
715
+ static mapToRange(n: number, currA: number, currB: number, targetA: number, targetB: number): number;
716
+ static seed(seed: string): void;
717
+ static random(): number;
718
+ }
719
+ declare class Geom {
720
+ static boundAngle(angle: number): number;
721
+ static boundRadian(radian: number): number;
722
+ static toRadian(angle: number): number;
723
+ static toDegree(radian: number): number;
724
+ static boundingBox(pts: PtIterable): Group;
725
+ static centroid(pts: PtLikeIterable): Pt;
726
+ static anchor(pts: PtLikeIterable, ptOrIndex?: PtLike | number, direction?: ("to" | "from")): void;
727
+ static interpolate(a: PtLike, b: PtLike, t?: number): Pt;
728
+ static perpendicular(pt: PtLike, axis?: string | PtLike): Group;
729
+ static isPerpendicular(p1: PtLike, p2: PtLike): boolean;
730
+ static withinBound(pt: PtLike, boundPt1: PtLike, boundPt2: PtLike): boolean;
731
+ static sortEdges(pts: PtIterable): GroupLike;
732
+ static scale(ps: Pt | PtIterable, scale: number | PtLike, anchor?: PtLike): Geom;
733
+ static rotate2D(ps: Pt | PtIterable, angle: number, anchor?: PtLike, axis?: string | PtLike): Geom;
734
+ static shear2D(ps: Pt | PtIterable, scale: number | PtLike, anchor?: PtLike, axis?: string | PtLike): Geom;
735
+ static reflect2D(ps: Pt | PtIterable, line: PtLikeIterable, axis?: string | PtLike): Geom;
736
+ static cosTable(): {
737
+ table: Float64Array;
738
+ cos: (rad: number) => number;
838
739
  };
839
- maxValue(): {
840
- value: number;
841
- index: number;
740
+ static sinTable(): {
741
+ table: Float64Array;
742
+ sin: (rad: number) => number;
842
743
  };
843
- $min(...args: any[]): Pt;
844
- $max(...args: any[]): Pt;
845
- angle(axis?: string | number[]): number;
846
- angleBetween(p: Pt, axis?: string | number[]): number;
847
- scale(scale: number | number[] | PtLike, anchor?: PtLike): this;
848
- rotate2D(angle: number, anchor?: PtLike, axis?: string): this;
849
- shear2D(scale: number | number[] | PtLike, anchor?: PtLike, axis?: string): this;
850
- reflect2D(line: GroupLike, axis?: string): this;
851
- toString(): string;
852
- toArray(): number[];
853
- toGroup(): Group;
854
- toBound(): Bound;
855
744
  }
856
- export class Group extends Array<Pt> {
857
- protected _id: string;
858
- constructor(...args: Pt[]);
859
- get id(): string;
860
- set id(s: string);
861
- get p1(): Pt;
862
- get p2(): Pt;
863
- get p3(): Pt;
864
- get p4(): Pt;
865
- get q1(): Pt;
866
- get q2(): Pt;
867
- get q3(): Pt;
868
- get q4(): Pt;
869
- clone(): Group;
870
- static fromArray(list: PtLikeIterable): Group;
871
- static fromPtArray(list: PtIterable): Group;
872
- split(chunkSize: number, stride?: number, loopBack?: boolean): Group[];
873
- insert(pts: PtIterable, index?: number): this;
874
- remove(index?: number, count?: number): Group;
875
- segments(pts_per_segment?: number, stride?: number, loopBack?: boolean): Group[];
876
- lines(): Group[];
877
- centroid(): Pt;
878
- boundingBox(): Group;
879
- anchorTo(ptOrIndex?: PtLike | number): void;
880
- anchorFrom(ptOrIndex?: PtLike | number): void;
881
- op(fn: (g1: PtIterable, ...rest: any[]) => any): (...rest: any[]) => any;
882
- ops(fns: ((g1: PtIterable, ...rest: any[]) => any)[]): ((...rest: any[]) => any)[];
883
- interpolate(t: number): Pt;
884
- moveBy(...args: any[]): this;
885
- moveTo(...args: any[]): this;
886
- scale(scale: number | number[] | PtLike, anchor?: PtLike): this;
887
- rotate2D(angle: number, anchor?: PtLike, axis?: string): this;
888
- shear2D(scale: number | number[] | PtLike, anchor?: PtLike, axis?: string): this;
889
- reflect2D(line: PtLikeIterable, axis?: string): this;
890
- sortByDimension(dim: number, desc?: boolean): this;
891
- forEachPt(ptFn: string, ...args: any[]): this;
892
- add(...args: any[]): this;
893
- subtract(...args: any[]): this;
894
- multiply(...args: any[]): this;
895
- divide(...args: any[]): this;
896
- $matrixAdd(g: GroupLike | number[][] | number): Group;
897
- $matrixMultiply(g: GroupLike | number, transposed?: boolean, elementwise?: boolean): Group;
898
- zipSlice(index: number, defaultValue?: number | boolean): Pt;
899
- $zip(defaultValue?: number | boolean, useLongest?: boolean): Group;
900
- toBound(): Group;
901
- toString(): string;
745
+ declare class Shaping {
746
+ static linear(t: number, c?: number): number;
747
+ static quadraticIn(t: number, c?: number): number;
748
+ static quadraticOut(t: number, c?: number): number;
749
+ static quadraticInOut(t: number, c?: number): number;
750
+ static cubicIn(t: number, c?: number): number;
751
+ static cubicOut(t: number, c?: number): number;
752
+ static cubicInOut(t: number, c?: number): number;
753
+ static exponentialIn(t: number, c?: number, p?: number): number;
754
+ static exponentialOut(t: number, c?: number, p?: number): number;
755
+ static sineIn(t: number, c?: number): number;
756
+ static sineOut(t: number, c?: number): number;
757
+ static sineInOut(t: number, c?: number): number;
758
+ static cosineApprox(t: number, c?: number): number;
759
+ static circularIn(t: number, c?: number): number;
760
+ static circularOut(t: number, c?: number): number;
761
+ static circularInOut(t: number, c?: number): number;
762
+ static elasticIn(t: number, c?: number, p?: number): number;
763
+ static elasticOut(t: number, c?: number, p?: number): number;
764
+ static elasticInOut(t: number, c?: number, p?: number): number;
765
+ static bounceIn(t: number, c?: number): number;
766
+ static bounceOut(t: number, c?: number): number;
767
+ static bounceInOut(t: number, c?: number): number;
768
+ static sigmoid(t: number, c?: number, p?: number): number;
769
+ static logSigmoid(t: number, c?: number, p?: number): number;
770
+ static seat(t: number, c?: number, p?: number): number;
771
+ static quadraticBezier(t: number, c?: number, p?: number | PtLike): number;
772
+ static cubicBezier(t: number, c?: number, p1?: PtLike, p2?: PtLike): number;
773
+ static quadraticTarget(t: number, c?: number, p1?: PtLike): number;
774
+ static cliff(t: number, c?: number, p?: number): number;
775
+ static step(fn: Function, steps: number, t: number, c: number, ...args: any[]): any;
902
776
  }
903
- export class Bound extends Group implements IPt {
904
- protected _center: Pt;
905
- protected _size: Pt;
906
- protected _topLeft: Pt;
907
- protected _bottomRight: Pt;
908
- protected _inited: boolean;
909
- constructor(...args: Pt[]);
910
- static fromBoundingRect(rect: ClientRect): Bound;
911
- static fromGroup(g: PtLikeIterable): Bound;
912
- protected init(): void;
913
- clone(): Bound;
914
- protected _updateSize(): void;
915
- protected _updateCenter(): void;
916
- protected _updatePosFromTop(): void;
917
- protected _updatePosFromBottom(): void;
918
- protected _updatePosFromCenter(): void;
919
- get size(): Pt;
920
- set size(p: Pt);
921
- get center(): Pt;
922
- set center(p: Pt);
923
- get topLeft(): Pt;
924
- set topLeft(p: Pt);
925
- get bottomRight(): Pt;
926
- set bottomRight(p: Pt);
927
- get width(): number;
928
- set width(w: number);
929
- get height(): number;
930
- set height(h: number);
931
- get depth(): number;
932
- set depth(d: number);
933
- get x(): number;
934
- get y(): number;
935
- get z(): number;
936
- get inited(): boolean;
937
- update(): this;
777
+ declare class Range {
778
+ protected _source: Group;
779
+ protected _max: Pt;
780
+ protected _min: Pt;
781
+ protected _mag: Pt;
782
+ protected _dims: number;
783
+ constructor(g: PtIterable);
784
+ get max(): Pt;
785
+ get min(): Pt;
786
+ get magnitude(): Pt;
787
+ calc(): this;
788
+ mapTo(min: number, max: number, exclude?: boolean[]): Group;
789
+ append(pts: PtLikeIterable, update?: boolean): this;
790
+ ticks(count: number): Group;
791
+ }
792
+
793
+ /*! Pts.js is licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
794
+
795
+ declare class Line {
796
+ static fromAngle(anchor: PtLike, angle: number, magnitude: number): Group;
797
+ static slope(p1: PtLike, p2: PtLike): number;
798
+ static intercept(p1: PtLike, p2: PtLike): {
799
+ slope: number;
800
+ xi: number;
801
+ yi: number;
802
+ };
803
+ static sideOfPt2D(line: PtLikeIterable, pt: PtLike): number;
804
+ static collinear(p1: PtLike, p2: PtLike, p3: PtLike, threshold?: number): boolean;
805
+ static magnitude(line: PtIterable): number;
806
+ static magnitudeSq(line: PtIterable): number;
807
+ static perpendicularFromPt(line: PtIterable, pt: PtLike, asProjection?: boolean): Pt;
808
+ static distanceFromPt(line: GroupLike, pt: PtLike | number[]): number;
809
+ static intersectRay2D(la: PtIterable, lb: PtIterable): Pt;
810
+ static intersectLine2D(la: PtIterable, lb: PtIterable): Pt;
811
+ static intersectLineWithRay2D(line: PtIterable, ray: PtIterable): Pt;
812
+ static intersectPolygon2D(lineOrRay: PtIterable, poly: PtIterable, sourceIsRay?: boolean): Group;
813
+ static intersectLines2D(lines1: Iterable<PtIterable>, lines2: Iterable<PtIterable>, isRay?: boolean): Group;
814
+ static intersectGridWithRay2D(ray: PtIterable, gridPt: PtLike): Group;
815
+ static intersectGridWithLine2D(line: GroupLike, gridPt: PtLike | number[]): Group;
816
+ static intersectRect2D(line: GroupLike, rect: GroupLike): Group;
817
+ static subpoints(line: PtLikeIterable, num: number): Group;
818
+ static crop(line: PtIterable, size: PtLike, index?: number, cropAsCircle?: boolean): Pt;
819
+ static marker(line: PtIterable, size: PtLike, graphic?: string, atTail?: boolean): Group;
820
+ static toRect(line: GroupLike): Group;
821
+ }
822
+ declare class Rectangle {
823
+ static from(topLeft: PtLike, widthOrSize: number | PtLike, height?: number): Group;
824
+ static fromTopLeft(topLeft: PtLike, widthOrSize: number | PtLike, height?: number): Group;
825
+ static fromCenter(center: PtLike, widthOrSize: number | PtLike, height?: number): Group;
826
+ static toCircle(pts: PtIterable, within?: boolean): Group;
827
+ static toSquare(pts: PtIterable, enclose?: boolean): Group;
828
+ static size(pts: PtIterable): Pt;
829
+ static center(pts: PtIterable): Pt;
830
+ static corners(rect: PtIterable): Group;
831
+ static sides(rect: PtIterable): Group[];
832
+ static boundingBox(rects: Iterable<PtLikeIterable>): Group;
833
+ static polygon(rect: PtIterable): Group;
834
+ static quadrants(rect: PtIterable, center?: PtLike): Group[];
835
+ static halves(rect: PtIterable, ratio?: number, asRows?: boolean): Group[];
836
+ static withinBound(rect: GroupLike, pt: PtLike): boolean;
837
+ static hasIntersectRect2D(rect1: GroupLike, rect2: GroupLike, resetBoundingBox?: boolean): boolean;
838
+ static intersectRect2D(rect1: GroupLike, rect2: GroupLike): Group;
839
+ }
840
+ declare class Circle {
841
+ static fromRect(pts: PtLikeIterable, enclose?: boolean): Group;
842
+ static fromTriangle(pts: PtIterable, enclose?: boolean): Group;
843
+ static fromCenter(pt: PtLike, radius: number): Group;
844
+ static withinBound(pts: PtIterable, pt: PtLike, threshold?: number): boolean;
845
+ static intersectRay2D(circle: PtIterable, ray: PtIterable): Group;
846
+ static intersectLine2D(circle: PtIterable, line: PtIterable): Group;
847
+ static intersectCircle2D(circle1: PtIterable, circle2: PtIterable): Group;
848
+ static intersectRect2D(circle: PtIterable, rect: PtIterable): Group;
849
+ static toRect(circle: PtIterable, within?: boolean): Group;
850
+ static toTriangle(circle: PtIterable, within?: boolean): Group;
851
+ }
852
+ declare class Triangle {
853
+ static fromRect(rect: PtIterable): Group;
854
+ static fromCircle(circle: PtIterable): Group;
855
+ static fromCenter(pt: PtLike, size: number): Group;
856
+ static medial(tri: PtIterable): Group;
857
+ static oppositeSide(tri: PtIterable, index: number): Group;
858
+ static altitude(tri: PtIterable, index: number): Group;
859
+ static orthocenter(tri: PtIterable): Pt;
860
+ static incenter(tri: PtIterable): Pt;
861
+ static incircle(tri: PtIterable, center?: Pt): Group;
862
+ static circumcenter(tri: PtIterable): Pt;
863
+ static circumcircle(tri: PtIterable, center?: Pt): Group;
864
+ }
865
+ declare class Polygon {
866
+ static centroid(pts: PtLikeIterable): Pt;
867
+ static rectangle(center: PtLike, widthOrSize: number | PtLike, height?: number): Group;
868
+ static fromCenter(center: PtLike, radius: number, sides: number): Group;
869
+ static lineAt(pts: PtLikeIterable, index: number): Group;
870
+ static lines(poly: PtIterable, closePath?: boolean): Group[];
871
+ static midpoints(poly: PtIterable, closePath?: boolean, t?: number): Group;
872
+ static adjacentSides(poly: PtIterable, index: number, closePath?: boolean): Group[];
873
+ static bisector(poly: PtIterable, index: number): Pt;
874
+ static perimeter(poly: PtIterable, closePath?: boolean): {
875
+ total: number;
876
+ segments: Pt;
877
+ };
878
+ static area(pts: PtLikeIterable): any;
879
+ static convexHull(pts: PtLikeIterable, sorted?: boolean): Group;
880
+ static network(poly: PtIterable, originIndex?: number): Group[];
881
+ static nearestPt(poly: PtIterable, pt: PtLike): number;
882
+ static projectAxis(poly: PtIterable, unitAxis: Pt): Pt;
883
+ protected static _axisOverlap(poly1: PtIterable, poly2: PtIterable, unitAxis: Pt): number;
884
+ static hasIntersectPoint(poly: PtLikeIterable, pt: PtLike): boolean;
885
+ static hasIntersectCircle(poly: PtIterable, circle: PtIterable): IntersectContext;
886
+ static hasIntersectPolygon(poly1: PtIterable, poly2: PtIterable): IntersectContext;
887
+ static intersectPolygon2D(poly1: PtIterable, poly2: PtIterable): Group;
888
+ static toRects(polys: Iterable<PtIterable>): Group[];
889
+ }
890
+ declare class Curve {
891
+ static getSteps(steps: number): Group;
892
+ static controlPoints(pts: PtLikeIterable, index?: number, copyStart?: boolean): Group;
893
+ static _calcPt(ctrls: GroupLike, params: PtLike): Pt;
894
+ static catmullRom(pts: PtLikeIterable, steps?: number): Group;
895
+ static catmullRomStep(step: Pt, ctrls: GroupLike): Pt;
896
+ static cardinal(pts: PtLikeIterable, steps?: number, tension?: number): Group;
897
+ static cardinalStep(step: Pt, ctrls: GroupLike, tension?: number): Pt;
898
+ static bezier(pts: GroupLike, steps?: number): Group;
899
+ static bezierStep(step: Pt, ctrls: GroupLike): Pt;
900
+ static bspline(pts: GroupLike, steps?: number, tension?: number): Group;
901
+ static bsplineStep(step: Pt, ctrls: GroupLike): Pt;
902
+ static bsplineTensionStep(step: Pt, ctrls: GroupLike, tension?: number): Pt;
903
+ }
904
+
905
+ /*! Pts.js is licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
906
+
907
+ declare class Color extends Pt {
908
+ private static D65;
909
+ protected _mode: ColorType;
910
+ private _isNorm;
911
+ static ranges: {
912
+ [name: string]: Group;
913
+ };
914
+ constructor(...args: any[]);
915
+ static from(...args: any[]): Color;
916
+ static fromHex(hex: string): Color;
917
+ static rgb(...args: any[]): Color;
918
+ static hsl(...args: any[]): Color;
919
+ static hsb(...args: any[]): Color;
920
+ static lab(...args: any[]): Color;
921
+ static lch(...args: any[]): Color;
922
+ static luv(...args: any[]): Color;
923
+ static xyz(...args: any[]): Color;
924
+ static maxValues(mode: string): Pt;
925
+ get hex(): string;
926
+ get rgb(): string;
927
+ get rgba(): string;
928
+ clone(): Color;
929
+ toMode(mode: ColorType, convert?: boolean): this;
930
+ get mode(): ColorType;
931
+ get r(): number;
932
+ set r(n: number);
933
+ get g(): number;
934
+ set g(n: number);
935
+ get b(): number;
936
+ set b(n: number);
937
+ get h(): number;
938
+ set h(n: number);
939
+ get s(): number;
940
+ set s(n: number);
941
+ get l(): number;
942
+ set l(n: number);
943
+ get a(): number;
944
+ set a(n: number);
945
+ get c(): number;
946
+ set c(n: number);
947
+ get u(): number;
948
+ set u(n: number);
949
+ get v(): number;
950
+ set v(n: number);
951
+ set alpha(n: number);
952
+ get alpha(): number;
953
+ get normalized(): boolean;
954
+ set normalized(b: boolean);
955
+ normalize(toNorm?: boolean): Color;
956
+ $normalize(toNorm?: boolean): Color;
957
+ toString(format?: ("hex" | "rgb" | "rgba" | "mode")): string;
958
+ static RGBtoHSL(rgb: Color, normalizedInput?: boolean, normalizedOutput?: boolean): Color;
959
+ static HSLtoRGB(hsl: Color, normalizedInput?: boolean, normalizedOutput?: boolean): Color;
960
+ static RGBtoHSB(rgb: Color, normalizedInput?: boolean, normalizedOutput?: boolean): Color;
961
+ static HSBtoRGB(hsb: Color, normalizedInput?: boolean, normalizedOutput?: boolean): Color;
962
+ static RGBtoLAB(rgb: Color, normalizedInput?: boolean, normalizedOutput?: boolean): Color;
963
+ static LABtoRGB(lab: Color, normalizedInput?: boolean, normalizedOutput?: boolean): Color;
964
+ static RGBtoLCH(rgb: Color, normalizedInput?: boolean, normalizedOutput?: boolean): Color;
965
+ static LCHtoRGB(lch: Color, normalizedInput?: boolean, normalizedOutput?: boolean): Color;
966
+ static RGBtoLUV(rgb: Color, normalizedInput?: boolean, normalizedOutput?: boolean): Color;
967
+ static LUVtoRGB(luv: Color, normalizedInput?: boolean, normalizedOutput?: boolean): Color;
968
+ static RGBtoXYZ(rgb: Color, normalizedInput?: boolean, normalizedOutput?: boolean): Color;
969
+ static XYZtoRGB(xyz: Color, normalizedInput?: boolean, normalizedOutput?: boolean): Color;
970
+ static XYZtoLAB(xyz: Color, normalizedInput?: boolean, normalizedOutput?: boolean): Color;
971
+ static LABtoXYZ(lab: Color, normalizedInput?: boolean, normalizedOutput?: boolean): Color;
972
+ static XYZtoLUV(xyz: Color, normalizedInput?: boolean, normalizedOutput?: boolean): Color;
973
+ static LUVtoXYZ(luv: Color, normalizedInput?: boolean, normalizedOutput?: boolean): Color;
974
+ static LABtoLCH(lab: Color, normalizedInput?: boolean, normalizedOutput?: boolean): Color;
975
+ static LCHtoLAB(lch: Color, normalizedInput?: boolean, normalizedOutput?: boolean): Color;
976
+ }
977
+
978
+ /*! Pts.js is licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
979
+
980
+ declare const Const: {
981
+ xy: string;
982
+ yz: string;
983
+ xz: string;
984
+ xyz: string;
985
+ horizontal: number;
986
+ vertical: number;
987
+ identical: number;
988
+ right: number;
989
+ bottom_right: number;
990
+ bottom: number;
991
+ bottom_left: number;
992
+ left: number;
993
+ top_left: number;
994
+ top: number;
995
+ top_right: number;
996
+ epsilon: number;
997
+ max: number;
998
+ min: number;
999
+ pi: number;
1000
+ two_pi: number;
1001
+ half_pi: number;
1002
+ quarter_pi: number;
1003
+ one_degree: number;
1004
+ rad_to_deg: number;
1005
+ deg_to_rad: number;
1006
+ gravity: number;
1007
+ newton: number;
1008
+ gaussian: number;
1009
+ };
1010
+ declare class Util {
1011
+ static _warnLevel: WarningType;
1012
+ static warnLevel(lv?: WarningType): WarningType;
1013
+ static getArgs(args: any[]): Array<number>;
1014
+ static warn(message?: string, defaultReturn?: any): any;
1015
+ static randomInt(range: number, start?: number): number;
1016
+ static split(pts: any[], size: number, stride?: number, loopBack?: boolean, matchSize?: boolean): any[][];
1017
+ static flatten(pts: any[], flattenAsGroup?: boolean): any;
1018
+ static combine<T>(a: T[], b: T[], op: (a: T, b: T) => T): T[];
1019
+ static zip(arrays: Array<any>[]): any[];
1020
+ static stepper(max: number, min?: number, stride?: number, callback?: (n: number) => void): (() => number);
1021
+ static forRange(fn: (index: number) => any, range: number, start?: number, step?: number): any[];
1022
+ static load(url: string, callback: (response: string, success: boolean) => void): void;
1023
+ static download(space: CanvasSpace, filename?: string, filetype?: ("jpeg" | "jpg" | "png" | "webp"), quality?: number): void;
1024
+ static performance(avgFrames?: number): () => number;
1025
+ static arrayCheck(pts: PtLikeIterable, minRequired?: number): boolean;
1026
+ static iterToArray(it: Iterable<any>): any[];
1027
+ static isMobile(): boolean;
938
1028
  }
939
1029
 
940
- export abstract class Space {
1030
+ /*! Pts.js is licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
1031
+
1032
+ declare class DOMSpace extends MultiTouchSpace {
1033
+ protected _canvas: HTMLElement | SVGElement;
1034
+ protected _container: Element;
941
1035
  id: string;
942
- protected bound: Bound;
943
- protected _time: ITimer;
944
- protected players: ISpacePlayers;
945
- protected playerCount: number;
946
- protected _ctx: any;
947
- protected _pointer: Pt;
948
- protected _isReady: boolean;
949
- protected _playing: boolean;
950
- protected _keyDownBind: (evt: KeyboardEvent) => boolean;
951
- protected _keyUpBind: (evt: KeyboardEvent) => boolean;
952
- refresh(b: boolean): this;
953
- minFrameTime(ms?: number): void;
954
- add(p: IPlayer | AnimateCallbackFn): this;
1036
+ protected _autoResize: boolean;
1037
+ protected _bgcolor: string;
1038
+ protected _css: {};
1039
+ constructor(elem: string | Element, callback?: Function);
1040
+ static createElement(elem: string, id: string, appendTo?: Element): Element;
1041
+ private _ready;
1042
+ setup(opt: {
1043
+ bgcolor?: string;
1044
+ resize?: boolean;
1045
+ }): this;
1046
+ getForm(): Form;
1047
+ set autoResize(auto: boolean);
1048
+ get autoResize(): boolean;
1049
+ resize(b: Bound, evt?: Event): this;
1050
+ protected _resizeHandler(evt: Event): void;
1051
+ get element(): Element;
1052
+ get parent(): Element;
1053
+ get ready(): boolean;
1054
+ clear(bg?: string): this;
1055
+ set background(bg: string);
1056
+ get background(): string;
1057
+ style(key: string, val: string, update?: boolean): this;
1058
+ styles(styles: object, update?: boolean): this;
1059
+ static setAttr(elem: Element, data: object): Element;
1060
+ static getInlineStyles(data: object): string;
1061
+ dispose(): this;
1062
+ }
1063
+ declare class HTMLSpace extends DOMSpace {
1064
+ getForm(): Form;
1065
+ static htmlElement(parent: Element, name: string, id?: string, autoClass?: boolean): HTMLElement;
955
1066
  remove(player: IPlayer): this;
956
1067
  removeAll(): this;
957
- play(time?: number): this;
958
- replay(): void;
959
- protected playItems(time: number): void;
960
- pause(toggle?: boolean): this;
961
- resume(): this;
962
- stop(t?: number): this;
963
- playOnce(duration?: number): this;
964
- protected render(context: any): this;
965
- set customRendering(f: (context: any, self: Space) => null);
966
- get customRendering(): (context: any, self: Space) => null;
967
- get isPlaying(): boolean;
968
- get outerBound(): Bound;
969
- get innerBound(): Bound;
970
- get size(): Pt;
971
- get center(): Pt;
972
- get width(): number;
973
- get height(): number;
974
- abstract resize(b: Bound, evt?: Event): this;
975
- abstract clear(): this;
976
- abstract getForm(): Form;
977
1068
  }
978
- export abstract class MultiTouchSpace extends Space {
979
- protected _pressed: boolean;
980
- protected _dragged: boolean;
981
- protected _hasMouse: boolean;
982
- protected _hasTouch: boolean;
983
- protected _hasKeyboard: boolean;
984
- protected _canvas: EventTarget;
985
- get pointer(): Pt;
986
- bindCanvas(evt: string, callback: EventListener, options?: any, customTarget?: Element): void;
987
- unbindCanvas(evt: string, callback: EventListener, options?: any, customTarget?: Element): void;
988
- bindDoc(evt: string, callback: EventListener, options?: any): void;
989
- unbindDoc(evt: string, callback: EventListener, options?: any): void;
990
- bindMouse(bind?: boolean, customTarget?: Element): this;
991
- bindTouch(bind?: boolean, passive?: boolean, customTarget?: Element): this;
992
- bindKeyboard(bind?: boolean): this;
993
- touchesToPoints(evt: TouchEvent, which?: TouchPointsKey): Pt[];
994
- protected _mouseAction(type: string, evt: MouseEvent | TouchEvent): void;
995
- protected _mouseDown(evt: MouseEvent | TouchEvent): boolean;
996
- protected _mouseUp(evt: MouseEvent | TouchEvent): boolean;
997
- protected _mouseMove(evt: MouseEvent | TouchEvent): boolean;
998
- protected _mouseOver(evt: MouseEvent | TouchEvent): boolean;
999
- protected _mouseOut(evt: MouseEvent | TouchEvent): boolean;
1000
- protected _mouseClick(evt: MouseEvent | TouchEvent): boolean;
1001
- protected _contextMenu(evt: MouseEvent): boolean;
1002
- protected _touchMove(evt: TouchEvent): boolean;
1003
- protected _touchStart(evt: TouchEvent): boolean;
1004
- protected _keyDown(evt: KeyboardEvent): boolean;
1005
- protected _keyUp(evt: KeyboardEvent): boolean;
1006
- protected _keyboardAction(type: string, evt: KeyboardEvent): void;
1069
+ declare class HTMLForm extends VisualForm {
1070
+ protected _style: {
1071
+ filled: boolean;
1072
+ stroked: boolean;
1073
+ background: string;
1074
+ "border-color": string;
1075
+ color: string;
1076
+ "border-width": string;
1077
+ "border-radius": string;
1078
+ "border-style": string;
1079
+ opacity: number;
1080
+ position: string;
1081
+ top: number;
1082
+ left: number;
1083
+ width: number;
1084
+ height: number;
1085
+ };
1086
+ protected _ctx: DOMFormContext;
1087
+ static groupID: number;
1088
+ static domID: number;
1089
+ protected _space: HTMLSpace;
1090
+ protected _ready: boolean;
1091
+ constructor(space: HTMLSpace);
1092
+ get space(): HTMLSpace;
1093
+ protected styleTo(k: any, v: any, unit?: string): void;
1094
+ alpha(a: number): this;
1095
+ fill(c: string | boolean): this;
1096
+ stroke(c: string | boolean, width?: number, linejoin?: string, linecap?: string): this;
1097
+ fillText(c: string): this;
1098
+ cls(c: string | boolean): this;
1099
+ font(sizeOrFont: number | Font, weight?: string, style?: string, lineHeight?: number, family?: string): this;
1100
+ reset(): this;
1101
+ updateScope(group_id: string, group?: Element): object;
1102
+ scope(item: IPlayer): object;
1103
+ nextID(): string;
1104
+ static getID(ctx: any): string;
1105
+ static scopeID(item: IPlayer): string;
1106
+ static style(elem: Element, styles: object): Element;
1107
+ static rectStyle(ctx: DOMFormContext, pt: PtLike, size: PtLike): DOMFormContext;
1108
+ static textStyle(ctx: DOMFormContext, pt: PtLike): DOMFormContext;
1109
+ static point(ctx: DOMFormContext, pt: PtLike, radius?: number, shape?: string): Element;
1110
+ point(pt: PtLike, radius?: number, shape?: string): this;
1111
+ static circle(ctx: DOMFormContext, pt: PtLike, radius?: number): Element;
1112
+ circle(pts: GroupLike | number[][]): this;
1113
+ static square(ctx: DOMFormContext, pt: PtLike, halfsize: number): HTMLElement;
1114
+ square(pt: PtLike, halfsize: number): this;
1115
+ static rect(ctx: DOMFormContext, pts: PtLikeIterable): Element;
1116
+ rect(pts: PtLikeIterable): this;
1117
+ static text(ctx: DOMFormContext, pt: PtLike, txt: string): Element;
1118
+ text(pt: PtLike, txt: string): this;
1119
+ log(txt: any): this;
1120
+ arc(pt: PtLike, radius: number, startAngle: number, endAngle: number, cc?: boolean): this;
1121
+ line(pts: GroupLike | number[][]): this;
1122
+ polygon(pts: GroupLike | number[][]): this;
1007
1123
  }
1008
1124
 
1009
- export class SVGSpace extends DOMSpace {
1125
+ /*! Pts.js is licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
1126
+
1127
+ declare class SVGSpace extends DOMSpace {
1010
1128
  protected _bgcolor: string;
1011
1129
  constructor(elem: string | Element, callback?: Function);
1012
1130
  getForm(): SVGForm;
@@ -1016,7 +1134,7 @@ export class SVGSpace extends DOMSpace {
1016
1134
  remove(player: IPlayer): this;
1017
1135
  removeAll(): this;
1018
1136
  }
1019
- export class SVGForm extends VisualForm {
1137
+ declare class SVGForm extends VisualForm {
1020
1138
  protected _style: {
1021
1139
  filled: boolean;
1022
1140
  stroked: boolean;
@@ -1071,258 +1189,178 @@ export class SVGForm extends VisualForm {
1071
1189
  log(txt: any): this;
1072
1190
  }
1073
1191
 
1074
- export interface IPt {
1075
- x?: number;
1076
- y?: number;
1077
- z?: number;
1078
- w?: number;
1079
- }
1080
- export type PtLike = Pt | Float32Array | number[];
1081
- export type GroupLike = Group | Pt[];
1082
- export type PtLikeIterable = GroupLike | PtLike[] | Iterable<PtLike>;
1083
- export type PtIterable = GroupLike | Pt[] | Iterable<Pt>;
1084
- export type AnimateCallbackFn = (time?: number, frameTime?: number, currentSpace?: any) => void;
1085
- export interface IPlayer {
1086
- animateID?: string;
1087
- animate?: AnimateCallbackFn;
1088
- resize?(bound: Bound, evt?: Event): void;
1089
- action?(type: string, px: number, py: number, evt: Event): void;
1090
- start?(bound: Bound, space: Space): void;
1091
- }
1092
- export interface ISpacePlayers {
1093
- [key: string]: IPlayer;
1094
- }
1095
- export interface ITimer {
1096
- prev: number;
1097
- diff: number;
1098
- end: number;
1099
- min: number;
1100
- }
1101
- export type TouchPointsKey = "touches" | "changedTouches" | "targetTouches";
1102
- export interface MultiTouchElement {
1103
- addEventListener(evt: any, callback: Function): any;
1104
- removeEventListener(evt: any, callback: Function): any;
1105
- }
1106
- export interface PtsCanvasRenderingContext2D extends CanvasRenderingContext2D {
1107
- webkitBackingStorePixelRatio?: number;
1108
- mozBackingStorePixelRatio?: number;
1109
- msBackingStorePixelRatio?: number;
1110
- oBackingStorePixelRatio?: number;
1111
- backingStorePixelRatio?: number;
1112
- }
1113
- export type CanvasSpaceOptions = {
1114
- bgcolor?: string;
1115
- resize?: boolean;
1116
- retina?: boolean;
1117
- offscreen?: boolean;
1118
- pixelDensity?: number;
1119
- };
1120
- export type ColorType = "rgb" | "hsl" | "hsb" | "lab" | "lch" | "luv" | "xyz";
1121
- export type DelaunayShape = {
1122
- i: number;
1123
- j: number;
1124
- k: number;
1125
- triangle: GroupLike;
1126
- circle: Group;
1127
- };
1128
- export type DelaunayMesh = {
1129
- [key: string]: DelaunayShape;
1130
- }[];
1131
- export type DOMFormContext = {
1132
- group: Element;
1133
- groupID: string;
1134
- groupCount: number;
1135
- currentID: string;
1136
- currentClass?: string;
1137
- style: object;
1138
- };
1139
- export type IntersectContext = {
1140
- which: number;
1141
- dist: number;
1142
- normal: Pt;
1143
- vertex: Pt;
1144
- edge: Group;
1145
- other?: any;
1146
- };
1147
- export type UIHandler = (target: UI, pt: PtLike, type: string, evt: MouseEvent) => void;
1148
- export type WarningType = "error" | "warn" | "mute";
1149
- export type ITempoStartFn = (count: number) => void | boolean;
1150
- export type ITempoProgressFn = (count: number, t: number, ms: number, start: boolean) => void | boolean;
1151
- export type ITempoListener = {
1152
- name?: string;
1153
- beats?: number | number[];
1154
- period?: number;
1155
- duration?: number;
1156
- offset?: number;
1157
- continuous?: boolean;
1158
- index?: number;
1159
- fn: Function;
1160
- };
1161
- export type ITempoResponses = {
1162
- start: (fn: ITempoStartFn, offset: number, name?: string) => string;
1163
- progress: (fn: ITempoProgressFn, offset: number, name?: string) => string;
1164
- };
1165
- export type ISoundAnalyzer = {
1166
- node: AnalyserNode;
1167
- size: number;
1168
- data: Uint8Array;
1169
- };
1170
- export type SoundType = "file" | "gen" | "input";
1171
- export type DefaultFormStyle = {
1172
- fillStyle?: string | CanvasGradient | CanvasPattern;
1173
- strokeStyle?: string | CanvasGradient | CanvasPattern;
1174
- lineWidth?: number;
1175
- lineJoin?: string;
1176
- lineCap?: string;
1177
- globalAlpha?: number;
1178
- };
1179
- export type CanvasPatternRepetition = "repeat" | "repeat-x" | "repeat-y" | "no-repeat";
1192
+ /*! Pts.js is licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
1180
1193
 
1181
- export class Typography {
1194
+ declare class Typography {
1182
1195
  static textWidthEstimator(fn: (string: any) => number, samples?: string[], distribution?: number[]): (string: any) => number;
1183
1196
  static truncate(fn: (string: any) => number, str: string, width: number, tail?: string): [string, number];
1184
1197
  static fontSizeToBox(box: PtLikeIterable, ratio?: number, byHeight?: boolean): (GroupLike: any) => number;
1185
1198
  static fontSizeToThreshold(threshold: number, direction?: number): (a: number, b: number) => number;
1186
1199
  }
1187
-
1188
- export default function (seed: string): {
1189
- random(): number;
1190
- };
1191
-
1192
- export const UIShape: {
1193
- rectangle: string;
1194
- circle: string;
1195
- polygon: string;
1196
- polyline: string;
1197
- line: string;
1198
- };
1199
- export const UIPointerActions: {
1200
- up: string;
1201
- down: string;
1202
- move: string;
1203
- drag: string;
1204
- uidrag: string;
1205
- drop: string;
1206
- uidrop: string;
1207
- over: string;
1208
- out: string;
1209
- enter: string;
1210
- leave: string;
1211
- click: string;
1212
- keydown: string;
1213
- keyup: string;
1214
- contextmenu: string;
1215
- all: string;
1216
- };
1217
- export class UI {
1218
- _group: Group;
1219
- _shape: string;
1220
- protected static _counter: number;
1221
- protected _id: string;
1222
- protected _actions: {
1223
- [type: string]: UIHandler[];
1224
- };
1225
- protected _states: {
1226
- [key: string]: any;
1227
- };
1228
- protected _holds: Map<number, string>;
1229
- constructor(group: PtLikeIterable, shape: string, states?: {
1230
- [key: string]: any;
1231
- }, id?: string);
1232
- static fromRectangle(group: PtLikeIterable, states: {}, id?: string): UI;
1233
- static fromCircle(group: PtLikeIterable, states: {}, id?: string): UI;
1234
- static fromPolygon(group: PtLikeIterable, states: {}, id?: string): UI;
1235
- static fromUI(ui: UI, states?: object, id?: string): UI;
1236
- get id(): string;
1237
- set id(d: string);
1238
- get group(): Group;
1239
- set group(d: Group);
1240
- get shape(): string;
1241
- set shape(d: string);
1242
- state(key: string, value?: any): any;
1243
- on(type: string, fn: UIHandler): number;
1244
- off(type: string, which?: number): boolean;
1245
- listen(type: string, p: PtLike, evt: MouseEvent): boolean;
1246
- protected hold(type: string): number;
1247
- protected unhold(key?: number): void;
1248
- static track(uis: UI[], type: string, p: PtLike, evt: MouseEvent): void;
1249
- render(fn: (group: Group, states: {
1250
- [key: string]: any;
1251
- }) => void): void;
1200
+
1201
+ /*! Pts.js is licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
1202
+
1203
+ declare class World {
1204
+ private _lastTime;
1205
+ protected _gravity: Pt;
1206
+ protected _friction: number;
1207
+ protected _damping: number;
1208
+ protected _bound: Bound;
1209
+ protected _particles: Particle[];
1210
+ protected _bodies: Body[];
1211
+ protected _pnames: string[];
1212
+ protected _bnames: string[];
1213
+ protected _drawParticles: (p: Particle, i: number) => void;
1214
+ protected _drawBodies: (p: Body, i: number) => void;
1215
+ constructor(bound: PtIterable, friction?: number, gravity?: PtLike | number);
1216
+ get bound(): Bound;
1217
+ set bound(bound: Bound);
1218
+ get gravity(): Pt;
1219
+ set gravity(g: Pt);
1220
+ get friction(): number;
1221
+ set friction(f: number);
1222
+ get damping(): number;
1223
+ set damping(f: number);
1224
+ get bodyCount(): number;
1225
+ get particleCount(): number;
1226
+ body(id: number | string): any;
1227
+ particle(id: number | string): any;
1228
+ bodyIndex(name: string): number;
1229
+ particleIndex(name: string): number;
1230
+ update(ms: number): void;
1231
+ drawParticles(fn: (p: Particle, i: number) => void): void;
1232
+ drawBodies(fn: (p: Body, i: number) => void): void;
1233
+ add(p: Particle | Body, name?: string): this;
1234
+ private _index;
1235
+ removeBody(from: number | string, count?: number): this;
1236
+ removeParticle(from: number | string, count?: number): this;
1237
+ static edgeConstraint(p1: Particle, p2: Particle, dist: number, stiff?: number, precise?: boolean): Particle;
1238
+ static boundConstraint(p: Particle, rect: PtIterable, damping?: number): void;
1239
+ protected integrate(p: Particle, dt: number, prevDt?: number): Particle;
1240
+ protected _updateParticles(dt: number): void;
1241
+ protected _updateBodies(dt: number): void;
1242
+ }
1243
+ declare class Particle extends Pt {
1244
+ protected _mass: number;
1245
+ protected _radius: number;
1246
+ protected _force: Pt;
1247
+ protected _prev: Pt;
1248
+ protected _body: Body;
1249
+ protected _lock: boolean;
1250
+ protected _lockPt: Pt;
1251
+ constructor(...args: any[]);
1252
+ get mass(): number;
1253
+ set mass(m: number);
1254
+ get radius(): number;
1255
+ set radius(f: number);
1256
+ get previous(): Pt;
1257
+ set previous(p: Pt);
1258
+ get force(): Pt;
1259
+ set force(g: Pt);
1260
+ get body(): Body;
1261
+ set body(b: Body);
1262
+ get lock(): boolean;
1263
+ set lock(b: boolean);
1264
+ get changed(): Pt;
1265
+ set position(p: Pt);
1266
+ size(r: number): this;
1267
+ addForce(...args: any[]): Pt;
1268
+ verlet(dt: number, friction: number, lastDt?: number): this;
1269
+ hit(...args: any[]): this;
1270
+ collide(p2: Particle, damp?: number): void;
1252
1271
  toString(): string;
1253
- protected _within(p: PtLike): boolean;
1254
- protected static _trigger(fns: UIHandler[], target: UI, pt: PtLike, type: string, evt: MouseEvent): void;
1255
- protected static _addHandler(fns: UIHandler[], fn: UIHandler): number;
1256
- protected static _removeHandler(fns: UIHandler[], index: number): boolean;
1257
- }
1258
- export class UIButton extends UI {
1259
- constructor(group: PtLikeIterable, shape: string, states?: {
1260
- [key: string]: any;
1261
- }, id?: string);
1262
- onClick(fn: UIHandler): number;
1263
- offClick(id: number): boolean;
1264
- onContextMenu(fn: UIHandler): number;
1265
- offContextMenu(id: number): boolean;
1266
- onHover(enter?: UIHandler, leave?: UIHandler): number[];
1267
- offHover(enterID?: number, leaveID?: number): boolean[];
1268
1272
  }
1269
- export class UIDragger extends UIButton {
1270
- constructor(group: PtLikeIterable, shape: string, states?: {
1271
- [key: string]: any;
1272
- }, id?: string);
1273
- onDrag(fn: UIHandler): number;
1274
- offDrag(id: number): boolean;
1275
- onDrop(fn: UIHandler): number;
1276
- offDrop(id: number): boolean;
1273
+ declare class Body extends Group {
1274
+ protected _cs: Array<number[]>;
1275
+ protected _stiff: number;
1276
+ protected _locks: {
1277
+ [index: string]: Particle;
1278
+ };
1279
+ protected _mass: number;
1280
+ constructor();
1281
+ static fromGroup(body: PtIterable, stiff?: number, autoLink?: boolean, autoMass?: boolean): Body;
1282
+ init(body: PtIterable, stiff?: number): this;
1283
+ get mass(): number;
1284
+ set mass(m: number);
1285
+ autoMass(): this;
1286
+ link(index1: number, index2: number, stiff?: number): this;
1287
+ linkAll(stiff: number): void;
1288
+ linksToLines(): Group[];
1289
+ processEdges(): void;
1290
+ processBody(b: Body): void;
1291
+ processParticle(b: Particle): void;
1277
1292
  }
1278
1293
 
1279
- export const Const: {
1280
- xy: string;
1281
- yz: string;
1282
- xz: string;
1283
- xyz: string;
1284
- horizontal: number;
1285
- vertical: number;
1286
- identical: number;
1287
- right: number;
1288
- bottom_right: number;
1289
- bottom: number;
1290
- bottom_left: number;
1291
- left: number;
1292
- top_left: number;
1293
- top: number;
1294
- top_right: number;
1295
- epsilon: number;
1296
- max: number;
1297
- min: number;
1298
- pi: number;
1299
- two_pi: number;
1300
- half_pi: number;
1301
- quarter_pi: number;
1302
- one_degree: number;
1303
- rad_to_deg: number;
1304
- deg_to_rad: number;
1305
- gravity: number;
1306
- newton: number;
1307
- gaussian: number;
1308
- };
1309
- export class Util {
1310
- static _warnLevel: WarningType;
1311
- static warnLevel(lv?: WarningType): WarningType;
1312
- static getArgs(args: any[]): Array<number>;
1313
- static warn(message?: string, defaultReturn?: any): any;
1314
- static randomInt(range: number, start?: number): number;
1315
- static split(pts: any[], size: number, stride?: number, loopBack?: boolean, matchSize?: boolean): any[][];
1316
- static flatten(pts: any[], flattenAsGroup?: boolean): any;
1317
- static combine<T>(a: T[], b: T[], op: (a: T, b: T) => T): T[];
1318
- static zip(arrays: Array<any>[]): any[];
1319
- static stepper(max: number, min?: number, stride?: number, callback?: (n: number) => void): (() => number);
1320
- static forRange(fn: (index: number) => any, range: number, start?: number, step?: number): any[];
1321
- static load(url: string, callback: (response: string, success: boolean) => void): void;
1322
- static download(space: CanvasSpace, filename?: string, filetype?: ("jpeg" | "jpg" | "png" | "webp"), quality?: number): void;
1323
- static performance(avgFrames?: number): () => number;
1324
- static arrayCheck(pts: PtLikeIterable, minRequired?: number): boolean;
1325
- static iterToArray(it: Iterable<any>): any[];
1326
- static isMobile(): boolean;
1294
+ declare class Tempo implements IPlayer {
1295
+ protected _bpm: number;
1296
+ protected _ms: number;
1297
+ protected _listeners: {
1298
+ [key: string]: ITempoListener;
1299
+ };
1300
+ protected _listenerInc: number;
1301
+ animateID: string;
1302
+ constructor(bpm: number);
1303
+ static fromBeat(ms: number): Tempo;
1304
+ get bpm(): number;
1305
+ set bpm(n: number);
1306
+ get ms(): number;
1307
+ set ms(n: number);
1308
+ protected _createID(listener: ITempoListener | Function): string;
1309
+ every(beats: number | number[]): ITempoResponses;
1310
+ track(time: any): void;
1311
+ stop(name: string): void;
1312
+ animate(time: any, ftime: any): void;
1313
+ resize(bound: Bound, evt?: Event): void;
1314
+ action(type: string, px: number, py: number, evt: Event): void;
1315
+ }
1316
+ declare class Sound {
1317
+ private _type;
1318
+ _ctx: AudioContext;
1319
+ _node: AudioNode;
1320
+ _outputNode: AudioNode;
1321
+ _stream: MediaStream;
1322
+ _source: HTMLMediaElement;
1323
+ _buffer: AudioBuffer;
1324
+ analyzer: ISoundAnalyzer;
1325
+ protected _playing: boolean;
1326
+ protected _timestamp: number;
1327
+ constructor(type: SoundType);
1328
+ static from(node: AudioNode, ctx: AudioContext, type?: SoundType, stream?: MediaStream): Sound;
1329
+ static load(source: HTMLMediaElement | string, crossOrigin?: string): Promise<Sound>;
1330
+ static loadAsBuffer(url: string): Promise<Sound>;
1331
+ protected createBuffer(buf: AudioBuffer): this;
1332
+ static generate(type: OscillatorType, val: number | PeriodicWave): Sound;
1333
+ protected _gen(type: OscillatorType, val: number | PeriodicWave): Sound;
1334
+ static input(constraint?: MediaStreamConstraints): Promise<Sound>;
1335
+ get ctx(): AudioContext;
1336
+ get node(): AudioNode;
1337
+ get outputNode(): AudioNode;
1338
+ get stream(): MediaStream;
1339
+ get source(): HTMLMediaElement;
1340
+ get buffer(): AudioBuffer;
1341
+ set buffer(b: AudioBuffer);
1342
+ get type(): SoundType;
1343
+ get playing(): boolean;
1344
+ get progress(): number;
1345
+ get playable(): boolean;
1346
+ get binSize(): number;
1347
+ get sampleRate(): number;
1348
+ get frequency(): number;
1349
+ set frequency(f: number);
1350
+ connect(node: AudioNode): this;
1351
+ setOutputNode(outputNode: AudioNode): this;
1352
+ removeOutputNode(): this;
1353
+ analyze(size?: number, minDb?: number, maxDb?: number, smooth?: number): this;
1354
+ protected _domain(time: boolean): Uint8Array;
1355
+ protected _domainTo(time: boolean, size: PtLike, position?: PtLike, trim?: number[]): Group;
1356
+ timeDomain(): Uint8Array;
1357
+ timeDomainTo(size: PtLike, position?: PtLike, trim?: number[]): Group;
1358
+ freqDomain(): Uint8Array;
1359
+ freqDomainTo(size: PtLike, position?: PtLike, trim?: number[]): Group;
1360
+ reset(): this;
1361
+ start(timeAt?: number): this;
1362
+ stop(): this;
1363
+ toggle(): this;
1327
1364
  }
1328
1365
 
1366
+ export { Body, Bound, CanvasForm, CanvasSpace, Circle, Color, Const, Create, Curve, DOMSpace, Delaunay, Font, Form, Geom, Group, HTMLForm, HTMLSpace, Img, Line, Mat, MultiTouchSpace, Noise, Num, Particle, Polygon, Pt, Range, Rectangle, SVGForm, SVGSpace, Shaping, Sound, Space, Tempo, Triangle, Typography, UI, UIButton, UIDragger, UIPointerActions, UIShape, Util, Vec, VisualForm, World };