pxt-common-packages 9.4.7 → 9.5.1

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 (60) hide show
  1. package/built/common-sim.d.ts +1 -0
  2. package/built/common-sim.js +3 -0
  3. package/libs/accelerometer/built/debug/binary.js +8 -8
  4. package/libs/azureiot/built/debug/binary.js +461 -461
  5. package/libs/base/fixed.ts +6 -0
  6. package/libs/color/built/debug/binary.js +8 -8
  7. package/libs/color-sensor/built/debug/binary.js +8 -8
  8. package/libs/controller/built/debug/binary.js +7636 -7598
  9. package/libs/controller---none/built/debug/binary.js +7617 -7579
  10. package/libs/core/built/debug/binary.js +2 -2
  11. package/libs/core---samd/built/debug/binary.js +8 -8
  12. package/libs/datalogger/built/debug/binary.js +63 -63
  13. package/libs/edge-connector/built/debug/binary.js +8 -8
  14. package/libs/esp32/built/debug/binary.js +462 -462
  15. package/libs/game/built/debug/binary.js +7530 -7492
  16. package/libs/game/hitbox.ts +5 -5
  17. package/libs/game/sprite.ts +9 -9
  18. package/libs/gamepad/built/debug/binary.js +8 -8
  19. package/libs/keyboard/built/debug/binary.js +8 -8
  20. package/libs/lcd/built/debug/binary.js +8 -8
  21. package/libs/light/built/debug/binary.js +8 -8
  22. package/libs/light-spectrum-sensor/built/debug/binary.js +8 -8
  23. package/libs/lora/built/debug/binary.js +8 -8
  24. package/libs/matrix-keypad/built/debug/binary.js +8 -8
  25. package/libs/microphone/built/debug/binary.js +8 -8
  26. package/libs/mouse/built/debug/binary.js +8 -8
  27. package/libs/mqtt/built/debug/binary.js +176 -176
  28. package/libs/music/built/debug/binary.js +8 -8
  29. package/libs/net/built/debug/binary.js +176 -176
  30. package/libs/net/controller.ts +10 -1
  31. package/libs/net-game/built/debug/binary.js +9286 -9248
  32. package/libs/palette/built/debug/binary.js +7529 -7491
  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/pulse/built/debug/binary.js +8 -8
  37. package/libs/radio/built/debug/binary.js +8 -8
  38. package/libs/radio-broadcast/built/debug/binary.js +8 -8
  39. package/libs/rotary-encoder/built/debug/binary.js +8 -8
  40. package/libs/screen/built/debug/binary.js +50 -50
  41. package/libs/servo/built/debug/binary.js +8 -8
  42. package/libs/sprite-scaling/_locales/sprite-scaling-strings.json +5 -7
  43. package/libs/sprite-scaling/built/debug/binary.js +7529 -7491
  44. package/libs/sprite-scaling/scaling.ts +51 -50
  45. package/libs/storyboard/built/debug/binary.js +7529 -7491
  46. package/libs/tests/built/debug/binary.js +15 -15
  47. package/libs/thermometer/built/debug/binary.js +8 -8
  48. package/libs/wifi---esp32/README.md +12 -0
  49. package/libs/wifi---esp32/buildlogin.sh +1 -0
  50. package/libs/wifi---esp32/controller.ts +27 -1
  51. package/libs/wifi---esp32/enums.d.ts +4 -0
  52. package/libs/wifi---esp32/httpserver.cpp +168 -0
  53. package/libs/wifi---esp32/login.full.html +37 -0
  54. package/libs/wifi---esp32/login.html +1 -0
  55. package/libs/wifi---esp32/pxt.json +1 -0
  56. package/libs/wifi---esp32/shims.d.ts +8 -0
  57. package/libs/wifi---esp32/sim/wifisockets.ts +3 -0
  58. package/libs/wifi---esp32/wifi.cpp +24 -15
  59. package/libs/wifi---esp32/wifi.h +15 -1
  60. package/package.json +1 -1
