Debian Codegraph @

Nasal/canvas/map/WPT.symbol

raw
1 # See: http://wiki.flightgear.org/MapStructure
2 # Class things:
3 var name = 'WPT';
4 var parents = [DotSym];
5 var __self__ = caller(0)[0];
6 DotSym.makeinstance( name, __self__ );
7
8 SymbolLayer.get(name).df_style = { # style to use by default
9 line_width: 3,
10 scale_factor: 1,
11 font: "LiberationFonts/LiberationSans-Regular.ttf",
12 font_size: 28,
13 font_color: [1,0,1],
14 active_color: [1,0,1],
15 inactive_color: [1,1,1],
16 };
17
18 var element_type = "group"; # we want a group, becomes "me.element"
19 var active = nil;
20
21 var init = func {
22 me.path = me.element.createChild("path")
23 .setStrokeLineWidth(me.style.line_width)
24 .moveTo(0,-25)
25 .lineTo(-5,-5)
26 .lineTo(-25,0)
27 .lineTo(-5,5)
28 .lineTo(0,25)
29 .lineTo(5,5)
30 .lineTo(25,0)
31 .lineTo(5,-5)
32 .setColor(1,1,1)
33 .close()
34 .setScale(me.style.scale_factor);
35
36 me.text = me.newText(me.model.name, me.style.font_color)
37 .setTranslation(25,35)
38 .setScale(me.style.scale_factor);
39
40 me.draw();
41 };
42 var draw = func {
43 var active = (getprop(me.options.current_wp_node) == me.model.idx);
44 if (active != me.active) {
45 me.path.setColor(
46 active ?
47 me.style.active_color :
48 me.style.inactive_color
49 );
50 me.text.setColor(
51 active ?
52 me.style.active_color :
53 me.style.inactive_color
54 );
55 me.active = active;
56 }
57 };
58