Advertisement
Guest User

Untitled

a guest
Apr 16th, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. (function () {
  3.     /* ОПЦИИ */
  4.     var IMAGE_URL = 'https://2ch.hk/to/src/50162/14922528037800.png';
  5.     var OX = 1347, OY = 930;
  6.     var ALPHA = 0.5;
  7.     /* ХУЁПЦИИ */
  8.  
  9.     var template_canvas = document.createElement('canvas');
  10.     template_canvas.width = window.App.elements.board[0].width;
  11.     template_canvas.height = window.App.elements.board[0].height;
  12.  
  13.     var ctx_tc = template_canvas.getContext('2d');
  14.  
  15.     template_image = new Image();
  16.     template_image.onload = function() {
  17.         console.log('Drawing ' + IMAGE_URL + ' @ ' + OX + ',' + OY +'...')
  18.         ctx_tc.globalAlpha = ALPHA;
  19.         ctx_tc.drawImage(template_image, OX, OY);
  20.     }
  21.     template_image.src = IMAGE_URL
  22.  
  23.     // Copypasta from https://github.com/xSke/Pxls/blob/master/resources/public/app.js
  24.     // Patched version
  25.     window.App.updateTransform = function () {
  26.         this.panX = Math.min(this.width / 2, Math.max(-this.width / 2, this.panX));
  27.         this.panY = Math.min(this.height / 2, Math.max(-this.height / 2, this.panY));
  28.         if (this.use_js_resize) {
  29.             var ctx2 = this.elements.board_render[0].getContext("2d");
  30.             var pxl_x = -this.panX + ((this.width - (window.innerWidth / this.scale)) / 2);
  31.             var pxl_y = -this.panY + ((this.height - (window.innerHeight / this.scale)) / 2);
  32.            
  33.             ctx2.fillStyle = '#CCCCCC';
  34.             ctx2.fillRect(0, 0, ctx2.canvas.width, ctx2.canvas.height);
  35.             ctx2.drawImage(this.elements.board[0], pxl_x, pxl_y, window.innerWidth / this.scale, window.innerHeight / this.scale, 0, 0, window.innerWidth, window.innerHeight);
  36.             ctx2.drawImage(template_canvas, pxl_x, pxl_y, window.innerWidth / this.scale, window.innerHeight / this.scale, 0, 0, window.innerWidth, window.innerHeight); // <- Добавляем вызов
  37.             return;
  38.         }
  39.         this.elements.boardMover
  40.             .css("width", this.width + "px")
  41.             .css("height", this.height + "px")
  42.             .css("transform", "translate(" + this.panX + "px, " + this.panY + "px)");
  43.         if (this.use_zoom) {
  44.             this.elements.boardZoomer.css("zoom", (this.scale * 100).toString() + "%");
  45.         } else {
  46.             this.elements.boardZoomer.css("transform", "scale(" + this.scale + ")");
  47.         }
  48.         this.elements.reticule.css("width", (this.scale + 1) + "px").css("height", (this.scale + 1) + "px");
  49.  
  50.         var a = this.screenToBoardSpace(0, 0);
  51.         this.elements.grid.css("background-size", this.scale + "px " + this.scale + "px").css("transform", "translate(" + Math.floor(-a.x % 1 * this.scale) + "px," + Math.floor(-a.y % 1 * this.scale) + "px)");
  52.         this.elements.grid.css("opacity", (this.scale - 2) / 6);
  53.     }
  54.  
  55. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement