pts 0.11.5 → 0.12.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.
- package/.eslintignore +5 -0
- package/.eslintrc.js +52 -0
- package/dist/index.d.mts +1380 -0
- package/dist/index.d.ts +31 -27
- package/dist/index.js +726 -707
- package/dist/index.mjs +726 -707
- package/dist/pts.js +727 -708
- package/dist/pts.min.js +4 -4
- package/dist/pts.min.js.map +1 -1
- package/package.json +10 -5
package/dist/index.d.ts
CHANGED
|
@@ -22,6 +22,8 @@ declare const UIPointerActions: {
|
|
|
22
22
|
click: string;
|
|
23
23
|
keydown: string;
|
|
24
24
|
keyup: string;
|
|
25
|
+
pointerdown: string;
|
|
26
|
+
pointerup: string;
|
|
25
27
|
contextmenu: string;
|
|
26
28
|
all: string;
|
|
27
29
|
};
|
|
@@ -100,11 +102,11 @@ interface IPt {
|
|
|
100
102
|
z?: number;
|
|
101
103
|
w?: number;
|
|
102
104
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
105
|
+
type PtLike = Pt | Float32Array | number[];
|
|
106
|
+
type GroupLike = Group | Pt[];
|
|
107
|
+
type PtIterable = GroupLike | Pt[] | Iterable<Pt>;
|
|
108
|
+
type PtLikeIterable = GroupLike | PtLike[] | Iterable<PtLike>;
|
|
109
|
+
type AnimateCallbackFn = (time?: number, frameTime?: number, currentSpace?: any) => void;
|
|
108
110
|
interface IPlayer {
|
|
109
111
|
animateID?: string;
|
|
110
112
|
animate?: AnimateCallbackFn;
|
|
@@ -121,7 +123,7 @@ interface ITimer {
|
|
|
121
123
|
end: number;
|
|
122
124
|
min: number;
|
|
123
125
|
}
|
|
124
|
-
|
|
126
|
+
type TouchPointsKey = "touches" | "changedTouches" | "targetTouches";
|
|
125
127
|
interface MultiTouchElement {
|
|
126
128
|
addEventListener(evt: any, callback: Function): any;
|
|
127
129
|
removeEventListener(evt: any, callback: Function): any;
|
|
@@ -133,25 +135,25 @@ interface PtsCanvasRenderingContext2D extends CanvasRenderingContext2D {
|
|
|
133
135
|
oBackingStorePixelRatio?: number;
|
|
134
136
|
backingStorePixelRatio?: number;
|
|
135
137
|
}
|
|
136
|
-
|
|
138
|
+
type CanvasSpaceOptions = {
|
|
137
139
|
bgcolor?: string;
|
|
138
140
|
resize?: boolean;
|
|
139
141
|
retina?: boolean;
|
|
140
142
|
offscreen?: boolean;
|
|
141
143
|
pixelDensity?: number;
|
|
142
144
|
};
|
|
143
|
-
|
|
144
|
-
|
|
145
|
+
type ColorType = "rgb" | "hsl" | "hsb" | "lab" | "lch" | "luv" | "xyz";
|
|
146
|
+
type DelaunayShape = {
|
|
145
147
|
i: number;
|
|
146
148
|
j: number;
|
|
147
149
|
k: number;
|
|
148
150
|
triangle: GroupLike;
|
|
149
151
|
circle: Group;
|
|
150
152
|
};
|
|
151
|
-
|
|
153
|
+
type DelaunayMesh = {
|
|
152
154
|
[key: string]: DelaunayShape;
|
|
153
155
|
}[];
|
|
154
|
-
|
|
156
|
+
type DOMFormContext = {
|
|
155
157
|
group: Element;
|
|
156
158
|
groupID: string;
|
|
157
159
|
groupCount: number;
|
|
@@ -159,7 +161,7 @@ declare type DOMFormContext = {
|
|
|
159
161
|
currentClass?: string;
|
|
160
162
|
style: object;
|
|
161
163
|
};
|
|
162
|
-
|
|
164
|
+
type IntersectContext = {
|
|
163
165
|
which: number;
|
|
164
166
|
dist: number;
|
|
165
167
|
normal: Pt;
|
|
@@ -167,11 +169,11 @@ declare type IntersectContext = {
|
|
|
167
169
|
edge: Group;
|
|
168
170
|
other?: any;
|
|
169
171
|
};
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
172
|
+
type UIHandler = (target: UI, pt: PtLike, type: string, evt: MouseEvent) => void;
|
|
173
|
+
type WarningType = "error" | "warn" | "mute";
|
|
174
|
+
type ITempoStartFn = (count: number) => void | boolean;
|
|
175
|
+
type ITempoProgressFn = (count: number, t: number, ms: number, start: boolean) => void | boolean;
|
|
176
|
+
type ITempoListener = {
|
|
175
177
|
name?: string;
|
|
176
178
|
beats?: number | number[];
|
|
177
179
|
period?: number;
|
|
@@ -181,17 +183,17 @@ declare type ITempoListener = {
|
|
|
181
183
|
index?: number;
|
|
182
184
|
fn: Function;
|
|
183
185
|
};
|
|
184
|
-
|
|
186
|
+
type ITempoResponses = {
|
|
185
187
|
start: (fn: ITempoStartFn, offset: number, name?: string) => string;
|
|
186
188
|
progress: (fn: ITempoProgressFn, offset: number, name?: string) => string;
|
|
187
189
|
};
|
|
188
|
-
|
|
190
|
+
type ISoundAnalyzer = {
|
|
189
191
|
node: AnalyserNode;
|
|
190
192
|
size: number;
|
|
191
193
|
data: Uint8Array;
|
|
192
194
|
};
|
|
193
|
-
|
|
194
|
-
|
|
195
|
+
type SoundType = "file" | "gen" | "input";
|
|
196
|
+
type DefaultFormStyle = {
|
|
195
197
|
fillStyle?: string | CanvasGradient | CanvasPattern;
|
|
196
198
|
strokeStyle?: string | CanvasGradient | CanvasPattern;
|
|
197
199
|
lineWidth?: number;
|
|
@@ -199,7 +201,7 @@ declare type DefaultFormStyle = {
|
|
|
199
201
|
lineCap?: string;
|
|
200
202
|
globalAlpha?: number;
|
|
201
203
|
};
|
|
202
|
-
|
|
204
|
+
type CanvasPatternRepetition = "repeat" | "repeat-x" | "repeat-y" | "no-repeat";
|
|
203
205
|
|
|
204
206
|
/*! Pts.js is licensed under Apache License 2.0. Copyright © 2017-current William Ngan and contributors. (https://github.com/williamngan/pts) */
|
|
205
207
|
|
|
@@ -464,9 +466,11 @@ declare abstract class MultiTouchSpace extends Space {
|
|
|
464
466
|
bindTouch(bind?: boolean, passive?: boolean, customTarget?: Element): this;
|
|
465
467
|
bindKeyboard(bind?: boolean): this;
|
|
466
468
|
touchesToPoints(evt: TouchEvent, which?: TouchPointsKey): Pt[];
|
|
467
|
-
protected _mouseAction(type: string, evt: MouseEvent | TouchEvent): void;
|
|
469
|
+
protected _mouseAction(type: string, evt: MouseEvent | TouchEvent | PointerEvent): void;
|
|
468
470
|
protected _mouseDown(evt: MouseEvent | TouchEvent): boolean;
|
|
471
|
+
protected _pointerDown(evt: PointerEvent): boolean;
|
|
469
472
|
protected _mouseUp(evt: MouseEvent | TouchEvent): boolean;
|
|
473
|
+
protected _pointerUp(evt: PointerEvent): boolean;
|
|
470
474
|
protected _mouseMove(evt: MouseEvent | TouchEvent): boolean;
|
|
471
475
|
protected _mouseOver(evt: MouseEvent | TouchEvent): boolean;
|
|
472
476
|
protected _mouseOut(evt: MouseEvent | TouchEvent): boolean;
|
|
@@ -548,7 +552,7 @@ declare class Img {
|
|
|
548
552
|
static loadPattern(src: string, space: CanvasSpace, repeat?: CanvasPatternRepetition, editable?: boolean): Promise<CanvasPattern>;
|
|
549
553
|
static blank(size: PtLike, space: CanvasSpace, scale?: number): Img;
|
|
550
554
|
load(src: string): Promise<Img>;
|
|
551
|
-
protected _drawToScale(canvasScale: number | PtLike, img:
|
|
555
|
+
protected _drawToScale(canvasScale: number | PtLike, img: HTMLImageElement | HTMLCanvasElement | ImageBitmap | OffscreenCanvas | HTMLVideoElement): void;
|
|
552
556
|
initCanvas(width: number, height: number, canvasScale?: number | PtLike): void;
|
|
553
557
|
bitmap(size?: PtLike): Promise<ImageBitmap>;
|
|
554
558
|
pattern(reptition?: CanvasPatternRepetition, dynamic?: boolean): CanvasPattern;
|
|
@@ -1232,8 +1236,8 @@ declare class World {
|
|
|
1232
1236
|
set iterations(f: number);
|
|
1233
1237
|
get bodyCount(): number;
|
|
1234
1238
|
get particleCount(): number;
|
|
1235
|
-
body(id: number | string):
|
|
1236
|
-
particle(id: number | string):
|
|
1239
|
+
body(id: number | string): Body;
|
|
1240
|
+
particle(id: number | string): Particle;
|
|
1237
1241
|
bodyIndex(name: string): number;
|
|
1238
1242
|
particleIndex(name: string): number;
|
|
1239
1243
|
update(ms: number): void;
|
|
@@ -1373,4 +1377,4 @@ declare class Sound {
|
|
|
1373
1377
|
toggle(): this;
|
|
1374
1378
|
}
|
|
1375
1379
|
|
|
1376
|
-
export { AnimateCallbackFn, Body, Bound, CanvasForm, CanvasPatternRepetition, CanvasSpace, CanvasSpaceOptions, Circle, Color, ColorType, Const, Create, Curve, DOMFormContext, DOMSpace, DefaultFormStyle, Delaunay, DelaunayMesh, DelaunayShape, Font, Form, Geom, Group, GroupLike, HTMLForm, HTMLSpace, IPlayer, IPt, ISoundAnalyzer, ISpacePlayers, ITempoListener, ITempoProgressFn, ITempoResponses, ITempoStartFn, ITimer, Img, IntersectContext, Line, Mat, MultiTouchElement, MultiTouchSpace, Noise, Num, Particle, Polygon, Pt, PtIterable, PtLike, PtLikeIterable, PtsCanvasRenderingContext2D, Range, Rectangle, SVGForm, SVGSpace, Shaping, Sound, SoundType, Space, Tempo, TouchPointsKey, Triangle, Typography, UI, UIButton, UIDragger, UIHandler, UIPointerActions, UIShape, Util, Vec, VisualForm, WarningType, World };
|
|
1380
|
+
export { type AnimateCallbackFn, Body, Bound, CanvasForm, type CanvasPatternRepetition, CanvasSpace, type CanvasSpaceOptions, Circle, Color, type ColorType, Const, Create, Curve, type DOMFormContext, DOMSpace, type DefaultFormStyle, Delaunay, type DelaunayMesh, type DelaunayShape, Font, Form, Geom, Group, type GroupLike, HTMLForm, HTMLSpace, type IPlayer, type IPt, type ISoundAnalyzer, type ISpacePlayers, type ITempoListener, type ITempoProgressFn, type ITempoResponses, type ITempoStartFn, type ITimer, Img, type IntersectContext, Line, Mat, type MultiTouchElement, MultiTouchSpace, Noise, Num, Particle, Polygon, Pt, type PtIterable, type PtLike, type PtLikeIterable, type PtsCanvasRenderingContext2D, Range, Rectangle, SVGForm, SVGSpace, Shaping, Sound, type SoundType, Space, Tempo, type TouchPointsKey, Triangle, Typography, UI, UIButton, UIDragger, type UIHandler, UIPointerActions, UIShape, Util, Vec, VisualForm, type WarningType, World };
|