function resize() { //canvas.width = window.innerWidth; // canvas.height = window.innerHeight; } function toggleHelp() { var help="help"+langStr(lang); var ele=document.getElementById(help); ele.hidden=!ele.hidden; if (ele.hidden==true) { ele=document.getElementById("helpBtn"); ele.innerHTML="Help"; } else { ele=document.getElementById("helpBtn"); ele.innerHTML="Hide Help"; } } //var n=1; //initial settings var min1=1; var max1=5; var min2=12; var max2=50; var GONews; var grid; //counter var h=0; var m=0; var s=0; var c = 0; var t; var timer_is_on = 0; var listFigure=[]; function timedCount() { s=s+1; if (s==60){ m=m+1; s=0; } if(m==60){ h=h+1; m=0; } document.getElementById("txt").innerHTML = h + ":" + m + ":" + s; if (h<10){ document.getElementById("txt").innerHTML = "0"+h + ":" + m + ":" + s; if (s<10&&m<10)document.getElementById("txt").innerHTML = "0"+h + ":0" + m + ":0" + s; if (s>10&&m<10)document.getElementById("txt").innerHTML = "0"+h + ":0" + m + ":" + s; if (s<10&&m>10)document.getElementById("txt").innerHTML = "0"+h + ":" + m + ":0" + s; }else if(m<10){ document.getElementById("txt").innerHTML = h + ":0" + m + ":" + s; if (s<10)document.getElementById("txt").innerHTML = h + ":0" + m + ":0" + s; } //c = c + 1; t = setTimeout(timedCount, 1000); } function startCount() { if (!timer_is_on) { timer_is_on = 1; timedCount(); } } function stopCount() { clearTimeout(t); timer_is_on = 0; } function resetCount() { clearTimeout(t); timer_is_on = 0; s=0; m=0; h=0; document.getElementById("txt").innerHTML = "00:00:00"; } // Hint tag //document.getElementById("myBtn").onclick = function() {myFunction()}; /* myFunction toggles between adding and removing the show class, which is used to hide and show the dropdown content */ function myFunction() { document.getElementById("myDropdown").classList.toggle("show"); } function setHTML(id,text){ var e=document.getElementById(id); if (e==null) return; e.innerHTML=text; } var lang=0; ) processed by MyLexV4 --> class MyRect extends Movable { constructor (x,y,w,h){ super (x,y); this.w=w; this.h=h; //this.id=id; } inside(x,y){ x-=this.x0; y-=this.y0; if(x>=0 && x<=this.w && y>=0 &&y<=this.h) return true; return false; } draw (ctx){ /*ctx.fillStyle="blue"; ctx.fillRect(this.x0, this.y0, this.w, this.h); ;*/ ctx.strokeStyle=this.color; ctx.beginPath(); ctx.rect(this.x0, this.y0, this.w,this.h); ctx.stroke(); } } function doMouseDown(event) { //alert("mouse is down"); //var m=document.getElementById("mouseInfo"); //m.innerHTML="mouse is down"; xyScreen(event); // debug20221025 Movable.mouseDown(event); Movable.isInside(event); TGP.isInside(event); } function doMouseUp(event) { xyScreen(event); // debug20221025 //alert("mouse is up"); //var m=document.getElementById("mouseInfo"); //m.innerHTML="mouse is up"; Movable.mouseUp(); //Movable.positionOK(); var inGrid=0; for (var i=0;i': case '.': case 'ArrowRight': da=-45; break; default: return; } if (Movable.rotSelected(da,mirror)) { redraw(Movable.ctx); } //var m=document.getElementById("mouseInfo"); //m.innerHTML="mouse is wheeling: ("+event.offsetX+", "+event.offsetY+")"; } function initCanvas(canvasName) { var canvas = document.getElementById(canvasName); initMyCanvasAndScreen(canvas,redraw, resizeTGP); canvas.addEventListener('mousedown',doMouseDown,false); canvas.addEventListener('mouseup',doMouseUp,false); canvas.addEventListener('mousemove',doMouseMove,false); canvas.addEventListener('mousewheel',doMouseWheel,false); document.addEventListener('keydown',doKeyDown); //document.addEventListener('keyup', doKeyUp); return canvas; } function redraw(ctx, caller="") { var n=getRndInteger(min1,max1); ctx.fillStyle="white"; ctx.fillRect(0,0,canvas.width,canvas.height); //ctx.arc(0,0,50,0,2*Math.PI); for (var i=0;i3) { // ?p=min1,max1,min2,max2 var s=paraStr.substring(3).split(/[=,]+/); // alert(paraStr+" s[0]="+s[0]+" s["+(s.length-1)+"]="+s[s.length-1]); if (s.length==2) { //N=parseInt(s[0]); min1=parseInt(s[0]); max1=parseInt(s[1]); //min2=parseInt(s[2]); //max2=parseInt(s[3]); } // alert("min1="+min1+" "+max1+" "+min2+" "+max2); } //var n=getRndInteger(min1,max1); //var randomNum=getRndInteger(min2,max2); getRandomPara(); /*var RR=50; //=========== var tangR1=new Tangram(0,0,true); tangR1.defT(500,100,RR,225,"black"); //"#DCDCDC"); tangR1.color="#87CEFA"; tangR1.set(150); Movable.list.push(tangR1); var tangR2=new Tangram(0,0,true); tangR2.defT(550,250,RR,225,"#DCDCDC"); tangR2.color="purple"; tangR2.set(150); Movable.list.push(tangR2); tangR3=new Tangram(0,0,true); tangR3.defS(485.36,185.35,RR,0,"#DCDCDC"); tangR3.color="green"; tangR3.set(150); Movable.list.push(tangR3); tangR4=new Tangram(0,0,true); tangR4.defP2(585.36+2*RR,185.35,RR,45,"#DCDCDC"); // tangR4.defP2(100, 100,RR,45*0,"#DCDCDC"); tangR4.color="#DEB887"; tangR4.set(145*0+150); Movable.list.push(tangR4); tangR5=new Tangram(0,0,true); tangR5.defT(620.71,320.71,RR*Math.sqrt(2),90,"DCDCDC"); tangR5.color="blue"; tangR5.set(150); Movable.list.push(tangR5); tangR6=new Tangram(0,0,true); tangR6.defT(585.36,185.35,2*RR,180,"DCDCDC"); tangR6.color="red"; tangR6.set(150); Movable.list.push(tangR6); tangR7=new Tangram(0,0,true); tangR7.defT(585.36,185.35,2*RR,270,"DCDCDC"); tangR7.color="yellow"; tangR7.set(150); Movable.list.push(tangR7); */ //========================== //Tangram Square for initiation //========================== /* //Triangle var tangR=new Tangram(); tangR.defT(150,200,RR,90,"#87CEFA"); tangR.set(150); Movable.list.push(tangR); tangR=new Tangram(); tangR.defT(200,200,RR,0,"purple"); tangR.set(150); Movable.list.push(tangR); // sequare tangR=new Tangram(); tangR.defS(150,200,RR,0,"green"); tangR.set(150); Movable.list.push(tangR); //Parallelgram //tangR=new Tangram(); //tangR.defP(400,200,RR,270,"brown"); //tangR.set(150); //Movable.list.push(tangR); //PARALLELGRAM2 tangR=new Tangram(); tangR.defP2(100,200,RR,45,"#DEB887"); tangR.set(150); Movable.list.push(tangR); tangR=new Tangram(); tangR.defT(150,100,2*RR/Math.sqrt(2),225,"blue"); tangR.set(150); Movable.list.push(tangR); tangR=new Tangram(); tangR.defT(150,200,2*RR,180,"red"); tangR.set(150); Movable.list.push(tangR); tangR=new Tangram(); tangR.defT(150,200,2*RR,270,"yellow"); tangR.set(150); Movable.list.push(tangR); */ var fig, ix=10, iy=10, w=10*TGP.scale, dw=w; fig = new TGP("Chicken",w,ix,iy); listFigure.push(fig); iy+=dw*5; fig = new TGP("Cat", w,ix,iy); listFigure.push(fig); iy+=dw*7; fig = new TGP("Rabbit", w,ix,iy); listFigure.push(fig); iy+=dw*5; fig = new TGP("Boat", w,ix,iy); listFigure.push(fig); iy+=dw*4.5; fig = new TGP("Horse", w,ix,iy); listFigure.push(fig); iy+=dw*6; fig = new TGP("Duck", w,ix,iy); listFigure.push(fig); iy+=dw*5; fig = new TGP("Rocket", w,ix,iy); listFigure.push(fig); iy+=dw*5.5; fig = new TGP("House", w,ix,iy); listFigure.push(fig); iy+=dw*5.5; fig = new TGP("Fish", w,ix,iy); listFigure.push(fig); ix+=dw*5; fig = new TGP("Swan", w,ix,iy); listFigure.push(fig); ix+=dw*5; fig = new TGP("Tree", w,ix,iy); listFigure.push(fig); ix+=dw*5; fig = new TGP("Dog", w,ix,iy); listFigure.push(fig); ix+=dw*5; fig = new TGP("Fox", w,ix,iy); listFigure.push(fig); ix+=dw*5; fig = new TGP("Butterfly", w,ix,iy); listFigure.push(fig); ix+=dw*5; fig = new TGP("Goose", w,ix,iy); listFigure.push(fig); ix+=dw*6; fig = new TGP("Turtle", w,ix,iy); listFigure.push(fig); ix+=dw*6; fig = new TGP("Cow", w,ix,iy); listFigure.push(fig); ix+=dw*6; fig = new TGP("Swan 2", w,ix,iy); listFigure.push(fig); ix+=dw*5; fig = new TGP("Heart", w,ix,iy); listFigure.push(fig); ix+=dw*5; fig = new TGP("Camel", w,ix,iy); listFigure.push(fig); ix+=dw*5; fig = new TGP("Bear", w,ix,iy+5); listFigure.push(fig); ix+=dw*5; fig = new TGP("Shark", w,ix,iy); listFigure.push(fig); ix+=dw*7.5; fig = new TGP("Rat", w,ix,iy+5); listFigure.push(fig); ix+=dw*6; fig = new TGP("Ox", w,ix,iy+5); listFigure.push(fig); ix+=dw*6; fig = new TGP("Tiger", w,ix,iy+5); listFigure.push(fig); ix+=dw*6; fig = new TGP("Dragon", w,ix,iy+3); listFigure.push(fig); ix+=dw*3; fig = new TGP("Snake", w,ix+(-51),iy+(-50)); listFigure.push(fig); iy+=dw*(-6); fig = new TGP("Monkey", w,ix+(-40),iy+(-50)); listFigure.push(fig); iy+=dw*(-5); fig = new TGP("Sheep", w,ix+(-40),iy+(-50)); listFigure.push(fig); iy+=dw*(-4); fig = new TGP("Pig", w,ix+(-40),iy+(-50)); listFigure.push(fig); iy+=dw*(-4); fig = new TGP("Rooster", w,ix+(-40),iy+(-50)); listFigure.push(fig); iy+=dw*(-7); fig = new TGP("Person 1", w,ix+(-40),iy+(-50)); listFigure.push(fig); iy+=dw*(-6); fig = new TGP("Person 2", w,ix+(-30),iy+(-50)); listFigure.push(fig); iy+=dw*(-6); fig = new TGP("Person 3", w,ix+(-60),iy+(-50)); listFigure.push(fig); iy+=dw*(-5); rearrangeTPG(listFigure, canvas); // auto arrangements resizeTGP(); // pieces is the current tangram figure with 7 pieces var pieces = new TGP("Square",70, 8*50,3*50, 0, false); // Movable.list.push(pieces); iy+=dw*6; pieces.type=""; fig = new TGP("Person 3",70, (20-12)*W,W*2-20, 7*0);// listFigure.push(fig); iy+=dw*6; fig.visible=false; TGP.offsetY=20; redraw(ctx); function toggleScale(toDraw=true) { if (TGP.scale==1) { ctx.save(); /* canvas.width*=2; canvas.height*=2; ctx.scale(2,2); TGP.scale=2; */ } else { ctx.restore(); TGP.scale=1; } if (toDraw==true) redraw(ctx); } function save() { pieces.save("textArea"); redraw(ctx); } showOrHide("title", lang); showOrHide('foot',lang); resizeTGP(); // full screen does not work 20221019 // resize(); ) processed by MyLexV4 -->
end of file