How to manipulate Canvas elements: Difference between revisions

Jump to navigation Jump to search
no edit summary
No edit summary
No edit summary
Line 5: Line 5:
For now '''Plot2D''' resides in the '''SpokenGCA''' addon, but the idea is that in the future it could be included in the $FG-ROOT/Nasal/canvas directory.<br />
For now '''Plot2D''' resides in the '''SpokenGCA''' addon, but the idea is that in the future it could be included in the $FG-ROOT/Nasal/canvas directory.<br />
If you have not the SpokenGCA addon installed, you may download '''''plot2D.nas''''' from  [https://sourceforge.net/p/flightgear/fgaddon/HEAD/tree/trunk/Addons/SpokenGCA/plot2D.nas here], put it into your ''$FG-HOME/Nasal/'' folder and then execute:
If you have not the SpokenGCA addon installed, you may download '''''plot2D.nas''''' from  [https://sourceforge.net/p/flightgear/fgaddon/HEAD/tree/trunk/Addons/SpokenGCA/plot2D.nas here], put it into your ''$FG-HOME/Nasal/'' folder and then execute:
<syntaxhighlight lang='Nasal'>
<syntaxhighlight lang="nasal">
   var root = getprop("/sim/fg-root");
   var root = getprop("/sim/fg-root");
   io.load_nasal( root ~ '/Nasal/plot2D.nas', "canvas" );
   io.load_nasal( root ~ '/Nasal/plot2D.nas', "canvas" );
Line 22: Line 22:
! example !! Screenshot
! example !! Screenshot
|-
|-
| <syntaxhighlight>
| <syntaxhighlight lang="nasal">
var window = canvas.Window.new([200,200],"dialog")
var window = canvas.Window.new([200,200],"dialog")
     .set("title","Plot2D demo"  );
     .set("title","Plot2D demo"  );
Line 61: Line 61:
! example !! Screenshot
! example !! Screenshot
|-
|-
| <syntaxhighlight>
| <syntaxhighlight lang="nasal">
var window = canvas.Window.new([200,200],"dialog").set("title","Plot2D demo"  );
var window = canvas.Window.new([200,200],"dialog").set("title","Plot2D demo"  );
var myCanvas = window.createCanvas().set("background", "#eeeeee");
var myCanvas = window.createCanvas().set("background", "#eeeeee");
Line 96: Line 96:
! example !! Screenshot
! example !! Screenshot
|-
|-
| <syntaxhighlight lang="xml">
| <syntaxhighlight lang="nasal">
var window = canvas.Window.new([200,200],"dialog").set("title","Plot2D demo"  );
var window = canvas.Window.new([200,200],"dialog").set("title","Plot2D demo"  );
var myCanvas = window.createCanvas().set("background", "#eeeeee");
var myCanvas = window.createCanvas().set("background", "#eeeeee");
Line 130: Line 130:
|-
|-
|
|
  {{Note| This assumes that you already have a top-level root group set up, and his ''group'' child named '''myGroup'''. }} <syntaxhighlight lang="xml">
  {{Note| This assumes that you already have a top-level root group set up, and his ''group'' child named '''myGroup'''. }} <syntaxhighlight lang="nasal">
var (red,blue,green,orange) = ['#ee0000', [0,0,1], [0,0.8,0], '#ea9a32' ];
var (red,blue,green,orange) = ['#ee0000', [0,0,1], [0,0.8,0], '#ea9a32' ];
canvas.plot2D.polyline(myGroup,[150,181,194,157,199],[52,20,64,28,36]);
canvas.plot2D.polyline(myGroup,[150,181,194,157,199],[52,20,64,28,36]);
Line 164: Line 164:
|-
|-
|
|
  {{Note| This assumes that you already have a top-level root group set up, and his ''group'' child named '''myGroup'''. }} <syntaxhighlight lang="xml">
  {{Note| This assumes that you already have a top-level root group set up, and his ''group'' child named '''myGroup'''. }} <syntaxhighlight lang="nasal">
var (red,blue,green,orange) = ['#ee0000', [0,0,1], [0,0.8,0], '#ea9a32' ];
var (red,blue,green,orange) = ['#ee0000', [0,0,1], [0,0.8,0], '#ea9a32' ];
canvas.plot2D.polyline(myGroup,[150,181,194,157,199],[52,20,64,28,36]);
canvas.plot2D.polyline(myGroup,[150,181,194,157,199],[52,20,64,28,36]);
229

edits

Navigation menu