pxt-common-packages 12.3.2 → 12.3.4
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.
- package/built/common-sim.d.ts +4 -0
- package/built/common-sim.js +275 -0
- package/libs/azureiot/built/debug/binary.js +461 -461
- package/libs/base/configkeys.h +2 -0
- package/libs/base/pxtbase.h +12 -1
- package/libs/browser-events/browserEvents.ts +9 -9
- package/libs/color/built/debug/binary.js +8 -8
- package/libs/color-sensor/built/debug/binary.js +8 -8
- package/libs/controller/built/debug/binary.js +9969 -8494
- package/libs/controller---none/built/debug/binary.js +9948 -8473
- package/libs/datalogger/built/debug/binary.js +63 -63
- package/libs/edge-connector/built/debug/binary.js +8 -8
- package/libs/esp32/built/debug/binary.js +462 -462
- package/libs/game/_locales/game-strings.json +4 -0
- package/libs/game/built/debug/binary.js +9861 -8386
- package/libs/game/hitbox.ts +13 -9
- package/libs/game/pxt.json +1 -0
- package/libs/game/rotation.ts +194 -0
- package/libs/game/sprite.ts +102 -8
- package/libs/lcd/built/debug/binary.js +8 -8
- package/libs/light-spectrum-sensor/built/debug/binary.js +9 -9
- package/libs/lora/built/debug/binary.js +8 -8
- package/libs/matrix-keypad/built/debug/binary.js +8 -8
- package/libs/mqtt/built/debug/binary.js +176 -176
- package/libs/net/built/debug/binary.js +176 -176
- package/libs/net-game/built/debug/binary.js +11768 -10293
- package/libs/palette/built/debug/binary.js +9860 -8385
- package/libs/pixel/built/debug/binary.js +8 -8
- package/libs/power/built/debug/binary.js +8 -8
- package/libs/proximity/built/debug/binary.js +8 -8
- package/libs/radio/built/debug/binary.js +8 -8
- package/libs/radio-broadcast/built/debug/binary.js +8 -8
- package/libs/rotary-encoder/built/debug/binary.js +8 -8
- package/libs/screen/built/debug/binary.js +50 -50
- package/libs/screen/image.cpp +374 -0
- package/libs/screen/image.ts +42 -0
- package/libs/screen/sim/image.ts +406 -0
- package/libs/servo/built/debug/binary.js +8 -8
- package/libs/settings/pxt.json +1 -0
- package/libs/settings/settings.cpp +21 -13
- package/libs/settings/targetoverrides.ts +6 -0
- package/libs/sprite-scaling/built/debug/binary.js +9860 -8385
- package/libs/storyboard/built/debug/binary.js +9860 -8385
- package/package.json +1 -1
package/built/common-sim.d.ts
CHANGED
|
@@ -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;
|
package/built/common-sim.js
CHANGED
|
@@ -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) {
|