for the code to test our svg files:
- Code: Select all
var CanvasApplication = {
##
# constructor
new: func(x=300,y=200,file="/gui/dialogs/images/ndb_symbol.svg") {
var m = { parents: [CanvasApplication] };
m.file=file;
m.dlg = canvas.Window.new([x,y],"dialog");
# you can change the background color here
var color = {WHITE:[1,1,1,1],BLACK:[0,0,0,1]};
m.canvas = m.dlg.createCanvas().setColorBackground(color.BLACK);
m.root = m.canvas.createGroup();
m.update();
return m;
},
update: func() {
var svg_symbols = me.root.createChild("group", "navaid");
canvas.parsesvg(svg_symbols, me.file);
svg_symbols.setScale(0.35); # resize the image so that it can be fully seen (30%)
#symbol_navaid.setGeoPosition(navaid.lat, navaid.lon);
},
init: func() {
var filename = "/Aircraft/Instruments/gyro.xml";
}, # init
}; # end of CanvasApplication
var SVGMapPreview= {
new: func(x,y,svg) {
var m = CanvasApplication.new(x:x, y:y, file:svg);
return m;
},
};
var preview= SVGMapPreview.new(x:400, y:400, svg:"Nasal/canvas/map/boeingND.svg");
print("SVGPreviewer loaded ...!");
I'm a Nasal newbie and just learned from experimenting that the parameters to CanvasApplication.new()
are all optional, so in this example If I leave away the file:svg then ndb_symbol.svg gets displayed.
this is also very helpful:
http://wiki.flightgear.org/Howto:Debugg ... up_Profile
FlightGear starts quicker and uses only 30% CPU when it runs compared to usual 98%