Canvas view camera element: Difference between revisions

Jump to navigation Jump to search
m (→‎Roadmap: https://forum.flightgear.org/viewtopic.php?f=71&t=23929&p=317798#p317798)
Line 309: Line 309:


<syntaxhighlight lang="nasal">
<syntaxhighlight lang="nasal">
# TODO: this must match the TYPENAME used by the C++ code
var ELEMENT_NAME ="view-camera"; # to be adapted according to the C++ changes
var ELEMENT_NAME ="view-camera"; # to be adapted according to the C++ changes


Line 314: Line 315:
  ##
  ##
  # constructor
  # constructor
  new: func(view=0, width=640,height=480) {
  new: func( camera ) {
   var m = { parents: [myElementTest] };
   var m = { parents: [myElementTest] };
   m.dlg = canvas.Window.new([width,height],"dialog");
   m.dlg = canvas.Window.new([camera.width,camera.height],"dialog");
   m.canvas = m.dlg.createCanvas().setColorBackground(1,1,1,1);
   m.canvas = m.dlg.createCanvas().setColorBackground(1,1,1,1);
   m.root = m.canvas.createGroup();
   m.root = m.canvas.createGroup();
Line 322: Line 323:
   ##
   ##
   # instantiate a new element
   # instantiate a new element
   me.myElement = m.root.createChild( ELEMENT_NAME );
   m.myElement = m.root.createChild( ELEMENT_NAME );
   me.myElement.set("view-number", view);
   # set the view-number property
  m.myElement.set("view-number", camera.view);
  m.dlg.set("title", "view #"~camera.view);


   return m;
   return m;
Line 332: Line 335:
var cameras = [
var cameras = [
  {view: 0, width : 640, height: 480},
  {view: 0, width : 640, height: 480},
  {view: 1, width : 640, height: 480},
  {view: 1, width : 320, height: 160},
  {view: 2, width : 640, height: 480},
  {view: 2, width : 320, height: 160},
];
];


foreach(var cam; cameras) {
foreach(var cam; cameras) {
  var newCam = myElementTest.new( view: cam.view, width: cam.width, height: cam.height );
  var newCam = myElementTest.new( cam );
}
}
</syntaxhighlight>
</syntaxhighlight>

Navigation menu