pxt-common-packages 9.4.2 → 9.4.6

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 (46) hide show
  1. package/built/common-sim.d.ts +8 -0
  2. package/built/common-sim.js +74 -0
  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 +6578 -6578
  8. package/libs/controller---none/built/debug/binary.js +6558 -6558
  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/built/debug/binary.js +6497 -6497
  13. package/libs/game/docs/reference/scene/set-tile-at.md +2 -2
  14. package/libs/game/docs/reference/scene/set-tilemap.md +89 -0
  15. package/libs/game/docs/reference/scene/tile-at-location-equals.md +1 -1
  16. package/libs/game/docs/reference/scene.md +4 -2
  17. package/libs/game/docs/reference/sprites/sprite/ax.md +34 -3
  18. package/libs/game/docs/reference/sprites/sprite/ay.md +34 -3
  19. package/libs/game/docs/reference/sprites/sprite/fx.md +123 -0
  20. package/libs/game/docs/reference/sprites/sprite/fy.md +123 -0
  21. package/libs/game/docs/reference/sprites.md +2 -0
  22. package/libs/game/renderText.ts +74 -11
  23. package/libs/game/spritesay.ts +204 -51
  24. package/libs/game/tilemap.ts +1 -1
  25. package/libs/lcd/built/debug/binary.js +8 -8
  26. package/libs/light-spectrum-sensor/built/debug/binary.js +8 -8
  27. package/libs/lora/built/debug/binary.js +8 -8
  28. package/libs/matrix-keypad/built/debug/binary.js +8 -8
  29. package/libs/mqtt/built/debug/binary.js +176 -176
  30. package/libs/net/built/debug/binary.js +176 -176
  31. package/libs/net-game/built/debug/binary.js +8084 -8084
  32. package/libs/palette/built/debug/binary.js +6492 -6492
  33. package/libs/pixel/built/debug/binary.js +8 -8
  34. package/libs/power/built/debug/binary.js +8 -8
  35. package/libs/proximity/built/debug/binary.js +8 -8
  36. package/libs/radio/built/debug/binary.js +8 -8
  37. package/libs/radio-broadcast/built/debug/binary.js +8 -8
  38. package/libs/rotary-encoder/built/debug/binary.js +8 -8
  39. package/libs/screen/built/debug/binary.js +50 -50
  40. package/libs/servo/built/debug/binary.js +8 -8
  41. package/libs/storyboard/built/debug/binary.js +6496 -6496
  42. package/libs/text-to-speech/pxt.json +14 -0
  43. package/libs/text-to-speech/shims.d.ts +47 -0
  44. package/libs/text-to-speech/sim/tts.ts +72 -0
  45. package/libs/text-to-speech/tts.ts +70 -0
  46. 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
  }
@@ -545,7 +545,7 @@ namespace tiles {
545
545
  //% tilemap.fieldOptions.filter="tile"
546
546
  //% tilemap.fieldOptions.taggedTemplate="tilemap"
547
547
  //% blockNamespace="scene" duplicateShadowOnDrag
548
- //% help=tiles/set-tile-map
548
+ //% help=scene/set-tilemap
549
549
  //% deprecated=1
550
550
  export function setTilemap(tilemap: TileMapData) {
551
551
  setCurrentTilemap(tilemap);
@@ -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___P48426(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___48667 = (undefined);
70
+ globals._pollEventQueue___48680 = (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___P48426.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"characterlcd.ts","functionName":"<main>","argumentNames":[]}
76
+ _main___P48426.continuations = [ ]
77
77
 
78
- function _main___P48418_mk(s) {
78
+ function _main___P48426_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___P48426, 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___P48426
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___P95952(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___96193 = (undefined);
70
+ globals._pollEventQueue___96206 = (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___P95952.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"tsl2591.ts","functionName":"<main>","argumentNames":[]}
76
+ _main___P95952.continuations = [ ]
77
77
 
78
- function _main___P95928_mk(s) {
78
+ function _main___P95952_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___P95952, 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___P95952
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___P59716(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___59957 = (undefined);
70
+ globals._pollEventQueue___59970 = (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___P59716.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"lora.ts","functionName":"<main>","argumentNames":[]}
76
+ _main___P59716.continuations = [ ]
77
77
 
78
- function _main___P59708_mk(s) {
78
+ function _main___P59716_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___P59716, 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___P59716
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___P185379(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___185620 = (undefined);
70
+ globals._pollEventQueue___185633 = (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___P185379.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"keypad.ts","functionName":"<main>","argumentNames":[]}
76
+ _main___P185379.continuations = [ ]
77
77
 
78
- function _main___P185323_mk(s) {
78
+ function _main___P185379_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___P185379, 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___P185379
92
92
  })