<link rel="stylesheet" type="text/css" href="domain/jsxgraph.css"/> <script type="text/javascript" src="domain/jsxgraphcore.js"></script> domain is the location of the JSXGraph files. This can be a local directory or jsxgraph.uni-bayreuth.de/distrib <div id="elementID"></div>, where elementID is an element identifier, elementClass is an element class. Naturally, the style of an element can be defined in any known way. var brd = JXG.JSXGraph.initBoard('elementClass',{attributes}), where elementClass is the class of the element, attributes are the attributes of the “board” that define its properties: dimensions, preservation of proportions, visibility of axes, grids, navigation buttons and rights notifications. var el = brd.create('type',[parents],{attributes}); where type is the type of the object (point, line, and so on),[parents] - an array of parent elements (for example, two points for a line),attributes - attributes (we will consider them later). el.setProperty({key1:value1,key2:value2,...}); where keyN is the name of the nth property, valueN is the value of the nth property. var el = brd.create('point',[x, y]); The point name is specified using the name attribute (for example, {name:'A'} ). var p0 = board.create('point',[-1, 1], {name:'A'}); If the fixed attribute is set to true , then a fixed point will be created: var pl = board.create('point',[1, -1], {name:'B', fixed:true}); If the value of at least one of the coordinates of the point is a function without parameters that returns a number, then a dependent point will be created: var p2 = board.create('point',[function(){return p0.X()}, -2], {name:''}); A is free, point B is fixed, point C is dependent on point A board.create('line',[point1, point2]) Points can be given either by object names, or directly by coordinates (in this case, the point is invisible).ax+by+c=0 (note the order of the coefficients in the command) board.create('line',[c, a, b]) var p1 = board.create('point',[0,0],{name:'A'}); var p2 = board.create('point',[3,2],{name:'B'}); var l1 = board.create('line',[p1,p2]); var l2 = board.create('line',[p1,[1,5]]); In JSFiddle: fiddle.jshell.net/AndreyDolgov/tybTW/show/light . var l3 = board.create('line',[-1.0,-2.0,1.0]); In JSFiddle: fiddle.jshell.net/AndreyDolgov/2A8Xa/show/light .straightFirst and straightLast . If one of these attributes is false , then we get a ray, if both are a segment. var p1 = board.create('point',[-2,-1],{name:'A'}); var p2 = board.create('point',[3,-2],{name:'B'}); var p3 = board.create('point',[-3,2],{name:'C'}); var l1 = board.create('line',[p1,p2],{straightFirst:false}); var l2 = board.create('line',[p1,p3],{straightLast:false}); var l3 = board.create('line',[p2,p3],{straightFirst:false,straightLast:false}); In JSFiddle: fiddle.jshell.net/AndreyDolgov/yKxku/show/light . board.create('circle',[centerPoint,pointOnCircle]); If there are two arguments, they are interpreted as the center and point on the circle. var center = board.create('point',[3,3],{name:'O'}); var ptOnCir = board.create('point',[4,5],{name:'A'}); var = board.create('circle',[center,ptOnCir]); In JSFiddle: fiddle.jshell.net/AndreyDolgov/A3JMq/show/light . var theCircle = board.create('circle',[[3,3],[4,5]]); In JSFiddle: fiddle.jshell.net/AndreyDolgov/9FgfW/show/light . board.create('circle',[centerPoint,radiusOfCircle]); When the second argument is a number, it is interpreted as a radius. var center = board.create('point',[3,3]);var theCircle = board.create('circle',[center,1]); In JSFiddle: fiddle.jshell.net/AndreyDolgov/VSRUx/show/light . board.create('circle',[centerPoint,circleWithDesiredRadius]); If the second argument is a circle, then its radius is used to build a new circle. var circle1 = board.create('circle',[[0,1],[0,2]]);var circle2 = board.create('circle',[[0,3],circle1]); In JSFiddle: fiddle.jshell.net/AndreyDolgov/aYezn/show/light . board.create('circle',[point1,point2,point3]); If there are three arguments, they are interpreted as three points through which the circle is constructed. var p1 = board.create('point',[2,1],{name:'p1',size:2}); var p2 = board.create('point',[2,5],{name:'p2',size:2}); var p3 = board.create('point',[4,3],{name:'p3',size:2}); var c = board.create('circle',[p1,p2,p3]); In JSFiddle: fiddle.jshell.net/AndreyDolgov/vRW3z/show/light board.create('polygon',[ptVertex1,ptVertex2,...]); In this case, the first and last element of the array should be the same vertex. If this is not done, the first vertex is automatically duplicated as the last. p1 = board.create('point',[0,0],{name:''}); p2 = board.create('point',[1,3],{name:''}); p3 = board.create('point',[5,5],{name:''}); p4 = board.create('point',[4,2],{name:''}); board.create('polygon',[p1,p2,p3,p4]); In JSFiddle: jsfiddle.net/AndreyDolgov/Fp3VM/show/light . board.create('conic',[point1,point2,point3,point4,point5]); board.create('conic',[a11,a22,a33,a21,a31,a32]); p1 = board.create('point',[0,0],{name:'p1'}); p2 = board.create('point',[1,1],{name:'p2'}); board.create('line',[p1,p2],{strokeWidth:1, color:'yellow'}); p3 = board.create('point',[2,3],{name:'p3'}); p4 = board.create('point',[3,4],{name:'p4'}); p5 = board.create('point',[4,1],{name:'p5'}); board.create('conic',[p1,p2,p3,p4,p5], {strokeWidth:4,strokeColor:'green'}); We will receive (JSFiddle): jsfiddle.net/AndreyDolgov/DdqvM/show/light board.create('conic',[9,4,-11,0,-9,-8]); We get : jsfiddle.net/AndreyDolgov/4jTQY/show/light . board.create('curve',[x,y,a,b]); where x and y are functions with one parameter that return a number, a and b define the interval of parameter values. board.create('curve',[functionOfTheta,[xOrigin,yOrigin],optBegValTheta,optEndValTheta]); where functionOfTheta is a function whose argument is an angle and which returns the distance from the pole;[xOrigin,yOrigin] - pole coordinates;optBegValTheta and optEndValTheta set the interval of the angle values ​​.. board.create('curve',[xArray,yArray]); where xArray and yArray are an array of X's and an array of little players .. board.create('curve', [function(t){return 3*Math.cos(t);}, function(t){ return 3*Math.sin(t);}, 0, Math.PI/2]); This is how it will look like in JSFiddle: jsfiddle.net/AndreyDolgov/9mcAs/show/light . board.create('curve', [function(theta){return theta/17;}, [-2,-1], -8*Math.PI, 8*Math.PI]); This is how it will look like in JSFiddle: jsfiddle.net/AndreyDolgov/XKH6Q/show/light . x = [-4,-3,-2,-1,0,1,2,3,5]; y = [-3,2,3,-1,0,2,1,4,0]; board.create('curve',[x,y]); This is how it will look like in JSFiddle: jsfiddle.net/AndreyDolgov/uKFFV/show/light . board.create('functiongraph',[functionRule,a,b]); where functionRule is a single argument function that returns a number,a and b specify the interval at which the function is defined. board.create('functiongraph', [function(x){ return (x+1)%(x-1);},1,3]); This is how it will look like: jsfiddle.net/AndreyDolgov/gkfqj/show/light . board.create('text',[x,y,stringText]); where the first two arguments set the position of the lower left corner of the text area, stringText is a string or a function that returns a string. board.create('text',[-5, 2, "<span style='color:yellow;background-color:blue; font-size:50px;'><br>.</span>"]); We get : jsfiddle.net/AndreyDolgov/YpQkL/show/light .Source: https://habr.com/ru/post/189862/
All Articles