15
edits
m (→FGPlot) |
mNo edit summary |
||
Line 9: | Line 9: | ||
<syntaxhighlight lang="xml"> | <syntaxhighlight lang="xml"> | ||
<canvas> | <canvas> | ||
<name>fgplot</name> | |||
<valign>fill</valign> | |||
<halign>fill</halign> | |||
<stretch>true</stretch> | |||
<pref-width>600</pref-width> | |||
<pref-height>400</pref-height> | |||
<nasal> | <nasal> | ||
<!-- | <!-- | ||
this is the Canvas-specific Nasal section where you can run your own Nasal code | |||
to access the canvas region | |||
--> | --> | ||
<load><![CDATA[ | <load> | ||
<![CDATA[ | |||
# you can add your canvas-specific code here | |||
var my_canvas = canvas.get( cmdarg() ); # this will get a handle to the parent canvas : | # you can add your canvas-specific code here | ||
var my_canvas = canvas.get( cmdarg() ); # this will get a handle to the parent canvas : | |||
print("Hello world from the embedded canvas section!\n"); | print("Hello world from the embedded canvas section!\n"); | ||
]]></load> | ]]> | ||
</nasal> | </load> | ||
</nasal> | |||
</canvas> | </canvas> | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 59: | Line 61: | ||
<empty><stretch>true</stretch></empty> | <empty><stretch>true</stretch></empty> | ||
<canvas> | <canvas> | ||
<name>fgplot</name> | |||
<valign>fill</valign> | |||
<halign>fill</halign> | |||
<stretch>true</stretch> | |||
<pref-width>600</pref-width> | |||
<pref-height>400</pref-height> | |||
<nasal> | <nasal> | ||
<!-- | <!-- | ||
this is the Nasal/canvas section where you can run your own Nasal code | |||
to access the canvas section | |||
--> | --> | ||
<load><![CDATA[ | <load> | ||
# you can add your canvas-specific code here | <![CDATA[ | ||
var my_canvas = canvas.get( cmdarg() ); # this will get a handle to the parent canvas: | # you can add your canvas-specific code here | ||
var my_canvas = canvas.get( cmdarg() ); # this will get a handle to the parent canvas: | |||
var root = my_canvas.createGroup(); | |||
var text = root.createChild("text") | |||
.setText("Hello world from FGPlot v. 0.1 !") | |||
.setTranslation(10, 30) | |||
.setAlignment("left-top") | |||
.setFontSize(20) | |||
.setFont("LiberationFonts/LiberationSans-Regular.ttf") | |||
.set("max-width", 380) | |||
.setColor(1,0,0); | |||
var | var graph = root.createChild("group"); | ||
var | var x_axis = graph.createChild("path", "x-axis") | ||
.moveTo(10, | .moveTo(10, 150) | ||
.lineTo( | .lineTo(380, 150) | ||
.setColor(1,0,0) | .setColor(1,0,0) | ||
.setStrokeLineWidth(3); | .setStrokeLineWidth(3); | ||
var | var y_axis = graph.createChild("path", "y-axis") | ||
. | .moveTo(10, 30) | ||
.setColor(0,0 | .lineTo(10, 250) | ||
. | .setColor(1,0,0) | ||
.setStrokeLineWidth(3); | |||
var | var plot = graph.createChild("path", "data") | ||
.setStrokeLineWidth(2) | |||
.setColor(0,0,1) | |||
.moveTo(10,150); # origin | |||
var samples = [ # absolute coordinates | |||
[50, 150], [100,140], [200,110], [270, 55] | |||
]; | |||
]]> | foreach(var set; samples) { | ||
</load> | plot.lineTo( set[0], set[1] ); | ||
</nasal> | } | ||
</canvas> | ]]> | ||
</load> | |||
</nasal> | |||
</canvas> | |||
<button> | <button> |
edits