Line: Difference between revisions

From JSXGraph Wiki
No edit summary
No edit summary
Line 2: Line 2:
A line needs two points. Lets construct two points "A" and "B".  
A line needs two points. Lets construct two points "A" and "B".  
<source lang="javascript">
<source lang="javascript">
var b = JXG.JSXGraph.initBoard('jxgbox', {originX: 200, originY: 100, unitX: 50, unitY: 50});
var b = JXG.JSXGraph.initBoard('jxgbox', {originX: 200, originY: 100, unitX: 50, unitY: 50});
var p1 = board.createElement('point',[-1,1], {name:'A',style:6});
var p1 = board.createElement('point',[-1,1], {name:'A',style:6});
var p2 = board.createElement('point',[2,-1], {name:'B',style:6});
var p2 = board.createElement('point',[2,-1], {name:'B',style:6});
</source>
Then we construct a line through "A" and "B". The setting of a new color and changing the stroke-width is not necessary.
<source lang="javascript">
var li = brd.createElement('line',["A","B"], {strokeColor:'#00ff00',strokeWidth:2});
</source>
</source>


Line 16: Line 20:
  var p1 = brd.createElement('point',[-1,1], {name:'A',style:6});
  var p1 = brd.createElement('point',[-1,1], {name:'A',style:6});
  var p2 = brd.createElement('point',[2,-1], {name:'B',style:6});
  var p2 = brd.createElement('point',[2,-1], {name:'B',style:6});
var li = brd.createElement('line',["A","B"], {strokeColor:'#00ff00',strokeWidth:2});
</script>
</script>
</html>
</html>

Revision as of 15:38, 17 September 2008

Construction of a line

A line needs two points. Lets construct two points "A" and "B".

var b = JXG.JSXGraph.initBoard('jxgbox', {originX: 200, originY: 100, unitX: 50, unitY: 50});
var p1 = board.createElement('point',[-1,1], {name:'A',style:6});
var p2 = board.createElement('point',[2,-1], {name:'B',style:6});

Then we construct a line through "A" and "B". The setting of a new color and changing the stroke-width is not necessary.

var li = brd.createElement('line',["A","B"], {strokeColor:'#00ff00',strokeWidth:2});