pxt-arcade 2.0.45 → 2.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1256,6 +1256,10 @@ declare namespace pxsim.ImageMethods {
1256
1256
  function blitRow(img: RefImage, x: number, y: number, from: RefImage, fromX: number, fromH: number): void;
1257
1257
  function _blit(img: RefImage, src: RefImage, args: RefCollection): boolean;
1258
1258
  function blit(dst: RefImage, src: RefImage, args: RefCollection): boolean;
1259
+ function _drawScaledRotatedImage(dst: RefImage, src: RefImage, args: RefCollection): void;
1260
+ function drawScaledRotatedImage(dst: RefImage, src: RefImage, args: RefCollection): void;
1261
+ function _checkOverlapsScaledRotatedImage(dst: RefImage, src: RefImage, args: RefCollection): boolean;
1262
+ function _checkOverlapsTwoScaledRotatedImages(dst: RefImage, src: RefImage, args: RefCollection): boolean;
1259
1263
  }
1260
1264
  declare namespace pxsim.image {
1261
1265
  function byteHeight(h: number, bpp: number): number;
@@ -4977,6 +4977,281 @@ var pxsim;
4977
4977
  return false;
4978
4978
  }
4979
4979
  ImageMethods.blit = blit;
4980
+ const TWO_PI = 2 * Math.PI;
4981
+ const HALF_PI = Math.PI / 2;
4982
+ const THREE_HALF_PI = 3 * Math.PI / 2;
4983
+ const FX_ONE = 1;
4984
+ function fxMul(a, b) {
4985
+ return (a * b);
4986
+ }
4987
+ function fxDiv(a, b) {
4988
+ return a / b;
4989
+ }
4990
+ function fxToInt(v) {
4991
+ return v;
4992
+ }
4993
+ function fxFloor(v) {
4994
+ return v | 0;
4995
+ }
4996
+ function parseShearArgs(src, args, argIndex) {
4997
+ const parsed = {
4998
+ sx: 0,
4999
+ sy: 0,
5000
+ scaledWidth: 0,
5001
+ scaledHeight: 0,
5002
+ minX: 0,
5003
+ minY: 0,
5004
+ maxX: 0,
5005
+ maxY: 0,
5006
+ xShear: 0,
5007
+ yShear: 0,
5008
+ flip: false
5009
+ };
5010
+ const sx = (args.getAt(argIndex) * FX_ONE);
5011
+ const sy = (args.getAt(argIndex + 1) * FX_ONE);
5012
+ let angle = args.getAt(argIndex + 2);
5013
+ parsed.sx = sx;
5014
+ parsed.sy = sy;
5015
+ if (sx <= 0 || sy <= 0) {
5016
+ return parsed;
5017
+ }
5018
+ angle %= TWO_PI;
5019
+ if (angle < 0) {
5020
+ angle += TWO_PI;
5021
+ }
5022
+ let flip = false;
5023
+ if (angle > HALF_PI && angle <= THREE_HALF_PI) {
5024
+ flip = true;
5025
+ angle = (angle + Math.PI) % TWO_PI;
5026
+ }
5027
+ const xShear = (-Math.tan(angle / 2) * FX_ONE);
5028
+ const yShear = (Math.sin(angle) * FX_ONE);
5029
+ const scaledWidth = src._width * sx;
5030
+ const scaledHeight = src._height * sy;
5031
+ let shearedX = 0;
5032
+ let shearedY = 0;
5033
+ const SHEAR = (x, y) => {
5034
+ shearedX = fxFloor(x + fxMul(y, xShear));
5035
+ shearedY = fxFloor(y + fxMul(shearedX, yShear));
5036
+ shearedX = fxFloor(shearedX + fxMul(shearedY, xShear));
5037
+ };
5038
+ SHEAR(0, 0);
5039
+ let minX = shearedX;
5040
+ let minY = shearedY;
5041
+ let maxX = shearedX;
5042
+ let maxY = shearedY;
5043
+ SHEAR(scaledWidth - FX_ONE, 0);
5044
+ minX = Math.min(minX, shearedX);
5045
+ minY = Math.min(minY, shearedY);
5046
+ maxX = Math.max(maxX, shearedX);
5047
+ maxY = Math.max(maxY, shearedY);
5048
+ SHEAR(scaledWidth - FX_ONE, scaledHeight - FX_ONE);
5049
+ minX = Math.min(minX, shearedX);
5050
+ minY = Math.min(minY, shearedY);
5051
+ maxX = Math.max(maxX, shearedX);
5052
+ maxY = Math.max(maxY, shearedY);
5053
+ SHEAR(0, scaledHeight - FX_ONE);
5054
+ minX = Math.min(minX, shearedX);
5055
+ minY = Math.min(minY, shearedY);
5056
+ maxX = Math.max(maxX, shearedX);
5057
+ maxY = Math.max(maxY, shearedY);
5058
+ parsed.minX = minX;
5059
+ parsed.minY = minY;
5060
+ parsed.maxX = maxX;
5061
+ parsed.maxY = maxY;
5062
+ parsed.scaledWidth = scaledWidth;
5063
+ parsed.scaledHeight = scaledHeight;
5064
+ parsed.xShear = xShear;
5065
+ parsed.yShear = yShear;
5066
+ parsed.flip = flip;
5067
+ return parsed;
5068
+ }
5069
+ function _drawScaledRotatedImage(dst, src, args) {
5070
+ drawScaledRotatedImage(dst, src, args);
5071
+ }
5072
+ ImageMethods._drawScaledRotatedImage = _drawScaledRotatedImage;
5073
+ function drawScaledRotatedImage(dst, src, args) {
5074
+ const xDst = args.getAt(0);
5075
+ const yDst = args.getAt(1);
5076
+ if (xDst >= dst._width || yDst >= dst._height) {
5077
+ return;
5078
+ }
5079
+ const shearArgs = parseShearArgs(src, args, 2);
5080
+ if (shearArgs.sx <= 0 ||
5081
+ shearArgs.sy <= 0 ||
5082
+ xDst + fxToInt(shearArgs.maxX - shearArgs.minX) < 0 ||
5083
+ yDst + fxToInt(shearArgs.maxY - shearArgs.minY) < 0) {
5084
+ return;
5085
+ }
5086
+ let shearedX = 0;
5087
+ let shearedY = 0;
5088
+ const SHEAR = (x, y) => {
5089
+ shearedX = fxFloor(x + fxMul(y, shearArgs.xShear));
5090
+ shearedY = fxFloor(y + fxMul(shearedX, shearArgs.yShear));
5091
+ shearedX = fxFloor(shearedX + fxMul(shearedY, shearArgs.xShear));
5092
+ };
5093
+ dst.makeWritable();
5094
+ if (shearArgs.flip) {
5095
+ for (let y = 0; y < shearArgs.scaledHeight; y += FX_ONE) {
5096
+ for (let x = 0; x < shearArgs.scaledWidth; x += FX_ONE) {
5097
+ let color = getPixel(src, fxToInt(fxDiv((shearArgs.scaledWidth - x - FX_ONE), shearArgs.sx)), fxToInt(fxDiv((shearArgs.scaledHeight - y - FX_ONE), shearArgs.sy)));
5098
+ if (!color)
5099
+ continue;
5100
+ SHEAR(x, y);
5101
+ setPixel(dst, xDst + fxToInt(shearedX - shearArgs.minX), yDst + fxToInt(shearedY - shearArgs.minY), color);
5102
+ }
5103
+ }
5104
+ }
5105
+ else {
5106
+ for (let y = 0; y < shearArgs.scaledHeight; y += FX_ONE) {
5107
+ for (let x = 0; x < shearArgs.scaledWidth; x += FX_ONE) {
5108
+ let color = getPixel(src, fxToInt(fxDiv(x, shearArgs.sx)), fxToInt(fxDiv(y, shearArgs.sy)));
5109
+ if (!color)
5110
+ continue;
5111
+ SHEAR(x, y);
5112
+ setPixel(dst, xDst + fxToInt(shearedX - shearArgs.minX), yDst + fxToInt(shearedY - shearArgs.minY), color);
5113
+ }
5114
+ }
5115
+ }
5116
+ }
5117
+ ImageMethods.drawScaledRotatedImage = drawScaledRotatedImage;
5118
+ function _checkOverlapsScaledRotatedImage(dst, src, args) {
5119
+ const xDst = args.getAt(0);
5120
+ const yDst = args.getAt(1);
5121
+ if (xDst >= dst._width || yDst >= dst._height) {
5122
+ return false;
5123
+ }
5124
+ const shearArgs = parseShearArgs(src, args, 2);
5125
+ if (shearArgs.sx <= 0 ||
5126
+ shearArgs.sy <= 0 ||
5127
+ xDst + fxToInt(shearArgs.maxX - shearArgs.minX) < 0 ||
5128
+ yDst + fxToInt(shearArgs.maxY - shearArgs.minY) < 0) {
5129
+ return false;
5130
+ }
5131
+ let shearedX = 0;
5132
+ let shearedY = 0;
5133
+ const SHEAR = (x, y) => {
5134
+ shearedX = fxFloor(x + fxMul(y, shearArgs.xShear));
5135
+ shearedY = fxFloor(y + fxMul(shearedX, shearArgs.yShear));
5136
+ shearedX = fxFloor(shearedX + fxMul(shearedY, shearArgs.xShear));
5137
+ };
5138
+ if (shearArgs.flip) {
5139
+ for (let y = 0; y < shearArgs.scaledHeight; y += FX_ONE) {
5140
+ for (let x = 0; x < shearArgs.scaledWidth; x += FX_ONE) {
5141
+ let color = getPixel(src, fxToInt(fxDiv((shearArgs.scaledWidth - x - FX_ONE), shearArgs.sx)), fxToInt(fxDiv((shearArgs.scaledHeight - y - FX_ONE), shearArgs.sy)));
5142
+ if (!color)
5143
+ continue;
5144
+ SHEAR(x, y);
5145
+ if (getPixel(dst, xDst + fxToInt(shearedX - shearArgs.minX), yDst + fxToInt(shearedY - shearArgs.minY))) {
5146
+ return true;
5147
+ }
5148
+ }
5149
+ }
5150
+ }
5151
+ else {
5152
+ for (let y = 0; y < shearArgs.scaledHeight; y += FX_ONE) {
5153
+ for (let x = 0; x < shearArgs.scaledWidth; x += FX_ONE) {
5154
+ let color = getPixel(src, fxToInt(fxDiv(x, shearArgs.sx)), fxToInt(fxDiv(y, shearArgs.sy)));
5155
+ if (!color)
5156
+ continue;
5157
+ SHEAR(x, y);
5158
+ if (getPixel(dst, xDst + fxToInt(shearedX - shearArgs.minX), yDst + fxToInt(shearedY - shearArgs.minY))) {
5159
+ return true;
5160
+ }
5161
+ }
5162
+ }
5163
+ }
5164
+ return false;
5165
+ }
5166
+ ImageMethods._checkOverlapsScaledRotatedImage = _checkOverlapsScaledRotatedImage;
5167
+ function _checkOverlapsTwoScaledRotatedImages(dst, src, args) {
5168
+ const xDst = args.getAt(0);
5169
+ const yDst = args.getAt(1);
5170
+ const dstArgs = parseShearArgs(dst, args, 2);
5171
+ if (dstArgs.sx <= 0 ||
5172
+ dstArgs.sy <= 0 ||
5173
+ xDst >= dstArgs.maxX - dstArgs.minX ||
5174
+ yDst >= dstArgs.maxY - dstArgs.minY) {
5175
+ return false;
5176
+ }
5177
+ const srcArgs = parseShearArgs(src, args, 5);
5178
+ if (srcArgs.sx <= 0 ||
5179
+ srcArgs.sy <= 0 ||
5180
+ xDst + srcArgs.maxX - srcArgs.minX < 0 ||
5181
+ yDst + srcArgs.maxY - srcArgs.minY < 0) {
5182
+ return false;
5183
+ }
5184
+ let shearedX = 0;
5185
+ let shearedY = 0;
5186
+ let unshearedX = 0;
5187
+ let unshearedY = 0;
5188
+ const SHEAR = (x, y, xShear, yShear) => {
5189
+ shearedX = fxFloor(x + fxMul(y, xShear));
5190
+ shearedY = fxFloor(y + fxMul(shearedX, yShear));
5191
+ shearedX = fxFloor(shearedX + fxMul(shearedY, xShear));
5192
+ };
5193
+ const REVERSE_SHEAR = (x, y, xShear, yShear) => {
5194
+ unshearedX = fxFloor(x - fxMul(y, xShear));
5195
+ unshearedY = fxFloor(y - fxMul(unshearedX, yShear));
5196
+ unshearedX = fxFloor(unshearedX - fxMul(unshearedY, xShear));
5197
+ };
5198
+ if (srcArgs.flip) {
5199
+ for (let y = 0; y < srcArgs.scaledHeight; y += FX_ONE) {
5200
+ for (let x = 0; x < srcArgs.scaledWidth; x += FX_ONE) {
5201
+ let color = getPixel(src, fxToInt(fxDiv((srcArgs.scaledWidth - x - FX_ONE), srcArgs.sx)), fxToInt(fxDiv((srcArgs.scaledHeight - y - FX_ONE), srcArgs.sy)));
5202
+ if (!color)
5203
+ continue;
5204
+ SHEAR(x, y, srcArgs.xShear, srcArgs.yShear);
5205
+ const screenX = xDst + shearedX - srcArgs.minX;
5206
+ const screenY = yDst + shearedY - srcArgs.minY;
5207
+ if (screenX < 0 ||
5208
+ screenY < 0 ||
5209
+ screenX >= dstArgs.maxX - dstArgs.minX ||
5210
+ screenY >= dstArgs.maxY - dstArgs.minY) {
5211
+ continue;
5212
+ }
5213
+ REVERSE_SHEAR(screenX + dstArgs.minX, screenY + dstArgs.minY, dstArgs.xShear, dstArgs.yShear);
5214
+ if (dstArgs.flip) {
5215
+ if (getPixel(dst, fxToInt(fxDiv(dstArgs.scaledWidth - unshearedX - FX_ONE, dstArgs.sx)), fxToInt(fxDiv(dstArgs.scaledHeight - unshearedY - FX_ONE, dstArgs.sy)))) {
5216
+ return true;
5217
+ }
5218
+ }
5219
+ else if (getPixel(dst, fxToInt(fxDiv(unshearedX, dstArgs.sx)), fxToInt(fxDiv(unshearedY, dstArgs.sy)))) {
5220
+ return true;
5221
+ }
5222
+ }
5223
+ }
5224
+ }
5225
+ else {
5226
+ for (let y = 0; y < srcArgs.scaledHeight; y += FX_ONE) {
5227
+ for (let x = 0; x < srcArgs.scaledWidth; x += FX_ONE) {
5228
+ let color = getPixel(src, fxToInt(fxDiv(x, srcArgs.sx)), fxToInt(fxDiv(y, srcArgs.sy)));
5229
+ if (!color)
5230
+ continue;
5231
+ SHEAR(x, y, srcArgs.xShear, srcArgs.yShear);
5232
+ const screenX = xDst + shearedX - srcArgs.minX;
5233
+ const screenY = yDst + shearedY - srcArgs.minY;
5234
+ if (screenX < 0 ||
5235
+ screenY < 0 ||
5236
+ screenX >= dstArgs.maxX - dstArgs.minX ||
5237
+ screenY >= dstArgs.maxY - dstArgs.minY) {
5238
+ continue;
5239
+ }
5240
+ REVERSE_SHEAR(screenX + dstArgs.minX, screenY + dstArgs.minY, dstArgs.xShear, dstArgs.yShear);
5241
+ if (dstArgs.flip) {
5242
+ if (getPixel(dst, fxToInt(fxDiv(dstArgs.scaledWidth - unshearedX - FX_ONE, dstArgs.sx)), fxToInt(fxDiv(dstArgs.scaledHeight - unshearedY - FX_ONE, dstArgs.sy)))) {
5243
+ return true;
5244
+ }
5245
+ }
5246
+ else if (getPixel(dst, fxToInt(fxDiv(unshearedX, dstArgs.sx)), fxToInt(fxDiv(unshearedY, dstArgs.sy)))) {
5247
+ return true;
5248
+ }
5249
+ }
5250
+ }
5251
+ }
5252
+ return false;
5253
+ }
5254
+ ImageMethods._checkOverlapsTwoScaledRotatedImages = _checkOverlapsTwoScaledRotatedImages;
4980
5255
  })(ImageMethods = pxsim.ImageMethods || (pxsim.ImageMethods = {}));
