pxt-common-packages 9.4.4 → 9.4.8

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 (58) hide show
  1. package/built/common-sim.d.ts +3 -2
  2. package/built/common-sim.js +15 -1
  3. package/libs/azureiot/built/debug/binary.js +461 -461
  4. package/libs/color/built/debug/binary.js +8 -8
  5. package/libs/color/colors.ts +11 -0
  6. package/libs/color-sensor/built/debug/binary.js +8 -8
  7. package/libs/controller/built/debug/binary.js +9043 -7832
  8. package/libs/controller---none/built/debug/binary.js +9022 -7811
  9. package/libs/datalogger/built/debug/binary.js +63 -63
  10. package/libs/edge-connector/built/debug/binary.js +8 -8
  11. package/libs/esp32/built/debug/binary.js +462 -462
  12. package/libs/game/_locales/game-strings.json +21 -0
  13. package/libs/game/built/debug/binary.js +8935 -7724
  14. package/libs/game/hitbox.ts +40 -22
  15. package/libs/game/renderText.ts +74 -11
  16. package/libs/game/sprite.ts +244 -16
  17. package/libs/game/spritesay.ts +206 -53
  18. package/libs/lcd/built/debug/binary.js +8 -8
  19. package/libs/light-spectrum-sensor/built/debug/binary.js +8 -8
  20. package/libs/lora/built/debug/binary.js +8 -8
  21. package/libs/matrix-keypad/built/debug/binary.js +8 -8
  22. package/libs/mqtt/built/debug/binary.js +176 -176
  23. package/libs/net/built/debug/binary.js +176 -176
  24. package/libs/net/controller.ts +4 -0
  25. package/libs/net-game/built/debug/binary.js +10832 -9617
  26. package/libs/palette/built/debug/binary.js +8934 -7723
  27. package/libs/pixel/built/debug/binary.js +8 -8
  28. package/libs/power/built/debug/binary.js +8 -8
  29. package/libs/proximity/built/debug/binary.js +9 -9
  30. package/libs/radio/built/debug/binary.js +8 -8
  31. package/libs/radio-broadcast/built/debug/binary.js +8 -8
  32. package/libs/rotary-encoder/built/debug/binary.js +8 -8
  33. package/libs/screen/built/debug/binary.js +50 -50
  34. package/libs/screen/image.cpp +14 -4
  35. package/libs/screen/image.ts +5 -4
  36. package/libs/screen/sim/image.ts +15 -3
  37. package/libs/servo/built/debug/binary.js +8 -8
  38. package/libs/sprite-scaling/README.md +3 -0
  39. package/libs/sprite-scaling/_locales/sprite-scaling-jsdoc-strings.json +1 -0
  40. package/libs/sprite-scaling/_locales/sprite-scaling-strings.json +9 -0
  41. package/libs/sprite-scaling/built/debug/binary.js +40047 -0
  42. package/libs/sprite-scaling/pxt.json +16 -0
  43. package/libs/sprite-scaling/scaling.ts +111 -0
  44. package/libs/sprite-scaling/targetoverrides.ts +1 -0
  45. package/libs/sprite-scaling/test.ts +0 -0
  46. package/libs/storyboard/built/debug/binary.js +8934 -7723
  47. package/libs/wifi---esp32/buildlogin.sh +1 -0
  48. package/libs/wifi---esp32/controller.ts +19 -1
  49. package/libs/wifi---esp32/enums.d.ts +2 -0
  50. package/libs/wifi---esp32/httpserver.cpp +166 -0
  51. package/libs/wifi---esp32/login.full.html +37 -0
  52. package/libs/wifi---esp32/login.html +1 -0
  53. package/libs/wifi---esp32/pxt.json +1 -0
  54. package/libs/wifi---esp32/shims.d.ts +4 -0
  55. package/libs/wifi---esp32/sim/wifisockets.ts +3 -0
  56. package/libs/wifi---esp32/wifi.cpp +13 -14
  57. package/libs/wifi---esp32/wifi.h +13 -1
  58. package/package.json +1 -1
@@ -17,6 +17,206 @@ namespace sprites {
17
17
  }
18
18
 
