-
Notifications
You must be signed in to change notification settings - Fork 0
/
ip.js
148 lines (146 loc) · 7.65 KB
/
ip.js
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
var getMetrics = (() => {
function generateMetrics(bounds) {
var width = fixFloat(bounds[1] - bounds[0]);
var height = fixFloat(bounds[3] - bounds[2]);
var origin_x = -bounds[0];
var origin_y = -bounds[2];
var center_x = fixFloat(width/2);
var center_y = fixFloat(height/2);
var offset_x = fixFloat(center_x-origin_x);
var offset_y = fixFloat(center_y-origin_y);
return function() {
return {bounds:[...bounds],width,height,origin:vector(origin_x,origin_y),center:vector(center_x,center_y),offset:vector(offset_x,offset_y)};
}
}
var getMetrics = {
Input: generateMetrics([-1.65, 0.05, -0.85, 0.85]),
Clock: generateMetrics([-1.65, 0.05, -0.85, 0.85]),
Button: generateMetrics([-2, 0.05, -1.2, 0.85]),
ButtonPad: generateMetrics([-7.35, 0.05, -6.85, 0.55]),
SegmentDisplay: generateMetrics([-3.6, 0.6, -7.05, 0.05]),
SevenSegment: generateMetrics([-3.6, 0.6, -7.05, 0.05]),
SixteenSegment: generateMetrics([-3.6, 0.6, -7.05, 0.05]),
Joystick: generateMetrics([-1.975, 1.975, -3.975, -0.025]),
RotaryEncoder: generateMetrics([-2.05, 2.05, -4.05, 0.05]),
Output: generateMetrics([-0.05, 1.65, -0.85, 0.85]),
LED: generateMetrics([-0.05, 1.65, -0.85, 0.85]),
Switch: generateMetrics([-0.05, 2.05, -1.3, 0.1]),
Buffer: generateMetrics([-0.05, 2.05, -1.1, 1.1]),
SmallBuffer: generateMetrics([-0.05, 2.05, -0.785, 0.785]),
Not: generateMetrics([-0.05, 3.05, -1.1, 1.1]),
SmallNot: generateMetrics([-0.05, 2.05, -0.785, 0.785]),
And: generateMetrics([-0.05, 3.05, -0.6, 2.6]),
Or: generateMetrics([-0.05, 3.05, -0.6, 2.6]),
Xor: generateMetrics([-0.05, 3.05, -0.6, 2.6]),
Xand: generateMetrics([-0.05, 3.05, -0.6, 2.6]),
Nand: generateMetrics([-0.05, 4.05, -0.6, 2.6]),
Nor: generateMetrics([-0.05, 4.05, -0.6, 2.6]),
Xnor: generateMetrics([-0.05, 4.05, -0.6, 2.6]),
Xnand: generateMetrics([-0.05, 4.05, -0.6, 2.6]),
WideAnd: generateMetrics([-0.05, 4.05, -0.6, 2.6]),
WideOr: generateMetrics([-0.05, 4.05, -0.6, 2.6]),
WideXor: generateMetrics([-0.05, 4.05, -0.6, 2.6]),
WideXand: generateMetrics([-0.05, 4.05, -0.6, 2.6]),
WideNand: generateMetrics([-0.05, 5.05, -0.6, 2.6]),
WideNor: generateMetrics([-0.05, 5.05, -0.6, 2.6]),
WideXnor: generateMetrics([-0.05, 5.05, -0.6, 2.6]),
WideXnand: generateMetrics([-0.05, 5.05, -0.6, 2.6]),
Majority: generateMetrics([-0.05, 3.05, -0.6, 2.6]),
Minority: generateMetrics([-0.05, 4.05, -0.6, 2.6]),
Xmajority: generateMetrics([-0.05, 3.05, -0.6, 2.6]),
Xminority: generateMetrics([-0.05, 4.05, -0.6, 2.6]),
BufferOC: generateMetrics([-0.05, 2.05, -1.1, 1.1]),
SmallBufferOC: generateMetrics([-0.05, 2.05, -0.785, 0.785]),
NotOC: generateMetrics([-0.05, 3.05, -1.1, 1.1]),
SmallNotOC: generateMetrics([-0.05, 2.05, -0.785, 0.785]),
AndOC: generateMetrics([-0.05, 3.05, -0.6, 2.6]),
OrOC: generateMetrics([-0.05, 3.05, -0.6, 2.6]),
XorOC: generateMetrics([-0.05, 3.05, -0.6, 2.6]),
XandOC: generateMetrics([-0.05, 3.05, -0.6, 2.6]),
NandOC: generateMetrics([-0.05, 4.05, -0.6, 2.6]),
NorOC: generateMetrics([-0.05, 4.05, -0.6, 2.6]),
XnorOC: generateMetrics([-0.05, 4.05, -0.6, 2.6]),
XnandOC: generateMetrics([-0.05, 4.05, -0.6, 2.6]),
WideAndOC: generateMetrics([-0.05, 4.05, -0.6, 2.6]),
WideOrOC: generateMetrics([-0.05, 4.05, -0.6, 2.6]),
WideXorOC: generateMetrics([-0.05, 4.05, -0.6, 2.6]),
WideXandOC: generateMetrics([-0.05, 4.05, -0.6, 2.6]),
WideNandOC: generateMetrics([-0.05, 5.05, -0.6, 2.6]),
WideNorOC: generateMetrics([-0.05, 5.05, -0.6, 2.6]),
WideXnorOC: generateMetrics([-0.05, 5.05, -0.6, 2.6]),
WideXnandOC: generateMetrics([-0.05, 5.05, -0.6, 2.6]),
MajorityOC: generateMetrics([-0.05, 3.05, -0.6, 2.6]),
MinorityOC: generateMetrics([-0.05, 4.05, -0.6, 2.6]),
XmajorityOC: generateMetrics([-0.05, 3.05, -0.6, 2.6]),
XminorityOC: generateMetrics([-0.05, 4.05, -0.6, 2.6]),
BufferOE: generateMetrics([-0.05, 2.05, -1.1, 1.1]),
SmallBufferOE: generateMetrics([-0.05, 2.05, -0.785, 0.785]),
NotOE: generateMetrics([-0.05, 3.05, -1.1, 1.1]),
SmallNotOE: generateMetrics([-0.05, 2.05, -0.785, 0.785]),
AndOE: generateMetrics([-0.05, 3.05, -0.6, 2.6]),
OrOE: generateMetrics([-0.05, 3.05, -0.6, 2.6]),
XorOE: generateMetrics([-0.05, 3.05, -0.6, 2.6]),
XandOE: generateMetrics([-0.05, 3.05, -0.6, 2.6]),
NandOE: generateMetrics([-0.05, 4.05, -0.6, 2.6]),
NorOE: generateMetrics([-0.05, 4.05, -0.6, 2.6]),
XnorOE: generateMetrics([-0.05, 4.05, -0.6, 2.6]),
XnandOE: generateMetrics([-0.05, 4.05, -0.6, 2.6]),
WideAndOE: generateMetrics([-0.05, 4.05, -0.6, 2.6]),
WideOrOE: generateMetrics([-0.05, 4.05, -0.6, 2.6]),
WideXorOE: generateMetrics([-0.05, 4.05, -0.6, 2.6]),
WideXandOE: generateMetrics([-0.05, 4.05, -0.6, 2.6]),
WideNandOE: generateMetrics([-0.05, 5.05, -0.6, 2.6]),
WideNorOE: generateMetrics([-0.05, 5.05, -0.6, 2.6]),
WideXnorOE: generateMetrics([-0.05, 5.05, -0.6, 2.6]),
WideXnandOE: generateMetrics([-0.05, 5.05, -0.6, 2.6]),
MajorityOE: generateMetrics([-0.05, 3.05, -0.6, 2.6]),
MinorityOE: generateMetrics([-0.05, 4.05, -0.6, 2.6]),
XmajorityOE: generateMetrics([-0.05, 3.05, -0.6, 2.6]),
XminorityOE: generateMetrics([-0.05, 4.05, -0.6, 2.6]),
LUT: generateMetrics([-0.05, 3.05, -0.6, 2.6]),
Driver: generateMetrics([-0.05, 2.05, -1.1, 0.785]),
DriverInv: generateMetrics([-0.05, 2.05, -1.1, 0.785]),
Supply: generateMetrics([-0.75, 0.75, -1, 0.05]),
Ground: generateMetrics([-0.75, 0.75, -0.05, 1]),
Constant: generateMetrics([-1.05, 0.05, -0.95, 0.05]),
Tunnel: generateMetrics([-0.1, 0.76, -0.5, 0.5]),
PullUp: generateMetrics([-0.75, 0.75, -3, 0]),
PullDown: generateMetrics([-0.75, 0.75, 0, 3]),
NMOS: generateMetrics([0, 1, -1.025, 1.025]),
PMOS: generateMetrics([0, 1, -1.025, 1.025]),
TransmissionGate: generateMetrics([-0.05, 2.05, -1.1, 1.1]),
NPNBJT: generateMetrics([-0.025, 1.0325, -1.025, 1.025]),
PNPBJT: generateMetrics([-0.025, 1.0325, -1.025, 1.025]),
RAM: generateMetrics([-0.05, 3.05, -0.6, 4.6]),
ROM: generateMetrics([-0.05, 3.05, -0.6, 2.6]),
IC: generateMetrics([-0.05, 3.05, -0.6, 2.6]),
DIL: generateMetrics([-0.05, 3.05, -0.6, 2.6]),
Splitter: generateMetrics([-0.1, 1.1, -0.1, 3.1]),
Merger: generateMetrics([-0.1, 1.1, -0.1, 3.1]),
Decoder: generateMetrics([-0.05, 2.05, -0.35, 2.35]),
Multiplexer: generateMetrics([-0.05, 2.05, -0.35, 2.35]),
Demultiplexer: generateMetrics([-0.05, 2.05, -0.35, 2.35]),
BitSelector: generateMetrics([-0.05, 2.05, -0.35, 2.35]),
PriorityEncoder: generateMetrics([-0.05, 3.05, -0.6, 1.6]),
BinToBCD: generateMetrics([-0.05, 3.05, -0.6, 1.6]),
Increment: generateMetrics([-0.05, 3.05, -0.6, 1.6]),
Adder: generateMetrics([-0.05, 3.05, -0.6, 2.6]),
Decrement: generateMetrics([-0.05, 3.05, -0.6, 1.6]),
Subtractor: generateMetrics([-0.05, 3.05, -0.6, 2.6]),
Multiplier: generateMetrics([-0.05, 3.05, -0.6, 2.6]),
Divider: generateMetrics([-0.05, 3.05, -0.6, 2.6]),
Comparator: generateMetrics([-0.05, 3.05, -0.6, 2.6]),
Negator: generateMetrics([-0.05, 2.05, -0.6, 0.6]),
SignEx: generateMetrics([-0.05, 3.05, -0.6, 0.6]),
Cell: generateMetrics([-0.1, 1.1, -1.1, 1.1]),
Battery: generateMetrics([-1.1, 1.1, -1.1, 1.1]),
Resistor: generateMetrics([-0.35, 0.35, 0, 2]),
Capacitor: generateMetrics([-0.1, 1.1, -0.85, 0.85]),
Inductor: generateMetrics([-1.1, 1.1, -0.45, 0.1]),
Diode: generateMetrics([-0.05, 1.05, -0.6, 0.6]),
Reset: generateMetrics([-0.05, 1.05, -0.6, 0.6]),
};
return function(type) {
return getMetrics[type]();
}
})();