-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlib.d.ts
62 lines (49 loc) · 1.8 KB
/
lib.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/** @file "plot.js" */
class Plotter {
cnv: HTMLCanvasElement;
ctx: CanvasRenderingContext2D;
constructor(canvas: HTMLCanvasElement);
PlotFunction(func: (x: number) => number, opts: object);
PlotBuffer(buf: ArrayLike<number>, opts: object);
CreateLegend(): Legend;
RegisterLegendLabel(legend: Legend, name: string, color: string): number;
DrawLegend(legend: Legend, pos: {x: number, y: number});
}
interface Legend {
labels: string[];
colors: string[];
}
/** @file "playfield.js" */
interface PlayfieldModule {
name: string;
canvas: HTMLCanvasElement;
init?();
render?(dt: number);
}
interface Playfield {
register_experiment(name: string, definition: (module: PlayfieldModule) => void);
register_handler<K extends keyof HTMLElementEventMap>(module: PlayfieldModule, event: K, handler: (ev: HTMLElementEventMap[K]) => void);
// This does not throw on missing event handler but logs the error on console.
unregister_handler(module: PlayfieldModule, event: string);
}
declare var Playfield: Playfield;
/** @file "complex.js" */
interface Complex {
re: number;
im: number;
}
function _cmp_add(u: Complex, v: Complex): Complex;
function _cmp_sub(u: Complex, v: Complex): Complex;
function _cmp_mul(u: Complex, v: Complex): Complex;
function _cmp_scale(z: Complex, s: number): Complex;
function _exp_i(th: number): Complex;
function _cmp_buf(buf: ArrayLike<number>, idx: number): Complex;
class CSubarray {
constructor(buf: ArrayLike<number>, start: number, stride: number, size: number);
get(i: number): Complex;
set(i: number, v: Complex);
sub(offset: number, stride: number, size: number): CSubarray;
}
function FFT(src: CSubarray, dst: CSubarray);
function PerformFFT(buf: ArrayLike<number>, offset: number, size: number): Float32Array;
function ConvertComplex2Polar(buf: ArrayLike<number>): Float32Array;