4981
5256
  })(pxsim || (pxsim = {}));
4982
5257
  (function (pxsim) {
@@ -1 +1 @@
1
- {"Type your response using your keyboard and hit ENTER":"Type your response using your keyboard and hit ENTER","Unmute simulator":"Unmute simulator"}
1
+ {"Type your response using your keyboard and hit ENTER":"Type your response using your keyboard and hit ENTER"}
package/built/sim.js CHANGED
@@ -152,35 +152,6 @@ var pxsim;
152
152
  }
153
153
  })(pxsim || (pxsim = {}));
154
154
  var pxsim;
155
- (function (pxsim) {
156
- const icon = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!-- Font Awesome Pro 5.15.4 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) --><path d="M215.03 71.05L126.06 160H24c-13.26 0-24 10.74-24 24v144c0 13.25 10.74 24 24 24h102.06l88.97 88.95c15.03 15.03 40.97 4.47 40.97-16.97V88.02c0-21.46-25.96-31.98-40.97-16.97zM461.64 256l45.64-45.64c6.3-6.3 6.3-16.52 0-22.82l-22.82-22.82c-6.3-6.3-16.52-6.3-22.82 0L416 210.36l-45.64-45.64c-6.3-6.3-16.52-6.3-22.82 0l-22.82 22.82c-6.3 6.3-6.3 16.52 0 22.82L370.36 256l-45.63 45.63c-6.3 6.3-6.3 16.52 0 22.82l22.82 22.82c6.3 6.3 16.52 6.3 22.82 0L416 301.64l45.64 45.64c6.3 6.3 16.52 6.3 22.82 0l22.82-22.82c6.3-6.3 6.3-16.52 0-22.82L461.64 256z"/></svg>`;
157
- // We only need to unmute from within the iframe once
158
- let hasUnmuted = false;
159
- function createMuteButton() {
160
- const el = document.createElement("div");
161
- el.setAttribute("id", "safari-mute-button-outer");
162
- el.innerHTML = `
163
- <button class="safari-mute-button">
164
- ${icon}
165
- </button>
166
- `;
167
- const button = el.firstElementChild;
168
- button.setAttribute("title", pxsim.localization.lf("Unmute simulator"));
169
- button.addEventListener("click", () => {
170
- pxsim.AudioContextManager.mute(false);
171
- pxsim.setParentMuteState("unmuted");
172
- button.remove();
173
- hasUnmuted = true;
174
- });
175
- return el;
176
- }
177
- pxsim.createMuteButton = createMuteButton;
178
- function shouldShowMute() {
179
- return isSafari() && !hasUnmuted;
180
- }
181
- pxsim.shouldShowMute = shouldShowMute;
182
- })(pxsim || (pxsim = {}));
183
- var pxsim;
184
155
  (function (pxsim) {
185
156
  let forcedUpdateLoop;
186
157
  let isFirstRunSafari = true;
@@ -259,13 +230,8 @@ var pxsim;
259
230
  //event.preventDefault();
260
231
  // map canvas coordinates to arcade screen coordinates
261
232
  const rect = canvas.getBoundingClientRect();
262
- const aspectRatio = canvas.height / canvas.width;
263
- const actualWidth = Math.min(rect.height / aspectRatio, rect.width);
264
- const actualHeight = Math.min(rect.width * aspectRatio, rect.height);
265
- let xOffset = (rect.width - actualWidth) / 2;
266
- let yOffset = (rect.height - actualHeight) / 2;
267
- const x = ((event.clientX - rect.left - xOffset) / actualWidth) * canvas.width;
268
- const y = ((event.clientY - rect.top - yOffset) / actualHeight) * canvas.height;
233
+ const x = ((event.clientX - rect.left) / rect.width) * canvas.width;
234
+ const y = ((event.clientY - rect.top) / rect.height) * canvas.height;
269
235
  if (!isMultiplayerSession()) {
270
236
  board().mouseState.onEvent(event, x, y);
271
237
  }
@@ -629,7 +595,6 @@ var pxsim;
629
595
  }
630
596
  resize() { }
631
597
  async initAsync(msg) {
632
- var _a;
633
598
  this.runOptions = msg;
634
599
  this.stats = document.getElementById("debug-stats");
635
600
  this.stats.className = "stats no-select";
@@ -650,13 +615,6 @@ var pxsim;
650
615
  }
651
616
  this.setActivePlayer(msg.activePlayer, theme);
652
617
  this.updateStats();
653
- if (((_a = msg.options) === null || _a === void 0 ? void 0 : _a.mpRole) !== "server") {
654
- if (pxsim.shouldShowMute()) {
655
- document.body.appendChild(pxsim.createMuteButton());
656
- pxsim.AudioContextManager.mute(true);
657
- pxsim.setParentMuteState("disabled");
658
- }
659
- }
660
618
  let safariEnablePromise;
661
619
  if (isFirstRunSafari && !safariEnablePromise) {
662
620
  const safariWarning = document.getElementById("safari-enable-game");
@@ -2672,6 +2630,281 @@ var pxsim;
2672
2630
  return false;
2673
2631
  }
2674
2632
  ImageMethods.blit = blit;
2633
+ const TWO_PI = 2 * Math.PI;
2634
+ const HALF_PI = Math.PI / 2;
2635
+ const THREE_HALF_PI = 3 * Math.PI / 2;
2636
+ const FX_ONE = 1;
2637
+ function fxMul(a, b) {
2638
+ return (a * b);
2639
+ }
2640
+ function fxDiv(a, b) {
2641
+ return a / b;
2642
+ }
2643
+ function fxToInt(v) {
2644
+ return v;
2645
+ }
2646
+ function fxFloor(v) {
2647
+ return v | 0;
2648
+ }
2649
+ function parseShearArgs(src, args, argIndex) {
2650
+ const parsed = {
2651
+ sx: 0,
2652
+ sy: 0,
2653
+ scaledWidth: 0,
2654
+ scaledHeight: 0,
2655
+ minX: 0,
2656
+ minY: 0,
2657
+ maxX: 0,
2658
+ maxY: 0,
2659
+ xShear: 0,
2660
+ yShear: 0,
2661
+ flip: false
2662
+ };
2663
+ const sx = (args.getAt(argIndex) * FX_ONE);
2664
+ const sy = (args.getAt(argIndex + 1) * FX_ONE);
2665
+ let angle = args.getAt(argIndex + 2);
2666
+ parsed.sx = sx;
2667
+ parsed.sy = sy;
2668
+ if (sx <= 0 || sy <= 0) {
2669
+ return parsed;
2670
+ }
2671
+ angle %= TWO_PI;
2672
+ if (angle < 0) {
2673
+ angle += TWO_PI;
2674
+ }
2675
+ let flip = false;
2676
+ if (angle > HALF_PI && angle <= THREE_HALF_PI) {
2677
+ flip = true;
2678
+ angle = (angle + Math.PI) % TWO_PI;
2679
+ }
2680
+ const xShear = (-Math.tan(angle / 2) * FX_ONE);
2681
+ const yShear = (Math.sin(angle) * FX_ONE);
2682
+ const scaledWidth = src._width * sx;
2683
+ const scaledHeight = src._height * sy;
2684
+ let shearedX = 0;
2685
+ let shearedY = 0;
2686
+ const SHEAR = (x, y) => {
2687
+ shearedX = fxFloor(x + fxMul(y, xShear));
2688
+ shearedY = fxFloor(y + fxMul(shearedX, yShear));
2689
+ shearedX = fxFloor(shearedX + fxMul(shearedY, xShear));
2690
+ };
2691
+ SHEAR(0, 0);
2692
+ let minX = shearedX;
2693
+ let minY = shearedY;
2694
+ let maxX = shearedX;
2695
+ let maxY = shearedY;
2696
+ SHEAR(scaledWidth - FX_ONE, 0);
2697
+ minX = Math.min(minX, shearedX);
2698
+ minY = Math.min(minY, shearedY);
2699
+ maxX = Math.max(maxX, shearedX);
2700
+ maxY = Math.max(maxY, shearedY);
2701
+ SHEAR(scaledWidth - FX_ONE, scaledHeight - FX_ONE);
2702
+ minX = Math.min(minX, shearedX);
2703
+ minY = Math.min(minY, shearedY);
2704
+ maxX = Math.max(maxX, shearedX);
2705
+ maxY = Math.max(maxY, shearedY);
2706
+ SHEAR(0, scaledHeight - FX_ONE);
2707
+ minX = Math.min(minX, shearedX);
2708
+ minY = Math.min(minY, shearedY);
2709
+ maxX = Math.max(maxX, shearedX);
2710
+ maxY = Math.max(maxY, shearedY);
2711
+ parsed.minX = minX;
2712
+ parsed.minY = minY;
2713
+ parsed.maxX = maxX;
2714
+ parsed.maxY = maxY;
2715
+ parsed.scaledWidth = scaledWidth;
2716
+ parsed.scaledHeight = scaledHeight;
2717
+ parsed.xShear = xShear;
2718
+ parsed.yShear = yShear;
2719
+ parsed.flip = flip;
2720
+ return parsed;
2721
+ }
2722
+ function _drawScaledRotatedImage(dst, src, args) {
2723
+ drawScaledRotatedImage(dst, src, args);
2724
+ }
2725
+ ImageMethods._drawScaledRotatedImage = _drawScaledRotatedImage;
2726
+ function drawScaledRotatedImage(dst, src, args) {
2727
+ const xDst = args.getAt(0);
2728
+ const yDst = args.getAt(1);
2729
+ if (xDst >= dst._width || yDst >= dst._height) {
2730
+ return;
2731
+ }
2732
+ const shearArgs = parseShearArgs(src, args, 2);
2733
+ if (shearArgs.sx <= 0 ||
2734
+ shearArgs.sy <= 0 ||
2735
+ xDst + fxToInt(shearArgs.maxX - shearArgs.minX) < 0 ||
2736
+ yDst + fxToInt(shearArgs.maxY - shearArgs.minY) < 0) {
2737
+ return;
2738
+ }
2739
+ let shearedX = 0;
2740
+ let shearedY = 0;
2741
+ const SHEAR = (x, y) => {
2742
+ shearedX = fxFloor(x + fxMul(y, shearArgs.xShear));
2743
+ shearedY = fxFloor(y + fxMul(shearedX, shearArgs.yShear));
2744
+ shearedX = fxFloor(shearedX + fxMul(shearedY, shearArgs.xShear));
2745
+ };
2746
+ dst.makeWritable();
2747
+ if (shearArgs.flip) {
2748
+ for (let y = 0; y < shearArgs.scaledHeight; y += FX_ONE) {
2749
+ for (let x = 0; x < shearArgs.scaledWidth; x += FX_ONE) {
2750
+ let color = getPixel(src, fxToInt(fxDiv((shearArgs.scaledWidth - x - FX_ONE), shearArgs.sx)), fxToInt(fxDiv((shearArgs.scaledHeight - y - FX_ONE), shearArgs.sy)));
2751
+ if (!color)
2752
+ continue;
2753
+ SHEAR(x, y);
2754
+ setPixel(dst, xDst + fxToInt(shearedX - shearArgs.minX), yDst + fxToInt(shearedY - shearArgs.minY), color);
2755
+ }
2756
+ }
2757
+ }
2758
+ else {
2759
+ for (let y = 0; y < shearArgs.scaledHeight; y += FX_ONE) {
2760
+ for (let x = 0; x < shearArgs.scaledWidth; x += FX_ONE) {
2761
+ let color = getPixel(src, fxToInt(fxDiv(x, shearArgs.sx)), fxToInt(fxDiv(y, shearArgs.sy)));
2762
+ if (!color)
2763
+ continue;
2764
+ SHEAR(x, y);
2765
+ setPixel(dst, xDst + fxToInt(shearedX - shearArgs.minX), yDst + fxToInt(shearedY - shearArgs.minY), color);
2766
+ }
2767
+ }
2768
+ }
2769
+ }
2770
+ ImageMethods.drawScaledRotatedImage = drawScaledRotatedImage;
2771
+ function _checkOverlapsScaledRotatedImage(dst, src, args) {
2772
+ const xDst = args.getAt(0);
2773
+ const yDst = args.getAt(1);
2774
+ if (xDst >= dst._width || yDst >= dst._height) {
2775
+ return false;
2776
+ }
2777
+ const shearArgs = parseShearArgs(src, args, 2);
2778
+ if (shearArgs.sx <= 0 ||
2779
+ shearArgs.sy <= 0 ||
2780
+ xDst + fxToInt(shearArgs.maxX - shearArgs.minX) < 0 ||
2781
+ yDst + fxToInt(shearArgs.maxY - shearArgs.minY) < 0) {
2782
+ return false;
2783
+ }
2784
+ let shearedX = 0;
2785
+ let shearedY = 0;
2786
+ const SHEAR = (x, y) => {
2787
+ shearedX = fxFloor(x + fxMul(y, shearArgs.xShear));
2788
+ shearedY = fxFloor(y + fxMul(shearedX, shearArgs.yShear));
2789
+ shearedX = fxFloor(shearedX + fxMul(shearedY, shearArgs.xShear));
2790
+ };
2791
+ if (shearArgs.flip) {
2792
+ for (let y = 0; y < shearArgs.scaledHeight; y += FX_ONE) {
2793
+ for (let x = 0; x < shearArgs.scaledWidth; x += FX_ONE) {
2794
+ let color = getPixel(src, fxToInt(fxDiv((shearArgs.scaledWidth - x - FX_ONE), shearArgs.sx)), fxToInt(fxDiv((shearArgs.scaledHeight - y - FX_ONE), shearArgs.sy)));
2795
+ if (!color)
2796
+ continue;
2797
+ SHEAR(x, y);
2798
+ if (getPixel(dst, xDst + fxToInt(shearedX - shearArgs.minX), yDst + fxToInt(shearedY - shearArgs.minY))) {
2799
+ return true;
2800
+ }
2801
+ }
2802
+ }
2803
+ }
2804
+ else {
2805
+ for (let y = 0; y < shearArgs.scaledHeight; y += FX_ONE) {
2806
+ for (let x = 0; x < shearArgs.scaledWidth; x += FX_ONE) {
2807
+ let color = getPixel(src, fxToInt(fxDiv(x, shearArgs.sx)), fxToInt(fxDiv(y, shearArgs.sy)));
2808
+ if (!color)
2809
+ continue;
2810
+ SHEAR(x, y);
2811
+ if (getPixel(dst, xDst + fxToInt(shearedX - shearArgs.minX), yDst + fxToInt(shearedY - shearArgs.minY))) {
2812
+ return true;
2813
+ }
2814
+ }
2815
+ }
2816
+ }
2817
+ return false;
2818
+ }
2819
+ ImageMethods._checkOverlapsScaledRotatedImage = _checkOverlapsScaledRotatedImage;
2820
+ function _checkOverlapsTwoScaledRotatedImages(dst, src, args) {
2821
+ const xDst = args.getAt(0);
2822
+ const yDst = args.getAt(1);
2823
+ const dstArgs = parseShearArgs(dst, args, 2);
2824
+ if (dstArgs.sx <= 0 ||
2825
+ dstArgs.sy <= 0 ||
2826
+ xDst >= dstArgs.maxX - dstArgs.minX ||
2827
+ yDst >= dstArgs.maxY - dstArgs.minY) {
2828
+ return false;
2829
+ }
2830
+ const srcArgs = parseShearArgs(src, args, 5);
2831
+ if (srcArgs.sx <= 0 ||
2832
+ srcArgs.sy <= 0 ||
2833
+ xDst + srcArgs.maxX - srcArgs.minX < 0 ||
2834
+ yDst + srcArgs.maxY - srcArgs.minY < 0) {
2835
+ return false;
2836
+ }
2837
+ let shearedX = 0;
2838
+ let shearedY = 0;
2839
+ let unshearedX = 0;
2840
+ let unshearedY = 0;
2841
+ const SHEAR = (x, y, xShear, yShear) => {
2842
+ shearedX = fxFloor(x + fxMul(y, xShear));
2843
+ shearedY = fxFloor(y + fxMul(shearedX, yShear));
2844
+ shearedX = fxFloor(shearedX + fxMul(shearedY, xShear));
2845
+ };
2846
+ const REVERSE_SHEAR = (x, y, xShear, yShear) => {
2847
+ unshearedX = fxFloor(x - fxMul(y, xShear));
2848
+ unshearedY = fxFloor(y - fxMul(unshearedX, yShear));
2849
+ unshearedX = fxFloor(unshearedX - fxMul(unshearedY, xShear));
2850
+ };
2851
+ if (srcArgs.flip) {
2852
+ for (let y = 0; y < srcArgs.scaledHeight; y += FX_ONE) {
2853
+ for (let x = 0; x < srcArgs.scaledWidth; x += FX_ONE) {
2854
+ let color = getPixel(src, fxToInt(fxDiv((srcArgs.scaledWidth - x - FX_ONE), srcArgs.sx)), fxToInt(fxDiv((srcArgs.scaledHeight - y - FX_ONE), srcArgs.sy)));
2855
+ if (!color)
2856
+ continue;
2857
+ SHEAR(x, y, srcArgs.xShear, srcArgs.yShear);
2858
+ const screenX = xDst + shearedX - srcArgs.minX;
2859
+ const screenY = yDst + shearedY - srcArgs.minY;
2860
+ if (screenX < 0 ||
2861
+ screenY < 0 ||
2862
+ screenX >= dstArgs.maxX - dstArgs.minX ||
2863
+ screenY >= dstArgs.maxY - dstArgs.minY) {
2864
+ continue;
2865
+ }
2866
+ REVERSE_SHEAR(screenX + dstArgs.minX, screenY + dstArgs.minY, dstArgs.xShear, dstArgs.yShear);
2867
+ if (dstArgs.flip) {
2868
+ if (getPixel(dst, fxToInt(fxDiv(dstArgs.scaledWidth - unshearedX - FX_ONE, dstArgs.sx)), fxToInt(fxDiv(dstArgs.scaledHeight - unshearedY - FX_ONE, dstArgs.sy)))) {
2869
+ return true;
2870
+ }
2871
+ }
2872
+ else if (getPixel(dst, fxToInt(fxDiv(unshearedX, dstArgs.sx)), fxToInt(fxDiv(unshearedY, dstArgs.sy)))) {
2873
+ return true;
2874
+ }
2875
+ }
2876
+ }
2877
+ }
2878
+ else {
2879
+ for (let y = 0; y < srcArgs.scaledHeight; y += FX_ONE) {
2880
+ for (let x = 0; x < srcArgs.scaledWidth; x += FX_ONE) {
2881
+ let color = getPixel(src, fxToInt(fxDiv(x, srcArgs.sx)), fxToInt(fxDiv(y, srcArgs.sy)));
2882
+ if (!color)
2883
+ continue;
2884
+ SHEAR(x, y, srcArgs.xShear, srcArgs.yShear);
2885
+ const screenX = xDst + shearedX - srcArgs.minX;
2886
+ const screenY = yDst + shearedY - srcArgs.minY;
2887
+ if (screenX < 0 ||
2888
+ screenY < 0 ||
2889
+ screenX >= dstArgs.maxX - dstArgs.minX ||
2890
+ screenY >= dstArgs.maxY - dstArgs.minY) {
2891
+ continue;
2892
+ }
2893
+ REVERSE_SHEAR(screenX + dstArgs.minX, screenY + dstArgs.minY, dstArgs.xShear, dstArgs.yShear);
2894
+ if (dstArgs.flip) {
2895
+ if (getPixel(dst, fxToInt(fxDiv(dstArgs.scaledWidth - unshearedX - FX_ONE, dstArgs.sx)), fxToInt(fxDiv(dstArgs.scaledHeight - unshearedY - FX_ONE, dstArgs.sy)))) {
2896
+ return true;
2897
+ }
2898
+ }
2899
+ else if (getPixel(dst, fxToInt(fxDiv(unshearedX, dstArgs.sx)), fxToInt(fxDiv(unshearedY, dstArgs.sy)))) {
2900
+ return true;
2901
+ }
2902
+ }
2903
+ }
2904
+ }
2905
+ return false;
2906
+ }
2907
+ ImageMethods._checkOverlapsTwoScaledRotatedImages = _checkOverlapsTwoScaledRotatedImages;
2675
2908
  })(ImageMethods = pxsim.ImageMethods || (pxsim.ImageMethods = {}));
2676
2909
  })(pxsim || (pxsim = {}));
2677
2910
  (function (pxsim) {