File: bspline.html

package info (click to toggle)
jsxgraph 1.10.1%2Bdfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 24,804 kB
  • sloc: javascript: 82,299; xml: 5,869; java: 1,072; php: 281; makefile: 184; python: 174; cpp: 76; sh: 12
file content (37 lines) | stat: -rw-r--r-- 1,336 bytes parent folder | download | duplicates (3)
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
<html>
<head>
   <title>JSXGraph example</title>
   <link rel="stylesheet" type="text/css" href="../distrib/jsxgraph.css" />
   <script type="text/javascript" src="../distrib/jsxgraphcore.js"></script>
</head>
<body>
  <h2>B-splines</h2>
  <div id="jxgbox" class="jxgbox" style="width:600px; height:600px;"></div>
  <div id="debug" style="display:block;"></div>
  <form><input type="button" value="add point"
               onclick="p.push(board.createElement('point',[Math.random()*8-4,Math.random()*8-4]));board.update();"></form>
   <script type="text/javascript">
    /* <![CDATA[ */
    var board, p;
    (function(){
        var i, col;
        board = JXG.JSXGraph.initBoard('jxgbox', {boundingbox:[-4,4,4,-4], keepaspectratio:true, axis:true});
        //board.options.curve.doAdvancedPlot = false;
        p = [];
        for (i=0;i<8;i++) {
            if (i%1==0) {
                col = 'red';
            } else {
                col = 'blue';
            }
            p.push(board.createElement('point',[Math.random()*8-4,Math.random()*8-4],{/*id:'p'+i,*/strokeColor:col,fillColor:col}));
        }

        var c = board.createElement('curve', JXG.Math.Numerics.bspline(p,4), {strokecolor:'blue', strokeWidth:2});
        return p;
    })();

  /* ]]> */
  </script>
</body>
</html>