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 39 40 41 42 43 44 45 46 47 48 49 50 51
|
<html>
<head>
<title>JSXGraph example</title>
<link rel="stylesheet" type="text/css" href="../distrib/jsxgraph.css" />
<script type="text/javascript" src="/javascript/prototype/prototype.js"></script>
<script type="text/javascript" src="../distrib/jsxgraphcore.js"></script>
</head>
<body>
<h2>Sine waves</h2>
<div style="width:960px">
<div id="jxgbox" class="jxgbox" style="width:600px; height:400px; float:left; "></div>
</div>
<br clear=all>
<div id="debug" style="display:block;"></div>
<script type="text/javascript">
/* <![CDATA[ */
board1 = JXG.JSXGraph.initBoard('jxgbox', {originX: 300, originY: 200, unitX: 50, unitY: 50});
board1.suspendUpdate();
board1.createElement('axis', [[0,0], [1,0]], {ticksDistance: 0.6});
board1.createElement('axis', [[0,0], [0,1]], {});
var s = board1.createElement('slider', [[-0.75,-2.5],[4.75,-2.5],[0,0,10]], {name:'S',snapWidth:1});
board1.createElement('curve', [
'x',
function(t) {
var val = 0;
var k = 1;
for(var i = 0; i < s.Value() + 1; i++) {
val = val + Math.sin(2*Math.PI*k*t)/k;
k += 1;
}
return val+2;
}, -10, 10], {strokeColor: "#bb0000", curveType:'plot'});
board1.createElement('curve', [
'x',
function(t) {
var val = 0, i,
k = 1,
sv = s.Value();
for(i = 0; i < sv + 1; i++) {
val = val + Math.sin(2*Math.PI*(2*k-1)*t)/(2*k-1);
k += 1;
}
return val-2;
}, -10, 10], {strokeColor: "#cc5520", curveType:'plot'});
board1.unsuspendUpdate();
/* ]]> */
</script>
</body>
</html>
|