簡體   English   中英

在一組對象中,Segment 不移動

[英]In a group of objects Segment doesn't move

我是 jsxgraph 的新手。 我會有很多問題。 我的第一張圖如下

這是我能夠編碼的內容。

> <div id="box" class="jxgbox" style="width:500px; height:500px;">
> <script type="text/javascript"> var board =
> JXG.JSXGraph.initBoard('box', {boundingbox: [0, 10, 10, 0],
> axis:false}); var grid = board.create('grid', []); var t1 =
> board.create('text',[.5,5.2,"$A$"]); var t2 =
> board.create('text',[1.9,3.6,"$0$"]); var t3 =
> board.create('text',[1.9,6.4,"$1$"]); var p1 =
> board.create('point',[1,5], {name:'',
> size:1,strokeColor:'#AE181E',visible:false,fixed:true}); var p2 =
> board.create('point',[2,5],
> {name:'',size:1,strokeColor:'#AE181E',visible:false,fixed:true}); var
> p3 = board.create('point',[2,4], {name:'',
> size:1,strokeColor:'#AE181E',visible:false,fixed:true}); var p4 =
> board.create('point',[2,6],
> {name:'',size:1,strokeColor:'#AE181E',visible:false,fixed:true}); var
> li1 = board.create('line',[p1,p2], {straightFirst:false,
> straightLast:false,strokeColor:'#AE181E',strokeWidth:2}); var li2 =
> board.create('line',[p3,p4], {straightFirst:false,
> straightLast:false,strokeColor:'#AE181E',strokeWidth:2}); var seg1 =
> board.create('segment',[[2,4],[2,6]],{strokeColor:'#5F9EA0'}); var p5
> = board.create('point',[2.2,4], {name:'', size:1,strokeColor:'#AE181E',visible:false,fixed:true}); var p6 =
> board.create('point',[3.2,4], {name:'',
> size:1,strokeColor:'#AE181E',visible:false,fixed:true}); d=[]
> d[0]=board.create('glider',[seg1],{name:'',strokeColor:'#5F9EA0',fillColor:'#5F9EA0'});
> d[1] = board.create('point',[2.2,4], {name:'',
> size:1,strokeColor:'#AE181E',visible:false,fixed:true}); d[2] =
> board.create('point',[3.2,4], {name:'',
> size:1,strokeColor:'#AE181E',visible:false,fixed:true});
> d[3]=board.create('segment',[d[1],d[2]]);
> d[4]=board.create('text',[3.5,4,"$B$"]);
> d[5]=board.create('text',[2.7,4.2,"$C$"]); var gr =
> board.create('group',d) </script> </div>

但是段d[3]不會隨着其他d[]元素移動,我無法獲得 $\lambda_0$ 的 Latex 渲染。

我的錯誤是什么?

您使用組 object 實現依賴對象的方法非常有創意。 只有兩個小問題會阻止您的施工工作:

  1. 組可能僅包含點、文本、圖像(具有單個坐標的對象)。
  2. d[1]d[2]點在您的構造中是固定的,即不允許移動。

這是您的構造的一個工作變體,請在https://jsfiddle.net/d47bfye6/現場查看:

JXG.Options.point.strokeColor = '#AE181E';
var board = JXG.JSXGraph.initBoard('box', {boundingbox: [0, 10, 10, 0], axis: false});

var grid = board.create('grid', []); 
var t1 = board.create('text',[.5, 5.2,"$A$"]); 
var t2 = board.create('text',[1.9, 3.6,"$0$"]); 
var t3 = board.create('text',[1.9, 6.4,"$1$"]); 
var p1 = board.create('point', [1,5], {name:'', size:1,visible:false, fixed:true}); 
var p2 = board.create('point', [2,5], {name:'',size:1, visible:false, fixed:true}); 
var p3 = board.create('point', [2,4], {name:'', size:1,visible:false, fixed:true}); 
var p4 = board.create('point', [2,6], {name:'',size:1, visible:false, fixed:true}); 
var li1 = board.create('segment', [p1, p2], {strokeColor: '#AE181E', strokeWidth:2}); 
var li2 = board.create('segment', [p3, p4], {strokeColor: '#AE181E', strokeWidth:2}); 
var seg1 = board.create('segment', [[2,4],[2,6]],{strokeColor: '#5F9EA0'}); 
var p5 = board.create('point', [2.2,4], {name:'', visible:false, fixed:true}); 
var p6 = board.create('point', [3.2,4], {name:'', visible:false, fixed:true}); 
var d = [];
d[0] = board.create('glider', [seg1],{name:'',strokeColor:'#5F9EA0',fillColor:'#5F9EA0'});
d[1] = board.create('point', [2.2, 4], {name:'', visible: false, fixed:false}); 
d[2] = board.create('point', [3.2, 4], {name:'', visible: false, fixed:false});
d[3] = board.create('text', [3.5, 4, "$B$"]);
d[4] = board.create('text', [2.7, 4.2, "$C$"]); 

board.create('segment', [d[1], d[2]]);

var gr = board.create('group', d);

至少,我希望你希望結構像這樣工作,你的圖像鏈接似乎不起作用。

關於 MathJax / LaTeX:請在您的文件頭中包括:

<script>
window.MathJax = {
  tex: {
    inlineMath: [ ['$','$'], ["\\(","\\)"] ],
    displayMath: [ ['$$','$$'], ["\\[","\\]"] ],
    packages: ['base', 'ams']
  },
  options: {
    ignoreHtmlClass: 'tex2jax_ignore',
    processHtmlClass: 'tex2jax_process'
  }
};
</script>
<script src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js" id="MathJax-script"></script>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM