Canvas SVG parser: Difference between revisions

m
m (add a more trivial example that doesn't have additional dependencies or requires more knowledge)
Line 21: Line 21:
   m.file=file;
   m.file=file;
   m.dlg = canvas.Window.new([x,y],"dialog");
   m.dlg = canvas.Window.new([x,y],"dialog");
   # you can change the background color here
   # you can change the background color here
   var color = {WHITE:[1,1,1,1],BLACK:[0,0,0,1]};
   var color = {WHITE:[1,1,1,1], BLACK:[0,0,0,1]};
   m.canvas = m.dlg.createCanvas().setColorBackground(color.BLACK);
   m.canvas = m.dlg.createCanvas().setColorBackground(color.BLACK);
   m.root = m.canvas.createGroup();
   m.root = m.canvas.createGroup();
Line 30: Line 31:
    
    
update: func() {
update: func() {
var svg_symbols = me.root.createChild("group", "navaid");
# create a group for the image
var svg_symbols = me.root.createChild("group", "svgfile");
 
# parse the SVG file
canvas.parsesvg(svg_symbols, me.file);
canvas.parsesvg(svg_symbols, me.file);
svg_symbols.setScale(0.35); # resize the image so that it can be  fully seen (35%)


# resize the image so that it can be  fully seen (35%)
svg_symbols.setScale(0.35);


},
},
init: func() {
var filename = "/Aircraft/Instruments/gyro.xml";
}, # init
}; # end of CanvasApplication
}; # end of CanvasApplication