@@ -1,15 +1,15 @@
1
- namespace sprites {
2
- //% blockId=sprite_set_scale_ex
3
- //% block="set $sprite=variables_get(mySprite) scale to $value || $direction anchor $anchor"
4
- //% advanced=true
1
+ //% color="#95078E" weight=99 icon="\u2195" block="Sprite Scaling"
2
+ namespace scaling {
3
+ //% blockId=sprite_scale_to_percent_ex
4
+ //% block="set $sprite=variables_get(mySprite) scale to $value percent $direction anchor $anchor"
5
5
  //% expandableArgumentMode=enabled
6
6
  //% inlineInputMode=inline
7
- //% value.defl=1
7
+ //% value.defl=150
8
8
  //% direction.defl=ScaleDirection.Uniformly
9
9
  //% anchor.defl=ScaleAnchor.Middle
10
- //% help=sprites/sprite-scaling/set-scale
11
- //% group="Scale" weight=90
12
- export function setScale(sprite: Sprite, value: number, direction?: ScaleDirection, anchor?: ScaleAnchor): void {
10
+ //% help=sprites/sprite-scaling/scale
11
+ export function scaleToPercent(sprite: Sprite, value: number, direction?: ScaleDirection, anchor?: ScaleAnchor): void {
12
+ value /= 100;
13
13
  direction = direction || ScaleDirection.Uniformly;
14
14
  anchor = anchor || ScaleAnchor.Middle;
15
15
 
@@ -22,90 +22,91 @@ namespace sprites {
22
22
  sprite.setScaleCore(sx, sy, anchor);
23
23
  }
24
24
 
25
- //% blockId=sprite_grow_by_percent_ex
26
- //% block="grow $sprite=variables_get(mySprite) by $amount percent || $direction anchor $anchor"
27
- //% advanced=true
25
+ //% blockId=sprite_scale_by_percent_ex
26
+ //% block="change $sprite=variables_get(mySprite) scale by $value percent $direction anchor $anchor"
28
27
  //% expandableArgumentMode=enabled
29
28
  //% inlineInputMode=inline
30
- //% amount.defl=10
29
+ //% value.defl=50
31
30
  //% direction.defl=ScaleDirection.Uniformly
32
31
  //% anchor.defl=ScaleAnchor.Middle
33
- //% help=sprites/sprite-scaling/grow-by-amount
34
- //% group="Scale" weight=80
35
- export function growByPercent(sprite: Sprite, amount: number, direction?: ScaleDirection, anchor?: ScaleAnchor): void {
36
- amount /= 100;
32
+ //% help=sprites/sprite-scaling/scale
33
+ export function scaleByPercent(sprite: Sprite, value: number, direction?: ScaleDirection, anchor?: ScaleAnchor): void {
34
+ value /= 100;
37
35
  direction = direction || ScaleDirection.Uniformly;
38
36
  anchor = anchor || ScaleAnchor.Middle;
39
37
 
40
38
  let sx: number;
41
39
  let sy: number;
42
40
 
43
- if (direction & ScaleDirection.Horizontally) sx = sprite.sx + amount;
44
- if (direction & ScaleDirection.Vertically) sy = sprite.sy + amount;
41
+ if (direction & ScaleDirection.Horizontally) sx = sprite.sx + value;
42
+ if (direction & ScaleDirection.Vertically) sy = sprite.sy + value;
45
43
 
46
44
  sprite.setScaleCore(sx, sy, anchor);
47
45
  }
48
46
 
49
- //% blockId=sprite_shrink_by_percent_ex
50
- //% block="shrink $sprite=variables_get(mySprite) by $amount percent || $direction anchor $anchor"
51
- //% advanced=true
47
+ //% blockId=sprite_scale_to_pixels_ex
48
+ //% block="set $sprite=variables_get(mySprite) scale to $value pixels $direction anchor $anchor || proportional $proportional"
52
49
  //% expandableArgumentMode=enabled
53
50
  //% inlineInputMode=inline
54
- //% amount.defl=10
55
- //% direction.defl=ScaleDirection.Uniformly
56
- //% anchor.defl=ScaleAnchor.Middle
57
- //% help=sprites/sprite-scaling/shrink-by-percent
58
- //% group="Scale" weight=70
59
- export function shrinkByPercent(sprite: Sprite, amount: number, direction?: ScaleDirection, anchor?: ScaleAnchor): void {
60
- growByPercent(sprite, -amount, direction, anchor);
61
- }
62
-
63
- //% blockId=sprite_grow_by_pixels_ex
64
- //% block="grow $sprite=variables_get(mySprite) by $amount pixels $direction || anchor $anchor proportional $proportional"
65
- //% advanced=true
66
- //% expandableArgumentMode=enabled
67
- //% inlineInputMode=inline
68
- //% amount.defl=10
51
+ //% value.defl=32
69
52
  //% direction.defl=ScaleDirection.Horizontally
70
53
  //% anchor.defl=ScaleAnchor.Middle
71
54
  //% proportional.defl=0
72
- //% help=sprites/sprite-scaling/grow-by-pixels
73
- //% group="Scale" weight=60
74
- export function growByPixels(sprite: Sprite, amount: number, direction?: ScaleDirection, anchor?: ScaleAnchor, proportional?: boolean): void {
55
+ //% help=sprites/sprite-scaling/scale
56
+ export function scaleToPixels(sprite: Sprite, value: number, direction?: ScaleDirection, anchor?: ScaleAnchor, proportional?: boolean): void {
75
57
  direction = direction || ScaleDirection.Horizontally;
76
58
  anchor = anchor || ScaleAnchor.Middle;
77
- if (typeof proportional !== 'boolean') proportional = direction === ScaleDirection.Uniformly;
59
+
60
+ if (proportional == null) proportional = direction === ScaleDirection.Uniformly;
78
61
 
79
62
  let sx: number;
80
63
  let sy: number;
81
64
 
82
65
  if (direction & ScaleDirection.Horizontally) {
83
66
  const imgW = sprite.image.width;
84
- const newW = sprite.width + amount;
67
+ const newW = value;
85
68
  sx = newW / imgW;
86
69
  }
87
70
 
88
71
  if (direction & ScaleDirection.Vertically) {
89
72
  const imgH = sprite.image.height;
90
- const newH = sprite.height + amount;
73
+ const newH = value;
91
74
  sy = newH / imgH;
92
75
  }
93
76
 
94
77
  sprite.setScaleCore(sx, sy, anchor, proportional);
95
78
  }
96
79
 
97
- //% blockId=sprite_shrink_by_pixels
98
- //% block="shrink $sprite=variables_get(mySprite) by $amount pixels $direction || anchor $anchor proportional $proportional"
99
- //% advanced=true
80
+ //% blockId=sprite_scale_by_pixels_ex
81
+ //% block="change $sprite=variables_get(mySprite) scale by $value pixels $direction anchor $anchor || proportional $proportional"
100
82
  //% expandableArgumentMode=enabled
101
83
  //% inlineInputMode=inline
102
- //% amount.defl=10
84
+ //% value.defl=10
103
85
  //% direction.defl=ScaleDirection.Horizontally
104
86
  //% anchor.defl=ScaleAnchor.Middle
105
87
  //% proportional.defl=0
106
- //% help=sprites/sprite-scaling/grow-by-pixels
107
- //% group="Scale" weight=50
108
- export function shrinkByPixels(sprite: Sprite, amount: number, direction?: ScaleDirection, anchor?: ScaleAnchor, proportional?: boolean): void {
109
- growByPixels(sprite, -amount, direction, anchor, proportional);
88
+ //% help=sprites/sprite-scaling/scale
89
+ export function scaleByPixels(sprite: Sprite, value: number, direction?: ScaleDirection, anchor?: ScaleAnchor, proportional?: boolean): void {
90
+ direction = direction || ScaleDirection.Horizontally;
91
+ anchor = anchor || ScaleAnchor.Middle;
92
+
93
+ if (proportional == null) proportional = direction === ScaleDirection.Uniformly;
94
+
95
+ let sx: number;
96
+ let sy: number;
97
+
98
+ if (direction & ScaleDirection.Horizontally) {
99
+ const imgW = sprite.image.width;
100
+ const newW = sprite.width + value;
101
+ sx = newW / imgW;
102
+ }
103
+
104
+ if (direction & ScaleDirection.Vertically) {
105
+ const imgH = sprite.image.height;
106
+ const newH = sprite.height + value;
107
+ sy = newH / imgH;
108
+ }
109
+
110
+ sprite.setScaleCore(sx, sy, anchor, proportional);
110
111
  }
111
112
  }