-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwire.mjs
38 lines (35 loc) · 898 Bytes
/
wire.mjs
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
import { Net } from "./net.mjs";
import { Coordinate } from "./coordinate.mjs";
/**
* Class representing a wire.
*
* @param {Net[]} net - the corresponding net/potential
* @param {Coordinate[]} coords - positions of wire "edges"
*/
class Wire {
/**
* Generates a wire.
*
* @param {Net[]} net - the corresponding net/potential
* @param {Coordinate[]} coords - positions of wire "edges"
*/
constructor(net, coords) {
this.net = net;
this.coords = coords || [];
}
/**
* Serializes the wire. The TikZ "source code" is returned.
*
* @param {number} [indent=0] - the indention (= amount of tabs) to use
* @returns {string} the serislized wire
*/
serialize(indent = 0) {
return (
"\t".repeat(indent) +
(global.DEBUG ? "\\draw[Rays-Rays,red] " : "\\draw ") +
this.coords.map((coord) => coord.serializeName()).join(" -- ") +
";"
);
}
}
export { Wire };