Howto:Dynamic Liveries via Canvas: Difference between revisions

Jump to navigation Jump to search
m
m (→‎Canvas Code: more intuitive to use a hash here ?)
Line 65: Line 65:
myCanvas.addPlacement({"node": "Fuselage"});
myCanvas.addPlacement({"node": "Fuselage"});


# vector with all images added (beginning at 0)
# hash with all images added
var layers = {};
var layers = {};
# texture path
# texture path
var path="Aircraft/EF2000/Models/";
var path="Aircraft/EF2000/Models/";
foreach(var image; ['EF2000.png','EF2000-dirt.png']) {
foreach(var image; ['EF2000.png','EF2000-dirt.png']) {
# Put a raster image into the canvas and save the image in a hash: layers['EF2000.png].setScale(0.2);
if(contains(layers, image)) print("Warning: replacing texture (added twice): ", image);
# Put a raster image into the canvas and save the image in a hash: layers['EF2000.png].hide();
layers[image] = root.createChild("image")
layers[image] = root.createChild("image")
     .setFile( path~image )
     .setFile( path~image )

Navigation menu