<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://jsxgraph.org/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=PW</id>
	<title>JSXGraph Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://jsxgraph.org/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=PW"/>
	<link rel="alternate" type="text/html" href="https://jsxgraph.org/wiki/index.php?title=Special:Contributions/PW"/>
	<updated>2026-04-05T21:54:52Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.1</generator>
	<entry>
		<id>https://jsxgraph.org/wiki/index.php?title=Line&amp;diff=296</id>
		<title>Line</title>
		<link rel="alternate" type="text/html" href="https://jsxgraph.org/wiki/index.php?title=Line&amp;diff=296"/>
		<updated>2008-11-24T14:00:51Z</updated>

		<summary type="html">&lt;p&gt;PW: /* Construction of a line */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Construction of a line ==&lt;br /&gt;
A line needs two points. Lets construct two points &amp;quot;A&amp;quot; and &amp;quot;B&amp;quot;. &lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
var b = JXG.JSXGraph.initBoard(&#039;jxgbox&#039;, {originX: 200, originY: 100, unitX: 50, unitY: 50});&lt;br /&gt;
var p1 = b.createElement(&#039;point&#039;,[-1,1], {name:&#039;A&#039;,style:6});&lt;br /&gt;
var p2 = b.createElement(&#039;point&#039;,[2,-1], {name:&#039;B&#039;,style:6});&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Then we construct a line through &amp;quot;A&amp;quot; and &amp;quot;B&amp;quot;. The setting of a new color and changing the stroke-width is not necessary.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
var li = b.createElement(&#039;line&#039;,[&amp;quot;A&amp;quot;,&amp;quot;B&amp;quot;], {strokeColor:&#039;#00ff00&#039;,strokeWidth:2});&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
&amp;lt;link rel=&amp;quot;stylesheet&amp;quot; type=&amp;quot;text/css&amp;quot; href=&amp;quot;http://jsxgraph.uni-bayreuth.de/distrib/jsxgraph.css&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; src=&amp;quot;http://jsxgraph.uni-bayreuth.de/distrib/prototype.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; src=&amp;quot;http://jsxgraph.uni-bayreuth.de/distrib/jsxgraphcore.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;div id=&amp;quot;jxgbox&amp;quot; class=&amp;quot;jxgbox&amp;quot; style=&amp;quot;width:500px; height:200px; position:relative;&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;&lt;br /&gt;
 var brd = JXG.JSXGraph.initBoard(&#039;jxgbox&#039;, {originX: 200, originY: 100, unitX: 50, unitY: 50});&lt;br /&gt;
 var p1 = brd.createElement(&#039;point&#039;,[-1,1], {name:&#039;A&#039;,style:6});&lt;br /&gt;
 var p2 = brd.createElement(&#039;point&#039;,[2,-1], {name:&#039;B&#039;,style:6});&lt;br /&gt;
 var li = brd.createElement(&#039;line&#039;,[&amp;quot;A&amp;quot;,&amp;quot;B&amp;quot;], {strokeColor:&#039;#00ff00&#039;,strokeWidth:2});&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Generally it is better to use JavaScript variables and not Geometry-Element names when constructing.&lt;br /&gt;
Now, we do the same examples with JavaScript variables. Further, we don&#039;t show the whole line, but only a segment. To show another variation, we use a dashed line style.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
var li2 = b.createElement(&#039;line&#039;,[p1,p2], &lt;br /&gt;
 {straightFirst:false, straightLast:false, strokeWidth:2, dash:2});&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
&amp;lt;div id=&amp;quot;jxgbox2&amp;quot; class=&amp;quot;jxgbox&amp;quot; style=&amp;quot;width:500px; height:200px; position:relative;&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;&lt;br /&gt;
 var brd2 = JXG.JSXGraph.initBoard(&#039;jxgbox2&#039;, {originX: 200, originY: 100, unitX: 50, unitY: 50});&lt;br /&gt;
 var p1 = brd2.createElement(&#039;point&#039;,[-1,1], {name:&#039;A&#039;,style:6});&lt;br /&gt;
 var p2 = brd2.createElement(&#039;point&#039;,[2,-1], {name:&#039;B&#039;,style:6});&lt;br /&gt;
 var li2 = brd2.createElement(&#039;line&#039;,[p1,p2], {straightFirst:false, straightLast:false, strokeWidth:2, dash:2});&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Examples]]&lt;/div&gt;</summary>
		<author><name>PW</name></author>
	</entry>
</feed>