daily pastebin goal
0%
SHARE
TWEET

Untitled

a guest May 11th, 2017 30 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function getBodySize() {
  2.    
  3.         var w = window,
  4.         d = document,
  5.         e = d.documentElement,
  6.         g = d.getElementsByTagName('body')[0],
  7.         x = w.innerWidth || e.clientWidth || g.clientWidth,
  8.         y = w.innerHeight|| e.clientHeight|| g.clientHeight;
  9.        
  10.         if (x != Body_W || y != Body_H) {
  11.             Body_W = x;
  12.             Body_H = y;
  13.             resizeCanvas();
  14.         }  
  15.     }
  16.  
  17.     function resizeCanvas() {
  18.         var new_canvas_W = W;
  19.         var new_canvas_H = H;
  20.  
  21.         if (W > Body_W || H > Body_H) {
  22.             new_canvas_W = Body_W;
  23.             new_canvas_H = H / 1024 * Body_W;
  24.        
  25.             if (H > Body_H) {
  26.                 new_canvas_W =  W / 720 * Body_H ;
  27.                 new_canvas_H = Body_H;
  28.             }  
  29.         }
  30.    
  31.         if (new_canvas_W != canvas.width  || new_canvas_H != canvas.height) {
  32.             canvas.width  = new_canvas_W;
  33.             canvas.height = new_canvas_H;
  34.         }
  35.        
  36.         stage.scaleX = new_canvas_W / 1024;
  37.         stage.scaleY = new_canvas_H / 720;
  38.    
  39.         stage.update();
  40.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top