File: main.js

package info (click to toggle)
mathgl 8.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 248,044 kB
  • sloc: cpp: 87,365; ansic: 3,299; javascript: 3,284; pascal: 1,562; python: 52; sh: 51; makefile: 47; f90: 22
file content (38 lines) | stat: -rw-r--r-- 1,401 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
var graph;

/**
 * Entry function.
 */
var main = function() {
  // get canvas to work over from the DOM
  var canvas = document.getElementById("canvas");

  // get backend injected by from C++ side just to illustrate where it came from
  // in normal web application it shall be implemented using some transport protocol
  var backend = new mathgl.WebkitBackend();

  // instantiate mathgl graph instance connecting it with canvas and backend
  graph = new mathgl.Graph(canvas, backend);
  graph.setBackgroundFillStyle("#F0F0F0");
  // initialize it by some sample MGL script
  graph.loadGeometry(makeSampleScript(),null);
  graph.setPerspective(0.5);
}


//var script = "rotate 40 60:fsurf 'sin(2*pi*x*y)'\nbox:axis:fplot 'sin(2*pi*t)' 'cos(2*pi*t)' '2*t-1' 'm2o'";
//var script = "box:axis:fplot 'sin(pi*x)'";
//var script = "rotate 10 20: box:axis:fsurf 'sin(pi*x*y)'";

var makeSampleScript = function() {
//	var mgl = "fsurf 'x' 'rgb';value 4";

	var mgl = "origintick off\n";
	mgl += "title 'qqq' '@k':ranges -2 2 -2 2 -2 2:colorbar '>'\n"   // NOTE: Ranges MUST BE specified for correctly work of zoomaxis feature
	mgl += "facenum 50:";
//	mgl += "origin 0 0 0:axis :xlabel 'xxxx':ylabel 'yyyy':zlabel 'zzzz':"
	mgl += "axis :xlabel 'xxxx':ylabel 'yyyy':zlabel 'zzzz':"
	mgl += "box:fplot 'sin(x^2)'\n";   // This is just for testing zoomaxis features
	mgl += "text 0 0 'aaa'";
	return mgl;
}