Animation of lines

From JSXGraph Wiki
Revision as of 14:27, 17 December 2009 by A WASSERMANN (talk | contribs) (New page: <html> <span onClick="startAnimation1()" style="color:blue">Click here, to start animation 1</span> <span onClick="startAnimation2()" style="color:red">Click here, to start animation 2</sp...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Click here, to start animation 1 Click here, to start animation 2

The JavaScript code

var brd = JXG.JSXGraph.initBoard('jxgbox', {boundingbox: [-10, 10, 10, -10], axis: true, grid: false});
var p0 = brd.createElement('point', [0,0], {name:'T'});
var p1 = brd.createElement('point', [7, 5], {name:'A'});
var p2 = brd.createElement('point', [5, 7], {name:'B'});
var l = brd.createElement('line', [p1,p2], {name:''});
var t = brd.createElement('transform', [function(){return p0.X();},function(){return p0.Y();}], {type:'translate'});
t.bindTo(p1);t.bindTo(p2);

function startAnimation1() {
  p0.moveTo([-5,-8],1500);
}
function startAnimation2() {
  p0.moveTo([0,0],1500);
}
<span onClick="startAnimation1()" style="color:blue">Click here, to start animation 1</span>
<span onClick="startAnimation2()" style="color:red">Click here, to start animation 2</span>