20,741
edits
m (→FGPlot) |
m (→FGPlot) |
||
Line 67: | Line 67: | ||
# you can add your canvas-specific code here | # you can add your canvas-specific code here | ||
var my_canvas = canvas.get( cmdarg() ); # this will get a handle to the parent canvas: | 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 graph = root.createChild("group"); | |||
var x_axis = graph.createChild("path", "x-axis") | |||
.moveTo(10, 150) | |||
.lineTo(380, 150) | |||
.setColor(1,0,0) | |||
.setStrokeLineWidth(3); | |||
var y_axis = graph.createChild("path", "y-axis") | |||
.moveTo(10, 30) | |||
.lineTo(10, 250) | |||
.setColor(1,0,0) | |||
.setStrokeLineWidth(3); | |||
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) | |||
plot.lineTo( set[0], set[1] ); | |||
print("Hello world from the embedded canvas section!\n"); | print("Hello world from the embedded canvas section!\n"); | ||
]]> | ]]> |