19
19
  export class SpriteSayRenderer extends BaseSpriteSayRenderer {
20
+ static drawSayFrame(textLeft: number, textTop: number, textWidth: number, textHeight: number, speakerX: number, speakerY: number, color: number, canvas: Image) {
21
+ if (textLeft + textWidth < 0 || textTop + textHeight < 0 || textLeft > canvas.width || textTop > canvas.height) return;
22
+
23
+ if (textHeight) {
24
+ // Draw main rectangle
25
+ canvas.fillRect(
26
+ textLeft,
27
+ textTop,
28
+ textWidth,
29
+ textHeight,
30
+ color
31
+ );
32
+
33
+ // Draw lines around the rectangle to give it a bubble shape
34
+ canvas.fillRect(
35
+ textLeft - 1,
36
+ textTop + 1,
37
+ 1,
38
+ textHeight - 2,
39
+ color
40
+ );
41
+ canvas.fillRect(
42
+ textLeft + textWidth,
43
+ textTop + 1,
44
+ 1,
45
+ textHeight - 2,
46
+ color
47
+ );
48
+ canvas.fillRect(
49
+ textLeft + 1,
50
+ textTop - 1,
51
+ textWidth - 2,
52
+ 1,
53
+ color
54
+ );
55
+ canvas.fillRect(
56
+ textLeft + 1,
57
+ textTop + textHeight,
58
+ textWidth - 2,
59
+ 1,
60
+ color
61
+ );
62
+
63
+ // If the speaker location is within the bubble, don't draw an arrow
64
+ if (speakerX > textLeft && speakerX < textLeft + textWidth && speakerY > textTop && speakerY < textTop + textHeight) return;
65
+
66
+ const xDiff = Math.max(
67
+ Math.abs(speakerX - textLeft),
68
+ Math.abs(speakerX - (textLeft + textWidth))
69
+ );
70
+
71
+ const yDiff = Math.max(
72
+ Math.abs(speakerY - textHeight),
73
+ Math.abs(speakerY - (textHeight + textHeight))
74
+ );
75
+
76
+ // Draw the arrow
77
+ if (xDiff > yDiff) {
78
+ if (speakerX > textLeft + textWidth) {
79
+ const anchorY = Math.max(Math.min(speakerY, textTop + textHeight - 4), textTop + 5);
80
+ canvas.fillRect(
81
+ textLeft + textWidth + 1,
82
+ anchorY - 2,
83
+ 1,
84
+ 3,
85
+ color
86
+ );
87
+ canvas.fillRect(
88
+ textLeft + textWidth + 2,
89
+ anchorY - 1,
90
+ 1,
91
+ 1,
92
+ color
93
+ );
94
+ }
95
+ else if (speakerX < textLeft) {
96
+ const anchorY = Math.max(Math.min(speakerY, textTop + textHeight - 4), textTop + 5);
97
+ canvas.fillRect(
98
+ textLeft - 2,
99
+ anchorY - 2,
100
+ 1,
101
+ 3,
102
+ color
103
+ );
104
+ canvas.fillRect(
105
+ textLeft - 3,
106
+ anchorY - 1,
107
+ 1,
108
+ 1,
109
+ color
110
+ );
111
+ }
112
+ else if (speakerY > textTop + textHeight) {
113
+ const anchorX = Math.max(Math.min(speakerX, textLeft + textWidth - 4), textLeft + 5);
114
+ canvas.fillRect(
115
+ anchorX - 2,
116
+ textTop + textHeight + 1,
117
+ 3,
118
+ 1,
119
+ color
120
+ );
121
+ canvas.fillRect(
122
+ anchorX - 1,
123
+ textTop + textHeight + 2,
124
+ 1,
125
+ 1,
126
+ color
127
+ );
128
+ }
129
+ else if (speakerY < textTop) {
130
+ const anchorX = Math.max(Math.min(speakerX, textLeft + textWidth - 4), textLeft + 5);
131
+ canvas.fillRect(
132
+ anchorX - 2,
133
+ textTop - 2,
134
+ 3,
135
+ 1,
136
+ color
137
+ );
138
+ canvas.fillRect(
139
+ anchorX - 1,
140
+ textTop - 3,
141
+ 1,
142
+ 1,
143
+ color
144
+ );
145
+ }
146
+ }
147
+ else {
148
+ if (speakerY > textTop + textHeight) {
149
+ const anchorX = Math.max(Math.min(speakerX, textLeft + textWidth - 4), textLeft + 5);
150
+ canvas.fillRect(
151
+ anchorX - 2,
152
+ textTop + textHeight + 1,
153
+ 3,
154
+ 1,
155
+ color
156
+ );
157
+ canvas.fillRect(
158
+ anchorX - 1,
159
+ textTop + textHeight + 2,
160
+ 1,
161
+ 1,
162
+ color
163
+ );
164
+ }
165
+ else if (speakerY < textTop) {
166
+ const anchorX = Math.max(Math.min(speakerX, textLeft + textWidth - 4), textLeft + 5);
167
+ canvas.fillRect(
168
+ anchorX - 2,
169
+ textTop - 2,
170
+ 3,
171
+ 1,
172
+ color
173
+ );
174
+ canvas.fillRect(
175
+ anchorX - 1,
176
+ textTop - 3,
177
+ 1,
178
+ 1,
179
+ color
180
+ );
181
+ }
182
+ else if (speakerX > textLeft + textWidth) {
183
+ const anchorY = Math.max(Math.min(speakerY, textTop + textHeight - 4), textTop + 5);
184
+ canvas.fillRect(
185
+ textLeft + textWidth + 1,
186
+ anchorY - 2,
187
+ 1,
188
+ 3,
189
+ color
190
+ );
191
+ canvas.fillRect(
192
+ textLeft + textWidth + 2,
193
+ anchorY - 1,
194
+ 1,
195
+ 1,
196
+ color
197
+ );
198
+ }
199
+ else if (speakerX < textLeft) {
200
+ const anchorY = Math.max(Math.min(speakerY, textTop + textHeight - 4), textTop + 5);
201
+ canvas.fillRect(
202
+ textLeft - 2,
203
+ anchorY - 2,
204
+ 1,
205
+ 3,
206
+ color
207
+ );
208
+ canvas.fillRect(
209
+ textLeft - 3,
210
+ anchorY - 1,
211
+ 1,
212
+ 1,
213
+ color
214
+ );
215
+ }
216
+ }
217
+ }
218
+ }
219
+
20
220
  protected renderText: RenderText;
21
221
  protected animation: RenderTextAnimation;
22
222
 
@@ -45,62 +245,15 @@ namespace sprites {
45
245
  const t = Math.floor(owner.top - oy);
46
246
 
47
247
  const height = this.animation ? this.animation.currentHeight() : this.renderText.height;
48
- const sayLeft = l + (owner.width >> 1) - (this.renderText.width >> 1);
248
+ const width = this.animation ? this.animation.currentWidth() : this.renderText.width;
249
+ const sayLeft = l + (owner.width >> 1) - (width >> 1);
49
250
  const sayTop = t - height - 4;
50
251
 
252
+ if (sayLeft + width < 0 || sayTop + height < 0 || sayLeft > screen.width || sayTop > screen.height) return;
51
253
 
52
- if (sayLeft + this.renderText.width < 0 || sayTop + height < 0 || sayLeft > screen.width || sayTop > screen.height) return;
254
+ SpriteSayRenderer.drawSayFrame(sayLeft, sayTop, width, height, owner.x, owner.y, this.bgColor, screen);
53
255
 
54
256
  if (height) {
55
- screen.fillRect(
56
- sayLeft,
57
- sayTop,
58
- this.renderText.width,
59
- height,
60
- this.bgColor
61
- );
62
- screen.fillRect(
63
- sayLeft - 1,
64
- sayTop + 1,
65
- 1,
66
- height - 2,
67
- this.bgColor
68
- );
69
- screen.fillRect(
70
- sayLeft + this.renderText.width,
71
- sayTop + 1,
72
- 1,
73
- height - 2,
74
- this.bgColor
75
- );
76
- screen.fillRect(
77
- sayLeft + 1,
78
- sayTop - 1,
79
- this.renderText.width - 2,
80
- 1,
81
- this.bgColor
82
- );
83
- screen.fillRect(
84
- sayLeft + 1,
85
- sayTop + height,
86
- this.renderText.width - 2,
87
- 1,
88
- this.bgColor
89
- );
90
- screen.fillRect(
91
- sayLeft + (this.renderText.width >> 1) - 2,
92
- sayTop + height + 1,
93
- 3,
94
- 1,
95
- this.bgColor
96
- );
97
- screen.fillRect(
98
- sayLeft + (this.renderText.width >> 1) - 1,
99
- sayTop + height + 2,
100
- 1,
101
- 1,
102
- this.bgColor
103
- );
104
257
  if (this.animation) {
105
258
  this.animation.draw(screen, sayLeft, sayTop, this.fgColor);
106
259
  }
@@ -157,8 +310,8 @@ namespace sprites {
157
310
  // reuse previous sprite if possible
158
311
  const imgh = font.charHeight + bubblePadding;
159
312
  if (!this.sayBubbleSprite
160
- || this.sayBubbleSprite.image.width != bubbleWidth
161
- || this.sayBubbleSprite.image.height != imgh) {
313
+ || this.sayBubbleSprite.width != bubbleWidth
314
+ || this.sayBubbleSprite.height != imgh) {
162
315
  const sayImg = image.create(bubbleWidth, imgh);
163
316
  if (this.sayBubbleSprite) // sprite with same image size, we can reuse it
164
317
  this.sayBubbleSprite.setImage(sayImg);
@@ -56,7 +56,7 @@ const pxsim_pxtrt = pxsim.pxtrt;
56
56
  const pxsim_numops = pxsim.numops;
57
57
 
58
58
 
59
- function _main___P48418(s) {
59
+ function _main___P48754(s) {
60
60
  let r0 = s.r0, step = s.pc;
61
61
  s.pc = -1;
62
62
 
@@ -66,19 +66,19 @@ if (yieldSteps-- < 0 && maybeYield(s, step, r0) || runtime !== pxsim.runtime) re
66
66
  switch (step) {
67
67
  case 0:
68
68
 
69
- globals._intervals___48659 = (undefined);
70
- globals._pollEventQueue___48672 = (undefined);
69
+ globals._intervals___48995 = (undefined);
70
+ globals._pollEventQueue___49008 = (undefined);
71
71
  r0 = undefined;
72
72
  return leave(s, r0)
73
73
  default: oops()
74
74
  } } }
75
- _main___P48418.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"characterlcd.ts","functionName":"<main>","argumentNames":[]}
76
- _main___P48418.continuations = [ ]
75
+ _main___P48754.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"characterlcd.ts","functionName":"<main>","argumentNames":[]}
76
+ _main___P48754.continuations = [ ]
77
77
 
78
- function _main___P48418_mk(s) {
78
+ function _main___P48754_mk(s) {
79
79
  checkStack(s.depth);
80
80
  return {
81
- parent: s, fn: _main___P48418, depth: s.depth + 1,
81
+ parent: s, fn: _main___P48754, depth: s.depth + 1,
82
82
  pc: 0, retval: undefined, r0: undefined, overwrittenPC: false, lambdaArgs: null,
83
83
  } }
84
84
 
@@ -88,5 +88,5 @@ function _main___P48418_mk(s) {
88
88
 
89
89
  const breakpoints = setupDebugger(1, [])
90
90
 
91
- return _main___P48418
91
+ return _main___P48754
92
92
  })
@@ -56,7 +56,7 @@ const pxsim_pxtrt = pxsim.pxtrt;
56
56
  const pxsim_numops = pxsim.numops;
57
57
 
58
58
 
59
- function _main___P95928(s) {
59
+ function _main___P96936(s) {
60
60
  let r0 = s.r0, step = s.pc;
61
61
  s.pc = -1;
62
62
 
@@ -66,19 +66,19 @@ if (yieldSteps-- < 0 && maybeYield(s, step, r0) || runtime !== pxsim.runtime) re
66
66
  switch (step) {
67
67
  case 0:
68
68
 
69
- globals._intervals___96169 = (undefined);
70
- globals._pollEventQueue___96182 = (undefined);
69
+ globals._intervals___97177 = (undefined);
70
+ globals._pollEventQueue___97190 = (undefined);
71
71
  r0 = undefined;
72
72
  return leave(s, r0)
73
73
  default: oops()
74
74
  } } }
75
- _main___P95928.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"tsl2591.ts","functionName":"<main>","argumentNames":[]}
76
- _main___P95928.continuations = [ ]
75
+ _main___P96936.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"tsl2591.ts","functionName":"<main>","argumentNames":[]}
76
+ _main___P96936.continuations = [ ]
77
77
 
78
- function _main___P95928_mk(s) {
78
+ function _main___P96936_mk(s) {
79
79
  checkStack(s.depth);
80
80
  return {
81
- parent: s, fn: _main___P95928, depth: s.depth + 1,
81
+ parent: s, fn: _main___P96936, depth: s.depth + 1,
82
82
  pc: 0, retval: undefined, r0: undefined, overwrittenPC: false, lambdaArgs: null,
83
83
  } }
84
84
 
@@ -88,5 +88,5 @@ function _main___P95928_mk(s) {
88
88
 
89
89
  const breakpoints = setupDebugger(1, [])
90
90
 
91
- return _main___P95928
91
+ return _main___P96936
92
92
  })
@@ -56,7 +56,7 @@ const pxsim_pxtrt = pxsim.pxtrt;
56
56
  const pxsim_numops = pxsim.numops;
57
57
 
58
58
 
59
- function _main___P59708(s) {
59
+ function _main___P60044(s) {
60
60
  let r0 = s.r0, step = s.pc;
61
61
  s.pc = -1;
62
62
 
@@ -66,19 +66,19 @@ if (yieldSteps-- < 0 && maybeYield(s, step, r0) || runtime !== pxsim.runtime) re
66
66
  switch (step) {
67
67
  case 0:
68
68
 
69
- globals._intervals___59949 = (undefined);
70
- globals._pollEventQueue___59962 = (undefined);
69
+ globals._intervals___60285 = (undefined);
70
+ globals._pollEventQueue___60298 = (undefined);
71
71
  r0 = undefined;
72
72
  return leave(s, r0)
73
73
  default: oops()
74
74
  } } }
75
- _main___P59708.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"lora.ts","functionName":"<main>","argumentNames":[]}
76
- _main___P59708.continuations = [ ]
75
+ _main___P60044.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"lora.ts","functionName":"<main>","argumentNames":[]}
76
+ _main___P60044.continuations = [ ]
77
77
 
