forked from tracespace/tracespace
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
155 lines (128 loc) · 2.72 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
// Type definitions for gerber-plotter 4.0
// Project: https://github.com/tracespace/tracespace
// Definitions by: Mike Cousins <https://mike.cousins.io>
/// <reference types="node" />
declare function gerberPlotter(
options: gerberPlotter.Options
): gerberPlotter.Plotter
declare namespace gerberPlotter {
interface Plotter extends NodeJS.ReadWriteStream {
format: {
units: Units
backupUnits: Units
nota: Notation
backupNota: Notation
}
}
interface Options {
units?: Units | null
backupUnits?: Units | null
nota?: Notation | null
backupNota?: Notation | null
optimizePaths?: boolean | null
plotAsOutline?: boolean | number | null
}
type Units = 'mm' | 'in'
type Notation = 'A' | 'I'
type Direction = 'cw' | 'ccw'
type Polarity = 'dark' | 'clear'
type Point = [number, number]
type Offset = [number, number]
type Box = [number, number, number, number]
type ToolId = string
//----------------------------------------------------------------------
// Shape aka Tool
interface Circle {
type: 'circle'
r: number
cx: number
cy: number
}
interface Rect {
type: 'rect'
width: number
height: number
r: number
cx: number
cy: number
}
interface Poly {
type: 'poly'
points: Point[]
}
interface Ring {
type: 'ring'
r: number
width: number
cx: number
cy: number
}
interface Clip {
type: 'clip'
shape: (Rect | Poly)[]
clip: Ring
}
type Shape = Circle | Rect | Poly | Ring
//----------------------------------------------------------------------
// Segments
interface Line {
type: 'line'
start: Point
end: Point
}
interface Arc {
type: 'arc'
start: [number, number, number] // start x,y, angle
end: [number, number, number] // end x,y, angle
center: Point
sweep: number
radius: number
dir: Direction
}
type Segment = Line | Arc
//----------------------------------------------------------------------
// Chunks
interface ChunkShape {
type: 'shape'
tool: ToolId
shape: Shape[]
}
interface ChunkPad {
type: 'pad'
x: number
y: number
tool: ToolId
}
interface ChunkFill {
type: 'fill'
path: Segment[]
}
interface ChunkStroke {
type: 'stroke'
width: number
path: Segment[]
}
interface ChunkPolarity {
type: 'polarity'
polarity: Polarity
}
interface ChunkRepeat {
type: 'repeat'
offsets: Offset[]
box: Box
}
interface ChunkSize {
type: 'size'
box: Box
units: Units
}
type Chunk =
| ChunkShape
| ChunkPad
| ChunkFill
| ChunkStroke
| ChunkPolarity
| ChunkRepeat
| ChunkSize
}
export = gerberPlotter