| 1 |
<html> |
| 2 |
<head> |
| 3 |
<title>Egg | JSXGraph Example</title> |
| 4 |
<link rel="stylesheet" type="text/css" href="../../distrib/jsxgraph.css" /> |
| 5 |
<script type="text/javascript" src="../../distrib/jsxgraphcore.js"></script> |
| 6 |
</head> |
| 7 |
<body> |
| 8 |
<div id="debug" style="display: none"></div> |
| 9 |
<center> |
| 10 |
<div style="width: 1000px;"> |
| 11 |
<div style="width:600px; height: 410px;"> |
| 12 |
<div id="jxgbox" class="jxgbox" style="width:600px; height:400px; text-align: left; float: left;"></div> |
| 13 |
<div id="polynomials" style="display: none; width: 600px; height: 400px; margin-left: 10px; text-align: left; padding-left: -200px;"></div> |
| 14 |
</div> |
| 15 |
|
| 16 |
<div style="width: 800px; margin-top: 10px;"> |
| 17 |
<form> |
| 18 |
<input type="button" onclick="calculateLocus();" value="Calculate locus of T" /> |
| 19 |
<input type="button" onclick="showLocusEquation();" value="Show locus equation" /> |
| 20 |
<input type="button" onclick="showBoard();" value="Show board" /> |
| 21 |
<input type="button" onclick="showLocusTime(loc)" value="Show locus time" /> |
| 22 |
<input type="button" onclick="toggleOptimize();" id="opt" value="Optimization is off"> |
| 23 |
</form> |
| 24 |
</div> |
| 25 |
</div> |
| 26 |
</center> |
| 27 |
<script type="text/javascript"> |
| 28 |
/* <![CDATA[ */ |
| 29 |
|
| 30 |
board = JXG.JSXGraph.initBoard('jxgbox', {boundingbox:[-2, 5, 10, -3], axis: true, grid: false, |
| 31 |
keepaspectratio: true, showcopyright: false}); |
| 32 |
p1 = board.createElement('point', [1, 1]); |
| 33 |
p2 = board.createElement('point', [1, 3]); |
| 34 |
p3 = board.createElement('point', [8, 1]); |
| 35 |
|
| 36 |
board.options.locus.toOrigin = p1; |
| 37 |
board.options.locus.to10 = p2; |
| 38 |
|
| 39 |
l1 = board.createElement('line', [p1, p3]); |
| 40 |
c1 = board.createElement('circle', [p1, p2]); |
| 41 |
g1 = board.createElement('glider', [4, 4, c1], {name:"G"}); |
| 42 |
|
| 43 |
m1 = board.createElement('midpoint', [g1, p3], {color: 'blue'}); |
| 44 |
c2 = board.createElement('circle', [m1, 1]); |
| 45 |
m2 = board.createElement('intersection', [l1, c2, 0], {color: 'blue'}); |
| 46 |
m3 = board.createElement('midpoint', [m2, g1], {name: "T", color: 'green'}); |
| 47 |
|
| 48 |
loc = null;//board.createElement('locus', [m3], {strokeColor: 'red', strokeWidth: '1px'}); |
| 49 |
opt = false; |
| 50 |
|
| 51 |
|
| 52 |
function calculateLocus() { |
| 53 |
loc = board.create('locus', [m3], {strokeColor: 'black', strokeWidth: '2px'}); |
| 54 |
} |
| 55 |
|
| 56 |
function showLocusEquation() { |
| 57 |
var out = document.getElementById('polynomials'); |
| 58 |
|
| 59 |
out.innerHTML = '<ul>'; |
| 60 |
for(i=0; i<loc.eq.length; i++) |
| 61 |
out.innerHTML += '<li>' + loc.eq[i] + ' = 0</li>'; |
| 62 |
out.innerHTML += '</ul>'; |
| 63 |
out.style.display = 'block'; |
| 64 |
document.getElementById('jxgbox').style.display = 'none'; |
| 65 |
} |
| 66 |
|
| 67 |
function showBoard() { |
| 68 |
document.getElementById('polynomials').style.display = 'none'; |
| 69 |
document.getElementById('jxgbox').style.display = 'block'; |
| 70 |
} |
| 71 |
|
| 72 |
function dimConstruction() { |
| 73 |
var c = [p3, p4, c1, g, p6, c2, p14_1], i, o = getDim(); |
| 74 |
|
| 75 |
if(p3.visProp['strokeOpacity'] == o) |
| 76 |
o = 1.0; |
| 77 |
|
| 78 |
for(i=0; i<c.length; i++) { |
| 79 |
c[i].setProperty({strokeOpacity: o, fillOpacity: o}); |
| 80 |
} |
| 81 |
} |
| 82 |
|
| 83 |
function showLocusTime(l) { |
| 84 |
document.getElementById('polynomials').style.display = 'block'; |
| 85 |
document.getElementById('jxgbox').style.display = 'none'; |
| 86 |
|
| 87 |
document.getElementById('polynomials').innerHTML = l.ctime; |
| 88 |
} |
| 89 |
|
| 90 |
function toggleOptimize() { |
| 91 |
if(opt) { |
| 92 |
board.options.locus.translateToOrigin = false; |
| 93 |
board.options.locus.translateTo10 = false; |
| 94 |
opt = false; |
| 95 |
document.getElementById('opt').value = "Optimization is off"; |
| 96 |
} else { |
| 97 |
board.options.locus.translateToOrigin = true; |
| 98 |
board.options.locus.translateTo10 = true; |
| 99 |
opt = true; |
| 100 |
document.getElementById('opt').value = "Optimization is on"; |
| 101 |
} |
| 102 |
} |
| 103 |
|
| 104 |
/* ]]> */ |
| 105 |
</script> |
| 106 |
<br/> |
| 107 |
</body> |
| 108 |
</html> |