File: testjsxgraph.php

package info (click to toggle)
jsxgraph 1.5.0%2Bdfsg1-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 24,020 kB
  • sloc: javascript: 76,112; xml: 5,869; java: 1,072; python: 767; php: 181; makefile: 154; cpp: 76; sh: 9
file content (51 lines) | stat: -rw-r--r-- 1,371 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<html>
<?php
function jxgcompress($filename) 
{   
    if (file_exists($filename)) {
        $base64 = base64_encode(gzcompress(rawurlencode(file_get_contents($filename)),9));
        echo "var jxgcompressed = \"$base64\";\n";
    } else {
        throw new Exception("$filename not found");
    }
}
?>

<head>
<script src="./jsxcompressor.min.js" type="text/javascript"></script>

<link rel="stylesheet" type="text/css" href="./jsxgraph.css" />
<script type="text/javascript">

<?php 
   jxgcompress("../distrib/jsxgraphcore.js");
?>   
eval(JSXCompressor.default.decompress(jxgcompressed));
</script>
</head>

<body>
<h1>Bezier curves with JSXCompressor</h1>
<div id="jxgbox" class="jxgbox" style="width:600px; height:600px;"></div>
<script type="text/javascript">
    /* <![CDATA[ */

        var board, i, p, col;
        board = JXG.JSXGraph.initBoard('jxgbox', {boundingbox:[-4,4,4,-4], keepaspectratio:true, axis:true});
        p = [];
        for (i=0;i<2*3+1;i++) {
            if (i%3==0) {
                col = 'red';
            } else {
                col = 'blue';
            }
            p.push(board.create('point',[Math.random()*8-4,Math.random()*8-4],{strokeColor:col,fillColor:col}));
        }
        var c = board.create('curve', JXG.Math.Numerics.bezier(p),{strokecolor:'blue', strokeWidth:2}); 
        
/* ]]> */
</script>

</body>
</html>