var g,g2,el1,el2,my={} function constructMain(filename,w,h,rel){var version='0.673';if(typeof(rel)==='undefined')rel="../index.html";var w=930;var h=w*9/16;var constQ=true if(constQ){var w=560;var h=440;} my.frameTime=100 my.frameLast=Date.now() console.log('w, h, time',w,h,my.frameTime) my.voiceQ=false my.fastQ=false;my.showNo=0;my.showTxt='';my.showAlign='center';my.waitUntil=performance.now();my.presets=[['Q','ADD C
Question 1 Question 2 Question 3 Question 4 Question 5 Question 6 Question 7 Question 8 Question 9 Question 10
']];my.imgHome=(document.domain=='localhost')?'/mathsisfun/geometry/images/':'/geometry/images/' var s="";s+='
';s+='
';for(var i=0;i<2;i++){s+='
';} s+='';s+='';s+='
' s+=playHTML(48) s+='
' s+='';s+=`
` s+='
';s+='
© 2019 MathsIsFun.com v'+version+'
';s+='
';s+='
';document.write(s);el1=document.getElementById('canvas1');my.ratio=2;el1.width=w*my.ratio;el1.height=h*my.ratio;el1.style.width=w+"px";el1.style.height=h+"px";el2=document.getElementById('canvas2');el2.width=w*my.ratio;el2.height=h*my.ratio;el2.style.width=w+"px";el2.style.height=h+"px";if(my.voiceQ){voiceSetup()}else{my.voice=new Voice()} var el=el1;g=el.getContext("2d") g.setTransform(my.ratio,0,0,my.ratio,0,0) g2=el2.getContext("2d") g2.setTransform(my.ratio,0,0,my.ratio,0,0) my.devQ=(document.domain=='localhost')?true:false if(my.devQ){var div=document.getElementById('clicker') div.addEventListener('mousedown',function(ev){var bRect=div.getBoundingClientRect();var mouseX=(ev.clientX-bRect.left)*(el.width/my.ratio/bRect.width);var mouseY=(ev.clientY-bRect.top)*(el.height/my.ratio/bRect.height);console.log('mousedown',Math.round(mouseX),Math.round(mouseY))})} my.svg=new SVG();my.cmdN=0 my.stt={clr:'black',dotClr:'#8888ff',thk:1} my.dotClr=my.stt.dotClr my.ruler=new Ruler();my.pencil=new Pencil();my.compass=new Compass();my.protractor=new Protractor();my.cmdStt=0 my.cmdTypes={start:{n:0,run(){}},show:{n:0,run(cmd){console.log("show",cmd.txt.substr(0,50));my.showTxt=cmd.txt var div=document.getElementById('show'+my.showNo);div.style.opacity=0;my.showNo=1-my.showNo;var div=document.getElementById('show'+my.showNo);div.style.opacity=1;div.style.top='0px';div.innerHTML=fmtShow(my.showTxt);my.scrollYTgt=0;}},add:{n:0,run(cmd){console.log("add");my.showTxt+=cmd.txt var div=document.getElementById('show'+my.showNo);div.style.opacity=0;my.showNo=1-my.showNo;var div=document.getElementById('show'+my.showNo);div.innerHTML=fmtShow(my.showTxt);div.style.opacity=1;}},say:{n:0,run(cmd){if(my.fastQ)return if(!my.voiceQ)return console.log("SAY",cmd.txt);var utterance=new SpeechSynthesisUtterance(cmd.txt);utterance.rate=0.9;utterance.pitch=1.1;utterance.voice=my.voice.getVoices()[2];my.voice.speak(utterance);}},preset:{n:0,run(cmd){var preName=cmd.txt console.log(">>",cmd.type,preName);var preNo=-1;for(var i=0;i>>",i,preName,preset,preset[0].toLowerCase());if(preset[0].toLowerCase()==preName){preNo=i;break;}} console.log(">>>",preNo);if(preNo>=0){var preset=my.presets[preNo][1];var bits=preset.split(' ');var cmd=bits[0];var data=bits.splice(1);console.log(">>",cmd.type,cmd,data);cmdDo(new Cmd(cmd,data));}}},align:{n:1,run(cmd){switch(cmd.parms[0].toLowerCase()){case 'c':case 'center':my.showAlign='center' break case 'l':case 'left':my.showAlign='left' break case 'r':case 'right':my.showAlign='right' break default:}}},img:{n:1,run(cmd){var txt='
';console.log("IMG",txt);var div=document.getElementById('image');div.innerHTML=txt;}},scroll:{n:0,run(cmd){my.scrollXTgt=parseFloat(cmd.parms[0]);my.scrollYTgt=parseFloat(cmd.parms[1]);console.log(">>>>>>>>>>scroll",my);}},bg:{n:0,run(cmd){console.log("bg",cmd.txt);var div=document.getElementById('bg');div.style.background=cmd.txt}},line:{n:4,run(cmd){var p=cmd.parms var pts=[];var x,y;for(var i=0;i10){g.lineCap="butt";}else{g.lineCap="round";} g.lineWidth=thk;g.lineJoin="round";my.pencil.thk=thk}},cposn:{n:2,run(cmd){my.compass.moveTo(cmd.parms[0],cmd.parms[1])}},cmove:{n:1,run(cmd){my.compass.moveArc(cmd.parms[0])}},cdraw:{n:1,run(cmd){my.compass.drawArc(cmd.parms[0])}},cwidth:{n:1,run(cmd){my.compass.moveWidth(cmd.parms[0])}},prposn:{n:4,run(cmd){my.protractor.movePosn(cmd.parms[0],cmd.parms[1],cmd.parms[2],cmd.parms[3])}},rposn:{n:4,run(cmd){my.ruler.movePosn(cmd.parms[0],cmd.parms[1],cmd.parms[2],cmd.parms[3])}},pmove:{n:2,run(cmd){my.pencil.moveTo(cmd.parms[0],cmd.parms[1])}},prel:{n:2,run(cmd){my.pencil.moveRel(cmd.parms[0],cmd.parms[1])}},pdraw:{n:2,run(cmd){my.pencil.drawTo(cmd.parms[0],cmd.parms[1])}},pause:{n:0,run(){if(my.playQ)playToggle()}},wait:{n:1,run(cmd){my.waitUntil=performance.now()+parseFloat(cmd.parms[0]);console.log("wait now, until",performance.now(),my.waitUntil);}},reset:{n:0,run(){reset()}},clear:{n:0,run(){g.clearRect(0,0,g.canvas.width,g.canvas.height)}},fade:{n:1,run(cmd){var can=g.canvas var alphaWas=g.globalAlpha g.globalAlpha=cmd.parms[0] console.log('fade',cmd.parms[0],alphaWas,g) g.globalCompositeOperation='copy';g.drawImage(el,0,0,can.width,can.height,0,0,can.width/my.ratio,can.height/my.ratio);g.globalAlpha=alphaWas g.globalCompositeOperation='source-over';}},char:{n:3,run(cmd){console.log('char:',cmd.parms[2])}},end:{n:0,run(){if(my.devQ){console.log(my.svg.getText());}}},} my.cmds=[];my.cmdStt=0;my.cmdEnd=0;my.currLvl=0;my.prevX=0;my.prevY=0;my.playQ=false;my.strokedQ=true;loadChars();filename=my.imgHome+'construct/'+filename+'.txt' getFileFromServer(filename);my.waitUntil=performance.now();} function voiceSetup(){my.voice=speechSynthesis;var voices=my.voice.getVoices();console.log("my.voice",my.voice,voices);for(var i=0;imy.cmdN){cmdRange(my.cmdN,newPos);my.cmdN=newPos;}else{my.voice.cancel();el1.getContext("2d").clearRect(0,0,el1.width,el1.height);el2.getContext("2d").clearRect(0,0,el2.width,el2.height);my.showNo=0;my.showTxt='';my.showAlign='center';var div=document.getElementById('show'+my.showNo);div.innerHTML='';div.style.opacity=1;my.scrollYTgt=0;div.style.top='0px';cmdRange(0,newPos);my.cmdN=newPos;}} function sliderSet(v){var r1=document.getElementById("r1");r1.value=(v/my.cmds.length)*100;} function cmdsSet(script){script=script.trim();var s='' var lines=script.split(/\r?\n/);for(var i=0;i=chgN)break s+=' ' s+=p} return s}} function splitLim(str,regex,max){str=str.trim() if(str.length==0)return[];if(max<=0)return[str];var bits=[];var n=0 var stt=0 do{var result=regex.exec(str) if(result){var s2=str.substring(stt,result.index) bits.push(s2) stt=result.index+result.length}}while(n++my.frameTime*2)my.frameLast=now if(elapsed<-2000)my.frameLast=now+2000 var doQ=elapsed>my.frameTime if(!doQ)return my.frameLast+=my.frameTime incrFrame()}} function cmdRange(fromNo,toNo){my.fastQ=true;if(fromNo==0)reset() for(var i=fromNo;i<=toNo;i++){cmdDo(my.cmds[i]);} my.cmdN=toNo my.fastQ=false;} function cmdDo(cmd){if(cmd==undefined)return null;if(cmd.type=='curve3')my.frameLast-=my.frameTime*0.6 if(!my.strokedQ){g.stroke();my.strokedQ=true;} var cmdType=my.cmdTypes[cmd.type] try{cmdType.run(cmd)}catch(err){console.log('ERROR with command:',cmd)} return cmd.type;} function fmtShow(s){return '
'+s+'
';} function drawBubble(g,startX,startY,lenX,lenY,txt){g.font="16px Arial";var alphaWas=g.globalAlpha g.globalAlpha=1;g.fillStyle="#bbd";g.roundRect(startX-3,startY+2,lenX,lenY,5);g.fill();g.beginPath() g.strokeStyle='#bbb' g.fillStyle="#eef0f8";var lineWidthWas=g.lineWidth g.lineWidth=0.5 g.roundRect(startX-5,startY,lenX,lenY,5);g.fill();g.stroke() g.lineWidth=lineWidthWas g.fillStyle="#0000ff";var words=txt.split(' ');var lineN=1 var i=1 var lineHt=21 while(words.length>0&&i<=words.length){var str=words.slice(0,i).join(' ');var w=g.measureText(str).width;if(w>lenX){if(i==1)i=2;g.fillText(words.slice(0,i-1).join(' '),startX,startY+(lineHt*lineN));lineN++;words=words.splice(i-1);i=1}else{i++}} if(i>0)g.fillText(words.join(' '),startX,startY+(lineHt*lineN));g.globalAlpha=alphaWas;} function setLvl(newval){my.currLvl=parseInt(newval);if(my.currLvl==0){var el=el1;g=el.getContext("2d");g.setTransform(my.ratio,0,0,my.ratio,0,0)}else{var el=el2;g=el.getContext("2d");g.setTransform(my.ratio,0,0,my.ratio,0,0);g.clearRect(0,0,el.width,el.height);}} function playHTML(w){var s='';s+='';s+='';return s;} function playToggle(){console.log('playToggle',my.cmdN,my.cmds.length,my.playQ) var btn='playBtn' if(my.playQ){my.playQ=false;document.getElementById(btn).classList.add("play");document.getElementById(btn).classList.remove("pause");}else{my.playQ=true;document.getElementById(btn).classList.add("pause");document.getElementById(btn).classList.remove("play");if(my.cmdNmy.scrollInc){scrollY+=my.scrollInc*Math.sign(my.scrollYTgt-scrollY);div.style.top=-scrollY+'px';}} return;} function getScroll(){var div=document.getElementById('show0');var scrollX=-parseFloat(div.style.left);var scrollY=-parseFloat(div.style.top);return[scrollX,scrollY];} function incrFrame(){doScroll();if(my.cmdN>=my.cmds.length){console.log('reached end',pleaseWait(null)) if(!my.strokedQ){g.stroke();my.strokedQ=true;} if(!pleaseWait(null)){playToggle();}}else{if(!pleaseWait(my.cmds[my.cmdN])){cmdDo(my.cmds[my.cmdN]);my.cmdN++;sliderSet(my.cmdN);}}} function pleaseWait(cmd){if(my.waitUntil>performance.now())return true;if(my.pencil.isMovingQ)return true if(my.ruler.isMovingQ)return true if(my.compass.isMovingQ)return true if(my.protractor.isMovingQ)return true if(my.voice.speaking||my.voice.pending){if(cmd==null)return true;if(cmd.type=='img'||cmd.type=='show'||cmd.type=='add'||cmd.type=='scroll'||cmd.type=='wait'){return true;}} if(cmd==null){var scrollY=getScroll()[1];if(Math.abs(scrollY-my.scrollYTgt)>my.scrollInc){return true;}} return false;} class Ruler{constructor(){this.isMovingQ=false;this.currX=0;this.currY=0;this.newX=0;this.newY=0;this.currRot=0;this.newRot=0;this.drawQ=false;this.y=-50;} movePosn(x0,y0,x1,y1){setVisible('ruler',true);this.newX=(x0+x1)/2;this.newY=(y0+y1)/2;this.newRot=Math.atan2(y1-y0,x1-x0)*180/Math.PI;this.drawQ=false;this.animate();} adjustPosn(){var div=document.getElementById('ruler');var x=this.currX-200;var y=this.currY-24;x-=24*Math.sin((this.currRot)*Math.PI/180);y+=24*Math.cos((this.currRot)*Math.PI/180);div.style.left=x+'px';div.style.top=y+'px';div.style.transform="rotate("+this.currRot+"deg)";} animate(){if(my.fastQ){this.currX=this.newX;this.currY=this.newY;this.currRot=this.newRot;this.adjustPosn();this.isMovingQ=false;}else{if(my.playQ)this.movesDo();if(this.isMovingQ)requestAnimationFrame(this.animate.bind(this));}} movesDo(){var moveCount=0;var d=Math.sqrt(Math.pow(this.currX-this.newX,2)+Math.pow(this.currY-this.newY,2));if(d>0.5){this.currX=this.currX*0.9+this.newX*0.1;this.currY=this.currY*0.9+this.newY*0.1;moveCount++;}else{this.currX=this.newX;this.currY=this.newY;} if(Math.abs(this.newRot-this.currRot)>0.01){var drawSpeed=2;if(this.drawQ) drawSpeed=0.5;if(Math.abs(this.newRot-this.currRot)>drawSpeed){if(this.newRot>this.currRot) this.currRot+=drawSpeed;if(this.newRot0){this.adjustPosn();this.isMovingQ=true;}else{this.isMovingQ=false;}}} class Protractor{constructor(){this.isMovingQ=false;this.currX=0;this.currY=0;this.newX=0;this.newY=0;this.currRot=0;this.newRot=0;this.drawQ=false;this.y=-50;} movePosn(x0,y0,x1,y1){setVisible('protractor',true);this.newX=(x0+x1)/2;this.newY=(y0+y1)/2;this.newRot=Math.atan2(y1-y0,x1-x0)*180/Math.PI;this.drawQ=false;this.animate();} adjustPosn(){var div=document.getElementById('protractor');var x=this.currX-200;var y=this.currY-24;x-=24*Math.sin((this.currRot)*Math.PI/180);y+=24*Math.cos((this.currRot)*Math.PI/180);div.style.left=x+'px';div.style.top=y+'px';div.style.transform="rotate("+this.currRot+"deg)";} animate(){if(my.fastQ){this.currX=this.newX;this.currY=this.newY;this.currRot=this.newRot;this.adjustPosn();this.isMovingQ=false;}else{if(my.playQ)this.movesDo();if(this.isMovingQ)requestAnimationFrame(this.animate.bind(this));}} movesDo(){var moveCount=0;var d=Math.sqrt(Math.pow(this.currX-this.newX,2)+Math.pow(this.currY-this.newY,2));if(d>0.5){this.currX=this.currX*0.9+this.newX*0.1;this.currY=this.currY*0.9+this.newY*0.1;moveCount++;}else{this.currX=this.newX;this.currY=this.newY;} if(Math.abs(this.newRot-this.currRot)>0.01){var drawSpeed=2;if(this.drawQ) drawSpeed=0.5;if(Math.abs(this.newRot-this.currRot)>drawSpeed){if(this.newRot>this.currRot) this.currRot+=drawSpeed;if(this.newRot0){this.adjustPosn();this.isMovingQ=true;}else{this.isMovingQ=false;}}} class Pencil{constructor(){this.pencilQ=true if(this.pencilQ){this.div=document.getElementById('pencil')}else{this.div=document.getElementById('brush')} this.isMovingQ=false;this.clr='black' this.thk=1 this.currPt={x:0,y:0} this.prevPt={x:0,y:0} this.prevPtQ=false this.pts=[];this.endLine=null this.drawQ=false;this.alpha=1 this.visQ=false this.lastDraw=Date.now() this.skipN=0} vis(visQ){this.visQ=visQ this.div.style.opacity=visQ?1:0} alphaSet(alpha){var chgQ=this.alpha<0.9?alpha>=0.9:alpha<0.9 this.alpha=alpha if(chgQ){this.div.style.opacity=0 if(alpha<0.9){this.stackQ=true this.pencilQ=false this.div=document.getElementById('brush')}else{this.stackQ=false this.pencilQ=true this.div=document.getElementById('pencil')}}} moveRel(x,y){this.currPt.x+=x this.currPt.y+=y this.moveTo(this.currPt.x,this.currPt.y);} moveFast(x,y){this.vis(true) this.currPt.x=x this.currPt.y=y this.setDrawQ(false);this.divPlace();this.isMovingQ=false;} moveTo(x,y){this.vis(true) this.pts=this.multiGet([this.currPt,{x:x,y:y}],5,0.9) this.setDrawQ(false);this.animate();} drawTo(x,y){this.vis(true) this.pts=this.multiGet([this.currPt,{x:x,y:y}],5,0.9) my.svg.strokeStyle=my.pencil.clr;my.svg.moveTo(this.currPt.x,this.currPt.y);my.svg.lineTo(x,y);this.setDrawQ(true);this.animate();} multiGet(pts,dMin,ratio){return this.multiEasIn(pts,dMin,ratio)} multiEasIn(pts,dMin,ratio){if(pts.length<2)return var news=[] news.push(pts[0]) for(var i=1;i5){var ratio=(1-1/(Math.pow(x+1,4)))/0.9375} news.push({x:prevPt.x+ratio*(currPt.x-prevPt.x),y:prevPt.y+ratio*(currPt.y-prevPt.y),})}}} if(false){var thkWas=g.lineWidth g.lineWidth=1 for(var i=0;idMin){var currPt={x:prevPt.x,y:prevPt.y} while(ptDist(currPt,pt)>dMin){currPt.x=currPt.x*ratio+pt.x*(1-ratio) currPt.y=currPt.y*ratio+pt.y*(1-ratio) news.push({x:currPt.x,y:currPt.y})}} news.push(pt)} if(false){var thkWas=g.lineWidth g.lineWidth=1 for(var i=0;i180){this.currRot-=360;} if((this.currRot-this.newRot)<-180){this.currRot+=360;} this.setDrawQ(false);this.animate();} drawArc(a){setVisible('compass',true);this.startArcQ=false this.newRot=-a;this.setDrawQ(true);this.animate();my.svg.strokeStyle='#ffcc66';my.svg.arc(this.currX,this.currY,this.w,this.currRot,this.newRot);} setDrawQ(onQ){this.drawQ=onQ;if(this.drawQ){this.fromPointQ=false;}} adjustPosn(){var div=document.getElementById('cleft');div.style.transform="rotate("+this.leftRot+"deg)";div.style.transformOrigin="50% 0% 0";div=document.getElementById('cright');div.style.transform="rotate("+-this.leftRot+"deg)";div.style.transformOrigin="50% 0% 0";var x=this.currX;var y=this.currY;x+=this.armLen*Math.sin((this.leftRot+this.currRot)*Math.PI/180);y-=this.armLen*Math.cos((this.leftRot+this.currRot)*Math.PI/180);div=document.getElementById('compass');div.style.left=x+'px';div.style.top=y+'px';div.style.transform="rotate("+this.currRot+"deg)";var xSharp=this.armLen*Math.sin((this.leftRot+this.currRot)*Math.PI/180);var ySharp=this.armLen*Math.cos((this.leftRot+this.currRot)*Math.PI/180);if(this.drawQ){var xPencil=xSharp-this.armLen*Math.sin((-this.leftRot+this.currRot)*Math.PI/180);var yPencil=ySharp-this.armLen*Math.cos((-this.leftRot+this.currRot)*Math.PI/180);var toX=this.currX+xPencil;var toY=this.currY-yPencil;if(this.fromPointQ){g.strokeStyle='#ffcc66';var wdWas=g.lineWidth g.lineWidth=2 g.beginPath();g.moveTo(this.fromX,this.fromY);g.lineTo(toX,toY);g.stroke();g.lineWidth=wdWas} this.fromX=toX;this.fromY=toY;this.fromPointQ=true;}} animate(){if(my.fastQ){this.movesDo() if(this.isMovingQ)this.animate()}else{if(my.playQ)this.movesDo();if(this.isMovingQ)requestAnimationFrame(this.animate.bind(this));}} movesDo(){var moveCount=0;var d=Math.sqrt(Math.pow(this.currX-this.newX,2)+Math.pow(this.currY-this.newY,2));if(d>0.5){this.currX=this.currX*0.9+this.newX*0.1;this.currY=this.currY*0.9+this.newY*0.1;moveCount++;}else{this.currX=this.newX;this.currY=this.newY;} if(Math.abs(this.newRot-this.currRot)>0.01){var drawSpeed=3 if(this.drawQ){var angChg=Math.abs(this.newRot-this.currRot) drawSpeed=Math.max(0.3,Math.min(angChg/20,6))} if(this.startArcQ){if(Math.abs(this.newRot-this.currRot)>drawSpeed){if(this.newRot>this.currRot)this.currRot+=drawSpeed;if(this.newRot0.5){this.currAngle=this.currAngle*0.9+this.newAngle*0.1;this.leftRot=this.currAngle;moveCount++;}else{this.leftRot=this.newAngle;this.adjustPosn();} if(moveCount>0){this.adjustPosn();this.isMovingQ=true;}else{this.isMovingQ=false;}}} CanvasRenderingContext2D.prototype.roundRect=function(x,y,w,h,r){if(w<2*r)r=w/2;if(h<2*r)r=h/2;this.beginPath();this.moveTo(x+r,y);this.arcTo(x+w,y,x+w,y+h,r);this.arcTo(x+w,y+h,x,y+h,r);this.arcTo(x,y+h,x,y,r);this.arcTo(x,y,x+w,y,r);this.closePath();return this;} class SVG{constructor(){this.lineWidth=2 this.strokeStyle='#000';this.strokeStyle='#ffcc66';this.lineAlpha='1';this.fillStyle='#def';this.fillAlpha='0.5';this.inLineQ=false;this.inGroupQ=false;this.line=[];this.txt=this.getHeader();this.onQ=my.devQ} txtAdd(s){if(this.onQ)this.txt+=s+'\n'} getHeader(){var s='' s+='\n';s+='\n';s+='\n';s+='SVG Output\n' s+='\n' return s;} getFooter(){var s='' s+="\n";s+="";return s;} lineStyle(thick,clr){if(thick==0)thick=0.2;this.lineWidth=thick;this.strokeStyle=clr;} beginFill(clr){this.fillStyle=clr;} endFill(){} circle(x,y,rad){this.txtAdd(``)} arc(x,y,rad,startAngle,endAngle){var start=this.polarToCartesian(x,y,rad,endAngle);var end=this.polarToCartesian(x,y,rad,startAngle);var largeArcFlag=endAngle-startAngle<=180?"0":"1";var sweepFlag=1 var d=["M",fmt1(start.x),fmt1(start.y),"A",rad,rad,0,largeArcFlag,sweepFlag,fmt1(end.x),fmt1(end.y)].join(" ");this.txtAdd(``)} polarToCartesian(centerX,centerY,radius,angleInDegrees){var angleInRadians=angleInDegrees*Math.PI/180.0;return{x:centerX+(radius*Math.cos(angleInRadians)),y:centerY+(radius*Math.sin(angleInRadians))};} moveTo(x,y){if(this.line.length>1)this.polyline();this.line.push([x,y]);this.currStyle=this.getStyle();} lineTo(x,y){this.line.push([x,y]);} drawRect(x,y,width,height){this.txtAdd('')} drawText(text,x,y,rotate){var s='';s+=text;s+="";this.txtAdd(s)} getStyle(){var s='';s+="stroke-width='"+this.lineWidth+"' ";s+="stroke='"+this.strokeStyle+"' ";if(this.fillStyle.length>0){s+="fill='"+this.fillStyle+"' ";s+="fill-opacity='"+this.fillAlpha+"' ";} return s;} getFontStyle(){var s="";s+="font-size:30px; fill:#0000ff; stroke:none; font-family:Arial;" return(s);} polyline(){var s="";s+="";this.txtAdd(s) s+="\n";this.line=[];} polygon(line){var s="";s+="";s+="\n";this.txtAdd(s)} group(id){var s='' if(this.inGroupQ){s+="\n";} s+="";this.txtAdd(s) this.inGroupQ=true;} getText(){if(this.line.length>1)this.polyline();if(this.inGroupQ){this.txtAdd("\n")} this.txtAdd(this.getFooter()) return(this.txt);}} function fmt1(x){return Math.round(x*10)/10} function cmdsCharAdd(cmds,cmd){var x1=0,x2=0,x3=0;var y1=0,y2=0,y3=0;var x0=cmd[1];var y0=cmd[2];var c=cmd[3];var charArr=my.charArr[c] var dbgStt=cmds.length if(charArr!=undefined){var pntN=0;for(var k=0;k1){var cmd=new Cmd('line') cmd.parms=[(x2+x3)/2,(y2+y3)/2,x3,y3] cmds.push(cmd)} pntN=0;} x1=x2;y1=y2;x2=x3;y2=y3;x3=parseFloat(charArr[k][0])+parseFloat(x0);y3=parseFloat(charArr[k][1])+parseFloat(y0);pntN++;if(pntN==2){var cmd=new Cmd('line') cmd.parms=[x2,y2,(x2+x3)/2,(y2+y3)/2] cmds.push(cmd)} if(pntN>2){var cmd=new Cmd('curve3') cmd.parms=[(x1+x2)/2,(y1+y2)/2,x2,y2,(x2+x3)/2,(y2+y3)/2] cmds.push(cmd)}} if(pntN>1){var cmd=new Cmd('line') cmd.parms=[(x2+x3)/2,(y2+y3)/2,x3,y3] cmds.push(cmd)}} var s='' for(var i=dbgStt;i