-
Notifications
You must be signed in to change notification settings - Fork 3
/
svg_ext.js
163 lines (124 loc) · 4.69 KB
/
svg_ext.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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
// SVG.extend(SVG.Line, {
// clockface: function (x, y, r1, r2, deg) {
// return this.plot(SVG.shapes.clockface(x, y, r1, r2, deg))
// // var r = Math.PI / 180.0 * deg;
// // var p1 = Math.cos(r) * r1;
// // var p2 = Math.sin(r) * r1;
// // var p3 = Math.cos(r) * r2;
// // var p4 = Math.sin(r) * r2;
// // return this.line(x + p1, y + p2, x + p3, y + p4);
// },
// })
// SVG.shapes = {
// clockface: function (x, y, r1, r2, deg) {
// var points = [];
// var r = Math.PI / 180.0 * deg;
// var p1 = Math.cos(r) * r1;
// var p2 = Math.sin(r) * r1;
// var p3 = Math.cos(r) * r2;
// var p4 = Math.sin(r) * r2;
// points.push([x + p1, y + p2]);
// points.push([x + p3, y + p4]);
// return new SVG.PointArray(points);
// },
// // constructor(x, y, r1, r2, deg) {
// // super();
// // var r = Math.PI / 180.0 * deg;
// // var p1 = Math.cos(r) * r1;
// // var p2 = Math.sin(r) * r1;
// // var p3 = Math.cos(r) * r2;
// // var p4 = Math.sin(r) * r2;
// // this.line(x + p1, y + p2, x + p3, y + p4);
// // }
// }
SVG.extend(SVG.Container, {
clockface: function (x, y, r1, r2, deg) {
let r = Math.PI / 180.0 * deg;
let p1 = Math.cos(r) * r1;
let p2 = Math.sin(r) * r1;
let p3 = Math.cos(r) * r2;
let p4 = Math.sin(r) * r2;
return this.put(new SVG.Line(x + p1, y + p2, x + p3, y + p4))
},
boxed_text: function(w, h, text) {
return this.put(new SVG.BoxedText(w, h, text))
},
button: function (w, h, title, options, callback) {
return this.put(new SVG.Button(w, h, title, options, callback));
},
indicator_button: function (w, h, title, options, callback) {
return this.put(new SVG.IndicatorButton(w, h, title, options, callback));
},
circle_button: function (owner, diam, text, callback) {
return this.put(new SVG.CircleButton(owner, diam, text, callback));
},
rect_button: function (width, height, text, callback, enabled) {
return this.put(new SVG.RectButton(width, height, text, callback, enabled));
},
image_button: function (owner, text, image_on, image_off, callback) {
return this.put(new SVG.ImageButton(owner, text, image_on, image_off, callback));
},
icon_button: function (width, height, path) {
return this.put(new SVG.IconButton(width, height, path));
},
rotary: function () {
return this.put(new SVG.Rotary());
},
lcdDisplay: function (width, height, text, options) {
return this.put(new SVG.LCDDisplay(width, height, text, options))
},
compass: function (diam, options) {
return this.put(new SVG.Compass(diam, options));
},
compass_bug: function (diam, options) {
return this.put(new SVG.CompassBug(diam, options));
},
compass_needle: function (diam, options) {
return this.put(new SVG.CompassNeedle(diam, options));
},
compass_gauge: function (w, h, options) {
return this.put(new SVG.CompassGauge(w, h, options));
},
altimeter: function (w, h, step, div) {
return this.put(new Altimeter(w, h));
},
verticalspeed: function (w, h, step, div) {
return this.put(new VerticalSpeed(w, h));
},
gsindicator: function (w, h, step, div) {
return this.put(new GSIndicator(w, h));
},
altimeter_gauge: function (w, h, options) {
return this.put(new SVG.AltimeterGauge(w, h, options));
},
speedindicator: function (w, h, step, div) {
return this.put(new SpeedIndicator(w, h));
},
speedindicator_gauge: function (w, h, options) {
return this.put(new SVG.SpeedIndicatorGauge(w, h, options));
},
attitude_indicator: function (w, h, cx, cy) {
return this.put(new AttitudeIndicator(w, h, cx, cy));
},
rpm_gauge: function (w, h, r, opt) {
return this.put(new SVG.RPMGauge(w, h, r, opt));
},
horizontal_gauge: function (w, h, opt) {
return this.put(new SVG.HorizontalGauge(w, h, opt));
},
fuelquantity_gauge: function (w, h, opt) {
return this.put(new SVG.FuelQuantityGauge(w, h, opt));
},
magneto: function (w, h, opt = null, callback) {
return this.put(new SVG.Magneto(w, h, opt, callback));
},
trim_indicator:function (w, h, opt = null) {
return this.put(new SVG.TrimIndicator(w, h, opt));
},
flaps_control:function (w, h, opt = null) {
return this.put(new SVG.FlapsControl(w, h, opt));
},
wind_gauge:function (w, h, opt = null) {
return this.put(new SVG.WindGauge(w, h, opt));
},
});