let my={};function numberodometerMain(base){my.base=typeof base!=='undefined'?base:2;let version='0.83';w=460;h=240;digitCount=8;MIN=2;MAX=16;my.base=Math.max(MIN,Math.min(my.base,MAX)) my.prev=performance.now();let s="";s+='
';s+='';s+='
Base:
';s+='';s+='';s+='';s+='
Hexadecimal
';s+='
Decimal
';s+='
Binary
';s+='';s+='
' s+=playHTML(50) s+='
' let xPos=20;let yPos=175;for(i=0;i0
';s+='
?
';xPos+=35;} s+='
© 2020 MathsIsFun.com v'+version+'
';s+='';document.write(s);el=document.getElementById('canvasId');ratio=4;el.width=w*ratio;el.height=h*ratio;el.style.width=w+"px";el.style.height=h+"px";g=el.getContext("2d");g.setTransform(ratio,0,0,ratio,0,0);console.log('stt');numBalls=0;my.playQ=false;restart();} function playHTML(w){let s='';s+='';s+='';return s;} function play(){my.playQ=false;playToggle();} function playToggle(){let 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");anim();}} function anim(){if(my.playQ){if(performance.now()-my.prev>500){incr1() my.prev=performance.now();console.log('.')} requestAnimationFrame(anim);}} function restart(){if(my.playQ)play();for(i=0;i"+i+"";document.getElementById("txt"+(i+1)).innerHTML=s;} numBalls=0;g.clearRect(0,0,el.width,el.height);} function doBase(num){document.getElementById("exp").value=num;my.base=num;restart();play();} function incr1(){incr(1);numBalls++;drawBalls(numBalls);} function incr(n){if(n>digitCount){clearInterval(id);} let div=document.getElementById("dig"+n);let val=fromHex(div.innerHTML);val++;if(val>=my.base){val=0;incr(n+1);} if(val==0){div.style.backgroundColor="#ffff00";}else{div.style.backgroundColor="#ddeeff";} div.innerHTML=toHexx(val);} function fromHex(v){return(parseInt(v,16));} function toHexx(v){s=v.toString(16);s=s.toUpperCase();return(s);} function getExp(){let num=document.getElementById("exp").value;num=num.replace(/,/gm,"");num=parseInt(num);if(isNaN(num))num=0;if(num>this.MAX)num=this.MAX;if(numthis.MIN){num--;document.getElementById("exp").value=num;my.base=num;restart();play();}} function expUp(){let num=getExp();if(num430){xPos=320;yPos-=12;}}}