This repository has been archived by the owner on Jul 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
/
index.d.ts
87 lines (71 loc) · 2.85 KB
/
index.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
// Type definitions for D3JS d3-voronoi module v1.0.2
// Project: https://github.com/d3/d3-voronoi/
// Definitions by: Tom Wanzek <https://github.com/tomwanzek>, Alex Ford <https://github.com/gustavderdrache>, Boris Yankov <https://github.com/borisyankov>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// --------------------------------------------------------------------------
// Shared Type Definitions and Interfaces
// --------------------------------------------------------------------------
/**
* The VoronoiPoint interface is defined as a cue that the array is strictly of type [number, number] with two elements
* for x and y coordinates. However, it is used as a base for interface definitions, and [number, number]
* cannot be extended.
*/
export interface VoronoiPoint extends Array<number> {
0: number;
1: number;
}
/**
* The VoronoiPointPair interface is defined as a cue that the array is strictly of type [[number, number], [number, number]] with two elements, one
* for each point containing the respective x and y coordinates. However, it is used as a base for interface definitions, and
* [[number, number], [number, number]] cannot be extended.
*/
export interface VoronoiPointPair extends Array<[number, number]> {
0: [number, number];
1: [number, number];
}
export interface VoronoiPolygon<T> extends Array<[number, number]> {
data: T;
}
export type VoronoiTriangle<T> = [T, T, T];
export interface VoronoiSite<T> extends VoronoiPoint {
index: number;
data: T;
}
export interface VoronoiCell<T> {
site: VoronoiSite<T>;
halfEdges: Array<number>;
}
export interface VoronoiEdge<T> extends VoronoiPointPair {
left: VoronoiSite<T>;
right: VoronoiSite<T> | null;
}
export interface VoronoiLink<T> {
source: T;
target: T;
}
export interface VoronoiLayout<T> {
(data: Array<T>): VoronoiDiagram<T>;
x(): (d: T) => number;
x(x: (d: T) => number): this;
y(): (d: T) => number;
y(y: (d: T) => number): this;
extent(): [[number, number], [number, number]] | null;
extent(extent: [[number, number], [number, number]]): this;
size(): [number, number] | null;
size(size: [number, number]): this;
polygons(data: Array<T>): Array<VoronoiPolygon<T>>;
triangles(data: Array<T>): Array<VoronoiTriangle<T>>;
links(data: Array<T>): Array<VoronoiLink<T>>;
}
export interface VoronoiDiagram<T> {
edges: Array<VoronoiEdge<T>>;
cells: Array<VoronoiCell<T> | null>;
polygons(): Array<VoronoiPolygon<T>>;
triangles(): Array<VoronoiTriangle<T>>;
links(): Array<VoronoiLink<T>>;
}
// --------------------------------------------------------------------------
// voronoi Export
// --------------------------------------------------------------------------
export function voronoi(): VoronoiLayout<[number, number]>;
export function voronoi<T>(): VoronoiLayout<T>;