Hi fellow wiki editors!

To help newly registered users get more familiar with the wiki (and maybe older users too) there is now a {{Welcome to the wiki}} template. Have a look at it and feel free to add it to new users discussion pages (and perhaps your own).

I have tried to keep the template short, but meaningful. /Johan G

Talk:How to manipulate Canvas elements

From FlightGear wiki
Jump to: navigation, search

named arguments in examples ?

Hi there, fantastic job ! May I suggest that we use named function arguments, i.e. in the form:

var foo = func(altitude, label) {
}


foo(altitude:100, label:"hello world");

I feel that this would help make the code more self-explanatory, what do you think ? --Hooray (talk) 14:21, 5 December 2017 (EST)

plot2D namespace detection

I think, the following should work:

if (!canvas['plot2D']) {
 var root = getprop("/sim/fg-root");
 io.load_nasal( root ~ '/Nasal/plot2D.nas', "canvas" );
}

--Hooray (talk) 14:50, 5 December 2017 (EST)

Graphic

My suggestion would be rename "graphic" to "graph" or "graph2D" - and maybe consider using a wrapper class to make the 2 axes part of a helper, so that tic marks can be added to the graph more easily - otherwise, the function plotting the values would not even know where the surrounding axes are. That way, it would also be possible to not just accept a vector with data point, but also a callback that is to be executed to get a vector of values. And we could have a flag that specifies whether the new values are appended to the existing plot, or if they are to replace the plot. Higher level classes to do property plotting against time (or altitude) would also be easier to implement that way, because they could inherit from a single Graph2D class. --Hooray (talk) 15:29, 5 December 2017 (EST)