20,741
edits
(http://forum.flightgear.org/viewtopic.php?f=71&t=23961) |
mNo edit summary |
||
Line 1: | Line 1: | ||
[[File:Canvas-livery-demo-using-ogle.png|thumb|A screen shot showing the ogel aircraft whose livery is dynamically changed using the [[Canvas]] system - in this case, we're simply rendering a [[MapStructure]] map onto the face of the pilot using ~10 lines of Nasal/Canvas code.]] | |||
== Example == | |||
<syntaxhighlight lang="nasal"> | |||
# create a new window, dimensions are 320 x 160, using the dialog decoration (i.e. titlebar) | |||
var window = canvas.Window.new([320,160],"dialog"); | |||
# adding a canvas to the new window and setting up background colors/transparency | |||
var myCanvas = window.createCanvas(); | |||
# creating the top-level/root group which will contain all other elements/group | |||
var root = myCanvas.createGroup(); | |||
# ogel | |||
myCanvas.addPlacement({"node": "Head"}); | |||
var TestMap = root.createChild("map"); | |||
TestMap.setController("Aircraft position"); | |||
TestMap.setRange(25); | |||
TestMap.setTranslation( myCanvas.get("view[0]")/2, | |||
myCanvas.get("view[1]")/2 | |||
); | |||
var r = func(name,vis=1,zindex=nil) return caller(0)[0]; | |||
foreach(var type; [r('APT'), r('VOR') ] ) | |||
TestMap.addLayer(factory: canvas.SymbolLayer, type_arg: type.name, visible: type.vis, priority: type.zindex,); | |||
</syntaxhighlight> | |||
== Objective == | == Objective == |