Facebook
From Hot Echidna, 3 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 79
  1. function lstyle(elm){
  2. elm.style.display='inline-block';
  3. elm.style['text-align']="center";
  4. elm.style['font-size']="130%";
  5. elm.style['position']="absolute";
  6. return elm;
  7. }
  8.  
  9. function format(l){
  10. return l<10 ? '0'+l.toString() : l.toString();
  11. }
  12.  
  13. function isMouseInPosition ( cx, cy ,x, y, width, height ){
  14.         return ( ( cx >= x && cx <= x + width ) && ( cy >= y && cy <= y + height ) );
  15. }
  16.  
  17. function dist2D(x1,y1,x2,y2){
  18.         return Math.sqrt(Math.pow(x2-x1,2)+Math.pow(y2-y1,2));
  19. }
  20.  
  21. function Mathdeg(radians){
  22.   return radians * (180/Math.PI);}
  23.  
  24. function Mathrad(degrees){
  25.   return degrees * (Math.PI/180);}
  26.  
  27. function findRotation( x1, y1, x2, y2 ){
  28.     let t = -1*Mathdeg( Math.atan2( x2 - x1, y2 - y1 ) );
  29.     return t < 0 ? t + 360 : t;
  30. }
  31.  
  32. function getPointFromDistanceRotation(x, y, dist, angle){
  33.     let a = Mathrad(90 - angle);
  34.     return [x+Math.cos(a) * dist, y+Math.sin(a) * dist];
  35. }