78
- function _main___P59708_mk(s) {
78
+ function _main___P60044_mk(s) {
79
79
  checkStack(s.depth);
80
80
  return {
81
- parent: s, fn: _main___P59708, depth: s.depth + 1,
81
+ parent: s, fn: _main___P60044, depth: s.depth + 1,
82
82
  pc: 0, retval: undefined, r0: undefined, overwrittenPC: false, lambdaArgs: null,
83
83
  } }
84
84
 
@@ -88,5 +88,5 @@ function _main___P59708_mk(s) {
88
88
 
89
89
  const breakpoints = setupDebugger(1, [])
90
90
 
91
- return _main___P59708
91
+ return _main___P60044
92
92
  })
@@ -56,7 +56,7 @@ const pxsim_pxtrt = pxsim.pxtrt;
56
56
  const pxsim_numops = pxsim.numops;
57
57
 
58
58
 
59
- function _main___P185323(s) {
59
+ function _main___P187680(s) {
60
60
  let r0 = s.r0, step = s.pc;
61
61
  s.pc = -1;
62
62
 
@@ -66,19 +66,19 @@ if (yieldSteps-- < 0 && maybeYield(s, step, r0) || runtime !== pxsim.runtime) re
66
66
  switch (step) {
67
67
  case 0:
68
68
 
69
- globals._intervals___185564 = (undefined);
70
- globals._pollEventQueue___185577 = (undefined);
69
+ globals._intervals___187921 = (undefined);
70
+ globals._pollEventQueue___187934 = (undefined);
71
71
  r0 = undefined;
72
72
  return leave(s, r0)
73
73
  default: oops()
74
74
  } } }
75
- _main___P185323.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"keypad.ts","functionName":"<main>","argumentNames":[]}
76
- _main___P185323.continuations = [ ]
75
+ _main___P187680.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"keypad.ts","functionName":"<main>","argumentNames":[]}
76
+ _main___P187680.continuations = [ ]
77
77
 
78
- function _main___P185323_mk(s) {
78
+ function _main___P187680_mk(s) {
79
79
  checkStack(s.depth);
80
80
  return {
81
- parent: s, fn: _main___P185323, depth: s.depth + 1,
81
+ parent: s, fn: _main___P187680, depth: s.depth + 1,
82
82
  pc: 0, retval: undefined, r0: undefined, overwrittenPC: false, lambdaArgs: null,
83
83
  } }
84
84
 
@@ -88,5 +88,5 @@ function _main___P185323_mk(s) {
88
88
 
89
89
  const breakpoints = setupDebugger(1, [])
90
90
 
91
- return _main___P185323
91
+ return _main___P187680
92
92
  })