zkv1000 / Nasal / maps / track.nas /
Sébastien MARQUE add track display
d278ebe 3 years ago
1 contributor
31 lines | 0.977kb
var MapTrack = {
    new : func (device, group) {
        var m = { parents: [MapTrack] };
        m.device = device;
        m.visibility = 0;
        m.group = group.createChild('path', 'track')
            .moveTo((m.device.data.mapview[0] + m.device.data.mapclip.left)/2, 400)
            .vertTo(m.device.data.mapsize[1])
            .setCenter((m.device.data.mapview[0] + m.device.data.mapclip.left)/2, 400)
            .setRotation((data.trk + 180) * D2R)
            .setColor(1,0,0)
            .setStrokeLineWidth(3)
            .setVisible(m.visibility);
        return m;
    },
    off: func {
        me.setVisible(0);
        me.group.setVisible(0);
        me.group.removeAllChildren();
    },
    update: func {
        me.visibility != 0 or return;
        me.group.setRotation((data.trk + 180) * D2R);
    },
    setVisible : func (v) {
        if (me.visibility != v) {
            me.visibility = v;
            me.group.setVisible(v);
        }
    },
};