pxt-common-packages 11.1.1 → 11.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.
Files changed (38) hide show
  1. package/built/common-sim.d.ts +6 -0
  2. package/built/common-sim.js +62 -29
  3. package/libs/azureiot/built/debug/binary.js +461 -461
  4. package/libs/color/built/debug/binary.js +8 -8
  5. package/libs/color-sensor/built/debug/binary.js +8 -8
  6. package/libs/controller/built/debug/binary.js +7986 -7953
  7. package/libs/controller---none/built/debug/binary.js +7965 -7932
  8. package/libs/datalogger/built/debug/binary.js +63 -63
  9. package/libs/edge-connector/built/debug/binary.js +8 -8
  10. package/libs/esp32/built/debug/binary.js +462 -462
  11. package/libs/game/built/debug/binary.js +7878 -7845
  12. package/libs/game/sprite.ts +2 -0
  13. package/libs/game/sprites.ts +1 -0
  14. package/libs/lcd/built/debug/binary.js +8 -8
  15. package/libs/light-spectrum-sensor/built/debug/binary.js +8 -8
  16. package/libs/lora/built/debug/binary.js +8 -8
  17. package/libs/matrix-keypad/built/debug/binary.js +8 -8
  18. package/libs/microphone/sim/state.ts +2 -0
  19. package/libs/mqtt/built/debug/binary.js +176 -176
  20. package/libs/net/built/debug/binary.js +176 -176
  21. package/libs/net-game/built/debug/binary.js +9666 -9633
  22. package/libs/palette/built/debug/binary.js +7877 -7844
  23. package/libs/pixel/built/debug/binary.js +8 -8
  24. package/libs/power/built/debug/binary.js +8 -8
  25. package/libs/proximity/built/debug/binary.js +8 -8
  26. package/libs/radio/built/debug/binary.js +8 -8
  27. package/libs/radio-broadcast/built/debug/binary.js +8 -8
  28. package/libs/rotary-encoder/built/debug/binary.js +8 -8
  29. package/libs/screen/built/debug/binary.js +50 -50
  30. package/libs/screen/sim/image.ts +32 -31
  31. package/libs/servo/built/debug/binary.js +8 -8
  32. package/libs/shader/pxt.json +14 -0
  33. package/libs/shader/shader.cpp +140 -0
  34. package/libs/shader/shader.ts +19 -0
  35. package/libs/shader/sim/shader.ts +37 -0
  36. package/libs/sprite-scaling/built/debug/binary.js +7877 -7844
  37. package/libs/storyboard/built/debug/binary.js +7877 -7844
  38. package/package.json +1 -1
@@ -1103,6 +1103,8 @@ declare namespace pxsim {
1103
1103
  }
1104
1104
  }
1105
1105
  declare namespace pxsim.ImageMethods {
1106
+ function XX(x: number): number;
1107
+ function YY(x: number): number;
1106
1108
  function width(img: RefImage): number;
1107
1109
  function height(img: RefImage): number;
1108
1110
  function isMono(img: RefImage): boolean;
@@ -1222,6 +1224,10 @@ declare namespace pxsim.settings {
1222
1224
  function _userClean(): void;
1223
1225
  function _list(prefix: string): RefCollection;
1224
1226
  }
1227
+ declare namespace pxsim.ShaderMethods {
1228
+ function _mergeImage(dst: RefImage, src: RefImage, xy: number): void;
1229
+ function _mapImage(dst: RefImage, src: RefImage, xy: number, buf: RefBuffer): void;
1230
+ }
1225
1231
  declare namespace pxsim {
1226
1232
  class StorageState {
1227
1233
  files: pxsim.Map<number[]>;
@@ -3179,6 +3179,7 @@ var pxsim;
3179
3179
  input.setLoudSoundThreshold = setLoudSoundThreshold;
3180
3180
  })(input = pxsim.input || (pxsim.input = {}));
3181
3181
  })(pxsim || (pxsim = {}));
3182
+ /// <reference path="../../core/sim/analogSensor.ts" />
3182
3183
  var pxsim;
