Showing 1 changed files with 16 additions and 14 deletions
+16 -14
Nasal/maps/topo.nas
... ...
@@ -3,15 +3,18 @@ var MapTopo = {
3 3
         var m = { parents: [ MapTopo ] };
4 4
         m.device = device;
5 5
         m.visibility = 0;
6
-        m.group = group.createChild('map', 'topo')
6
+        m.dist_scale = 10;
7
+        m.radial_scale = 11;
8
+        m.group = group.createChild('group', 'topo')
7 9
             .setTranslation((m.device.data.mapview[0] + m.device.data.mapclip.left)/2, 400)
8 10
             .setRotation(m.device.data.orientation.airplane * D2R)
9 11
             .setVisible(m.visibility);
10
-        m.radar = [];
11
-        for (var dist = 0; dist < 10; dist += 1) {
12
-            append(m.radar, []);
12
+        for (var dist = 0; dist < m.dist_scale; dist += 1) {
13 13
             for (var radial = 0; radial < 11; radial += 1) {
14
-                append(m.radar[dist], m.arc((radial * 10) - 50, (dist * 35) + 10));
14
+                if (radial + dist)
15
+                    m.arc((radial * 10) - 50, (dist * 35) + 10);
16
+                else
17
+                    m.path = m.arc((radial * 10) - 50, (dist * 35) + 10).parents[1]._node.getPath();
15 18
             }
16 19
         }
17 20
         data.timers.topo_radar = maketimer(0, func {
... ...
@@ -22,17 +25,16 @@ var MapTopo = {
22 25
             if (_geodinfo != nil) {
23 26
                 var diff = _geodinfo[0] * units.altitude.from_m - data.alt;
24 27
 
25
-                var color = [1, 0.5, 0.16, 1];
28
+                var color = 'rgba(255, 127, 40, 1)';
26 29
                 if (diff > 1000 * units.altitude.from_ft)
27
-                    color = [1, 0, 0, 1];
30
+                    color = 'rgba(255, 0, 0, 1)';
28 31
 
29
-                m.radar[dist][radial]
30
-                    .setColorFill(color)
31
-                    .setVisible(diff > 0);
32
+                setprop(m.path, radial + m.radial_scale * dist, 'fill', color);
33
+                setprop(m.path, radial + m.radial_scale * dist, 'visible', diff > 0);
32 34
             }
33
-            if    (m.radial < 10) # size(m.radar[m.dist]) - 1
35
+            if    (m.radial < m.radial_scale - 1)
34 36
                 m.radial += 1;
35
-            elsif (m.dist   <  9) { # size(m.radar) -1
37
+            elsif (m.dist   <  m.dist_scale - 1) {
36 38
                 m.dist   += 1;
37 39
                 m.radial = 0;
38 40
             }
... ...
@@ -44,7 +46,7 @@ var MapTopo = {
44 46
         m.device.data.orientation.radar = 0;
45 47
         m.dist = 0;
46 48
         m.radial = 0;
47
-        m.delta_radar_dist_nm = m.device.data['range-nm'] / size(m.radar);
49
+        m.delta_radar_dist_nm = m.device.data['range-nm'] / m.dist_scale;
48 50
         return m;
49 51
     },
50 52
 
... ...
@@ -89,7 +91,7 @@ var MapTopo = {
89 91
     update : func {
90 92
         if (me.visibility) {
91 93
             me.group.setRotation(me.device.data.orientation.airplane * D2R);
92
-            me.delta_radar_dist_nm = me.device.data['range-nm'] / size(me.radar);
94
+            me.delta_radar_dist_nm = me.device.data['range-nm'] / me.dist_scale;
93 95
         }
94 96
     },
95 97
 };