function lstyle(elm){ elm.style.display='inline-block'; elm.style['text-align']="center"; elm.style['font-size']="130%"; elm.style['position']="absolute"; return elm; } function format(l){ return l<10 ? '0'+l.toString() : l.toString(); } function isMouseInPosition ( cx, cy ,x, y, width, height ){ return ( ( cx >= x && cx <= x + width ) && ( cy >= y && cy <= y + height ) ); } function dist2D(x1,y1,x2,y2){ return Math.sqrt(Math.pow(x2-x1,2)+Math.pow(y2-y1,2)); } function Mathdeg(radians){ return radians * (180/Math.PI);} function Mathrad(degrees){ return degrees * (Math.PI/180);} function findRotation( x1, y1, x2, y2 ){ let t = -1*Mathdeg( Math.atan2( x2 - x1, y2 - y1 ) ); return t < 0 ? t + 360 : t; } function getPointFromDistanceRotation(x, y, dist, angle){ let a = Mathrad(90 - angle); return [x+Math.cos(a) * dist, y+Math.sin(a) * dist]; }