3183
3184
  (function (pxsim) {
3184
3185
  class MicrophoneState extends pxsim.AnalogSensorState {
@@ -3792,7 +3793,9 @@ var pxsim;
3792
3793
  var ImageMethods;
3793
3794
  (function (ImageMethods) {
3794
3795
  function XX(x) { return (x << 16) >> 16; }
3796
+ ImageMethods.XX = XX;
3795
3797
  function YY(x) { return x >> 16; }
3798
+ ImageMethods.YY = YY;
3796
3799
  function width(img) { return img._width; }
3797
3800
  ImageMethods.width = width;
3798
3801
  function height(img) { return img._height; }
@@ -4236,57 +4239,58 @@ var pxsim;
4236
4239
  }
4237
4240
  ImageMethods.drawLine = drawLine;
4238
4241
  function drawIcon(img, icon, x, y, color) {
4239
- const img2 = icon.data;
4242
+ const src = icon.data;
4240
4243
  if (!pxsim.image.isValidImage(icon))
4241
4244
  return;
4242
- if (img2[1] != 1)
4245
+ if (src[1] != 1)
4243
4246
  return; // only mono
4244
- let w = pxsim.image.bufW(img2);
4245
- let h = pxsim.image.bufH(img2);
4246
- let byteH = pxsim.image.byteHeight(h, 1);
4247
+ let width = pxsim.image.bufW(src);
4248
+ let height = pxsim.image.bufH(src);
4249
+ let byteH = pxsim.image.byteHeight(height, 1);
4247
4250
  x |= 0;
4248
4251
  y |= 0;
4249
- const sh = img._height;
4250
- const sw = img._width;
4251
- if (x + w <= 0)
4252
+ const destHeight = img._height;
4253
+ const destWidth = img._width;
4254
+ if (x + width <= 0)
4252
4255
  return;
4253
- if (x >= sw)
4256
+ if (x >= destWidth)
4254
4257
  return;
4255
- if (y + h <= 0)
4258
+ if (y + height <= 0)
4256
4259
  return;
4257
- if (y >= sh)
4260
+ if (y >= destHeight)
4258
4261
  return;
4259
4262
  img.makeWritable();
4260
- let p = 8;
4263
+ let srcPointer = 8;
4261
4264
  color = img.color(color);
4262
4265
  const screen = img.data;
4263
- for (let i = 0; i < w; ++i) {
4264
- let xxx = x + i;
4265
- if (0 <= xxx && xxx < sw) {
4266
- let dst = xxx + y * sw;
4267
- let src = p;
4268
- let yy = y;
4269
- let end = Math.min(sh, h + y);
4266
+ for (let i = 0; i < width; ++i) {
4267
+ let destX = x + i;
4268
+ if (0 <= destX && destX < destWidth) {
4269
+ let destIndex = destX + y * destWidth;
4270
+ let srcIndex = srcPointer;
4271
+ let destY = y;
4272
+ let destEnd = Math.min(destHeight, height + y);
4270
4273
  if (y < 0) {
4271
- src += ((-y) >> 3);
4272
- yy += ((-y) >> 3) * 8;
4274
+ srcIndex += ((-y) >> 3);
4275
+ destY += ((-y) >> 3) * 8;
4276
+ destIndex += (destY - y) * destWidth;
4273
4277
  }
4274
4278
  let mask = 0x01;
4275
- let v = img2[src++];
4276
- while (yy < end) {
4277
- if (yy >= 0 && (v & mask)) {
4278
- screen[dst] = color;
4279
+ let srcByte = src[srcIndex++];
4280
+ while (destY < destEnd) {
4281
+ if (destY >= 0 && (srcByte & mask)) {
4282
+ screen[destIndex] = color;
4279
4283
  }
4280
4284
  mask <<= 1;
4281
4285
  if (mask == 0x100) {
4282
4286
  mask = 0x01;
4283
- v = img2[src++];
4287
+ srcByte = src[srcIndex++];
4284
4288
  }
4285
- dst += sw;
4286
- yy++;
4289
+ destIndex += destWidth;
4290
+ destY++;
4287
4291
  }
4288
4292
  }
4289
- p += byteH;
4293
+ srcPointer += byteH;
4290
4294
  }
4291
4295
  }
4292
4296
  ImageMethods.drawIcon = drawIcon;
@@ -5129,6 +5133,35 @@ var pxsim;
5129
5133
  settings._list = _list;
5130
5134
  })(settings = pxsim.settings || (pxsim.settings = {}));
5131
5135
  })(pxsim || (pxsim = {}));
5136
+ /// <reference path="../../screen/sim/image.ts" />
5137
+ var pxsim;
5138
+ (function (pxsim) {
5139
+ var ShaderMethods;
5140
+ (function (ShaderMethods) {
5141
+ function _mergeImage(dst, src, xy) {
5142
+ mergeImage(dst, src, pxsim.ImageMethods.XX(xy), pxsim.ImageMethods.YY(xy));
5143
+ }
5144
+ ShaderMethods._mergeImage = _mergeImage;
5145
+ function mergeImage(dst, src, x0, y0) {
5146
+ for (let x = 0; x < src._width; x++) {
5147
+ for (let y = 0; y < src._height; y++) {
5148
+ pxsim.ImageMethods.setPixel(dst, x0 + x, y0 + y, Math.min(pxsim.ImageMethods.getPixel(dst, x0 + x, y0 + y), pxsim.ImageMethods.getPixel(src, x, y)));
5149
+ }
5150
+ }
5151
+ }
5152
+ function _mapImage(dst, src, xy, buf) {
5153
+ mapImage(dst, src, pxsim.ImageMethods.XX(xy), pxsim.ImageMethods.YY(xy), buf);
5154
+ }
5155
+ ShaderMethods._mapImage = _mapImage;
5156
+ function mapImage(dst, src, x0, y0, buf) {
5157
+ for (let x = 0; x < src._width; x++) {
5158
+ for (let y = 0; y < src._height; y++) {
5159
+ pxsim.ImageMethods.setPixel(dst, x0 + x, y0 + y, buf.data[pxsim.ImageMethods.getPixel(dst, x0 + x, y0 + y) + (pxsim.ImageMethods.getPixel(src, x, y) << 4)]);
5160
+ }
5161
+ }
5162
+ }
5163
+ })(ShaderMethods = pxsim.ShaderMethods || (pxsim.ShaderMethods = {}));
5164
+ })(pxsim || (pxsim = {}));
5132
5165
  var pxsim;
5133
5166
  (function (pxsim) {
5134
5167
  class StorageState {