pxt-common-packages 9.5.1 → 9.5.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 (55) hide show
  1. package/libs/azureiot/built/debug/binary.js +485 -485
  2. package/libs/color/built/debug/binary.js +8 -8
  3. package/libs/color-sensor/built/debug/binary.js +8 -8
  4. package/libs/controller/built/debug/binary.js +8384 -7819
  5. package/libs/controller---none/built/debug/binary.js +8363 -7798
  6. package/libs/datalogger/built/debug/binary.js +63 -63
  7. package/libs/edge-connector/built/debug/binary.js +8 -8
  8. package/libs/esp32/built/debug/binary.js +486 -486
  9. package/libs/game/_locales/game-jsdoc-strings.json +6 -0
  10. package/libs/game/built/debug/binary.js +8276 -7711
  11. package/libs/game/controllerbutton.ts +98 -1
  12. package/libs/game/docs/reference/scene/get-neighboring-location.md +123 -0
  13. package/libs/game/docs/reference/scene/get-tile-location.md +1 -5
  14. package/libs/game/docs/reference/scene/location.md +246 -0
  15. package/libs/game/docs/reference/scene/tile-at-location-equals.md +1 -1
  16. package/libs/game/docs/reference/scene/tile-at-location-is-wall.md +98 -0
  17. package/libs/game/docs/reference/scene/tile-image-at-location.md +65 -0
  18. package/libs/game/docs/reference/scene/tilemap-location.md +83 -0
  19. package/libs/game/docs/reference/sprites/destroy-all-sprites-of-kind.md +74 -0
  20. package/libs/game/docs/reference/sprites/sprite/change-scale.md +65 -0
  21. package/libs/game/docs/reference/sprites/sprite/fx.md +25 -25
  22. package/libs/game/docs/reference/sprites/sprite/fy.md +24 -24
  23. package/libs/game/docs/reference/sprites/sprite/scale.md +80 -0
  24. package/libs/game/docs/reference/sprites/sprite/set-scale.md +79 -0
  25. package/libs/game/docs/reference/sprites/sprite/sx.md +80 -0
  26. package/libs/game/docs/reference/sprites/sprite/sy.md +80 -0
  27. package/libs/game/docs/reference/sprites.md +12 -2
  28. package/libs/game/scene.ts +2 -0
  29. package/libs/game/sprite.ts +2 -2
  30. package/libs/game/sprites.ts +1 -1
  31. package/libs/game/tilemap.ts +88 -4
  32. package/libs/lcd/built/debug/binary.js +8 -8
  33. package/libs/light-spectrum-sensor/built/debug/binary.js +8 -8
  34. package/libs/lora/built/debug/binary.js +8 -8
  35. package/libs/matrix-keypad/built/debug/binary.js +8 -8
  36. package/libs/mqtt/built/debug/binary.js +200 -200
  37. package/libs/net/built/debug/binary.js +200 -200
  38. package/libs/net-game/built/debug/binary.js +10081 -9516
  39. package/libs/palette/built/debug/binary.js +8275 -7710
  40. package/libs/pixel/built/debug/binary.js +8 -8
  41. package/libs/power/built/debug/binary.js +8 -8
  42. package/libs/proximity/built/debug/binary.js +8 -8
  43. package/libs/radio/built/debug/binary.js +8 -8
  44. package/libs/radio-broadcast/built/debug/binary.js +8 -8
  45. package/libs/rotary-encoder/built/debug/binary.js +8 -8
  46. package/libs/screen/built/debug/binary.js +50 -50
  47. package/libs/servo/built/debug/binary.js +8 -8
  48. package/libs/sprite-scaling/built/debug/binary.js +8275 -7710
  49. package/libs/sprite-scaling/docs/reference/sprites/scaling/scale-by-percent.md +77 -0
  50. package/libs/sprite-scaling/docs/reference/sprites/scaling/scale-by-pixels.md +144 -0
  51. package/libs/sprite-scaling/docs/reference/sprites/scaling/scale-to-percent.md +83 -0
  52. package/libs/sprite-scaling/docs/reference/sprites/scaling/scale-to-pixels.md +140 -0
  53. package/libs/sprite-scaling/scaling.ts +5 -5
  54. package/libs/storyboard/built/debug/binary.js +8275 -7710
  55. package/package.json +1 -1
@@ -0,0 +1,77 @@
1
+ # scale By Percent
2
+
3
+ Scale a sprite by a percentage of its current size in a direction from an anchor point.
4
+
5
+ ```sig
6
+ scaling.scaleByPercent(null, 50, ScaleDirection.Uniformly, ScaleAnchor.Middle)
7
+ ```
8
+
9
+ A sprite can scale by a percentage of its original size in a direction from an anchor point. The scaling can be in just one direction or the sprite can scale uniformly.
10
+
11
+ ## Uniform scaling
12
+
13
+ When the scaling **direction** is set to `uniformly`, the sprite is scaled so that the new size will have both the width and height changed by the same percentage **value**. If a sprite's current size is `64` x `32` and it's uniformly scaled by `50` percent, the new width is `32` and the new height is `16`.
14
+
15
+ ## Parameters
16
+
17
+ * **sprite**: the sprite to scale by a percentage of its original size.
18
+ * **value**: the [number](/types/number) that is the percentage to scale the sprite by.
19
+ * **direction**: the direction to scale in:
20
+ >* `horizontally`
21
+ >* `vertically`
22
+ >* `uniformly`
23
+ * **anchor**: an anchor point to scale the sprite from:
24
+ >* `middle`
25
+ >* `top`
26
+ >* `left`
27
+ >* `right`
28
+ >* `bottom`
29
+ >* `top left`
30
+ >* `top right`
31
+ >* `bottom right`
32
+ >* `bottom left`
33
+
34
+ ## Example #example
35
+
36
+ ### Scaling tester #ex1
37
+
38
+ Make a program to test sprite scaling a sprite by expanding and shrinking it uniformly. Use the controller buttons to increase and decrease the scale of a sprite by a percentage of its current size.
39
+
40
+ ```blocks
41
+ controller.B.onEvent(ControllerButtonEvent.Pressed, function () {
42
+ scaling.scaleByPercent(mySprite, -50, ScaleDirection.Uniformly, ScaleAnchor.Middle)
43
+ info.setScore(mySprite.width)
44
+ })
45
+ controller.A.onEvent(ControllerButtonEvent.Pressed, function () {
46
+ scaling.scaleByPercent(mySprite, 50, ScaleDirection.Uniformly, ScaleAnchor.Middle)
47
+ info.setScore(mySprite.width)
48
+ })
49
+ let mySprite: Sprite = null
50
+ mySprite = sprites.create(img`
51
+ 22222222222222222222222222222222
52
+ 25557777777777777777777777775552
53
+ 25577777777777777777777777777552
54
+ 25777777777777777777777777777752
55
+ 27777777777777777777777777777772
56
+ 27777777777777777777777777777772
57
+ 27777777777777777777777777777772
58
+ 27777777777777888877777777777772
59
+ 27777777777777888877777777777772
60
+ 27777777777777777777777777777772
61
+ 27777777777777777777777777777772
62
+ 27777777777777777777777777777772
63
+ 25777777777777777777777777777752
64
+ 25577777777777777777777777777552
65
+ 25557777777777777777777777775552
66
+ 22222222222222222222222222222222
67
+ `, SpriteKind.Player)
68
+ info.setScore(mySprite.width)
69
+ ```
70
+
71
+ ## See also #seealso
72
+
73
+ [scale to percent](/reference/sprites/scaling/scale-to-percent)
74
+
75
+ ```package
76
+ sprite-scaling
77
+ ```
@@ -0,0 +1,144 @@
1
+ # scale by Pixels
2
+
3
+ Scale a sprite by a number of pixels in a direction from an anchor point.
4
+
5
+ ```sig
6
+ scaling.scaleByPixels(null, 1, ScaleDirection.Uniformly, ScaleAnchor.Middle)
7
+ ```
8
+
9
+ A sprite can scale to a number of pixels in a direction from an anchor point. The scaling can be in just in the direction chosen, or the sprite can scale proportionally in the other direction too.
10
+
11
+ ## Proportional scaling
12
+
13
+ If the scale direction is `vertically` or `horizontally` but **proportional** is set to `false`, the sprite will scale to the number of pixels given in **value** only in the chosen direction. The sprite will expand in height but the width will stay the same or the sprite will expand in width but the height will stat the same.
14
+
15
+ If the scaling direction is `vertically` and the `proportional` parameter is `true`, the width will also expand by the same ratio of change as the height. With this setting, expanding a `32` x `16` sprite in the vertical direction by `16` pixels will also expand the width by `32`. The same ratio scaling will happen for the height if the direction is `horizontally`.
16
+
17
+ ## Uniform scaling
18
+
19
+ When the scaling **direction** is set to `uniformly`, the sprite is scaled so that the new size will have both the width and height change by the same amount. If a sprite's current size is `64` x `16` and it's uniformly scaled by `64`, the new width is `128` and the new height is `80`.
20
+
21
+ ## Parameters
22
+
23
+ * **sprite**: the sprite to scale by a pixel amount.
24
+ * **value**: the [number](/types/number) of pixels to scale the sprite by.
25
+ * **direction**: the direction to scale in:
26
+ >* `horizontally`
27
+ >* `vertically`
28
+ >* `uniformly`
29
+ * **anchor**: an anchor point to scale the sprite from:
30
+ >* `middle`
31
+ >* `top`
32
+ >* `left`
33
+ >* `right`
34
+ >* `bottom`
35
+ >* `top left`
36
+ >* `top right`
37
+ >* `bottom right`
38
+ >* `bottom left`
39
+ * **proportional**: a [boolean](/types/boolean) value that when `true` will scale the sprite proportionally. If `false`, the sprite will only scale by **direction**. This parameter has no effect when **direction** is set to `uniformly`.
40
+
41
+ ## Example #example
42
+
43
+ ### Scaling tester #ex1
44
+
45
+ Make a program to test sprite scaling in both directions for expanding and shrinking. Use the controller buttons to increase and decrease the scale. Use buttons to turn **proportional** to `true` or `false`.
46
+
47
+ ```blocks
48
+ controller.up.onEvent(ControllerButtonEvent.Pressed, function () {
49
+ scaling.scaleByPixels(mySprite, pixelMin, ScaleDirection.Vertically, ScaleAnchor.Middle, proportion)
50
+ })
51
+ controller.B.onEvent(ControllerButtonEvent.Pressed, function () {
52
+ proportion = false
53
+ game.showLongText("Proportional = FALSE", DialogLayout.Bottom)
54
+ })
55
+ controller.A.onEvent(ControllerButtonEvent.Pressed, function () {
56
+ proportion = true
57
+ game.showLongText("Proportional = TRUE", DialogLayout.Bottom)
58
+ })
59
+ controller.left.onEvent(ControllerButtonEvent.Pressed, function () {
60
+ if (mySprite.width > pixelMin) {
61
+ scaling.scaleByPixels(mySprite, pixelMin * -1, ScaleDirection.Horizontally, ScaleAnchor.Middle, proportion)
62
+ }
63
+ })
64
+ controller.right.onEvent(ControllerButtonEvent.Pressed, function () {
65
+ scaling.scaleByPixels(mySprite, pixelMin, ScaleDirection.Horizontally, ScaleAnchor.Middle, proportion)
66
+ })
67
+ controller.down.onEvent(ControllerButtonEvent.Pressed, function () {
68
+ if (mySprite.width > pixelMin) {
69
+ scaling.scaleByPixels(mySprite, pixelMin * -1, ScaleDirection.Vertically, ScaleAnchor.Middle, proportion)
70
+ }
71
+ })
72
+ let proportion = false
73
+ let pixelMin = 0
74
+ let mySprite: Sprite = null
75
+ mySprite = sprites.create(img`
76
+ 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
77
+ 2 5 5 5 7 7 7 7 7 7 7 7 5 5 5 2
78
+ 2 5 5 7 7 7 7 7 7 7 7 7 7 5 5 2
79
+ 2 5 7 7 7 7 7 7 7 7 7 7 7 7 5 2
80
+ 2 7 7 7 7 7 7 7 7 7 7 7 7 7 7 2
81
+ 2 7 7 7 7 7 7 7 7 7 7 7 7 7 7 2
82
+ 2 7 7 7 7 7 7 7 7 7 7 7 7 7 7 2
83
+ 2 7 7 7 7 7 7 8 8 7 7 7 7 7 7 2
84
+ 2 7 7 7 7 7 7 8 8 7 7 7 7 7 7 2
85
+ 2 7 7 7 7 7 7 7 7 7 7 7 7 7 7 2
86
+ 2 7 7 7 7 7 7 7 7 7 7 7 7 7 7 2
87
+ 2 7 7 7 7 7 7 7 7 7 7 7 7 7 7 2
88
+ 2 5 7 7 7 7 7 7 7 7 7 7 7 7 5 2
89
+ 2 5 5 7 7 7 7 7 7 7 7 7 7 5 5 2
90
+ 2 5 5 5 7 7 7 7 7 7 7 7 5 5 5 2
91
+ 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
92
+ `, SpriteKind.Player)
93
+ pixelMin = mySprite.width
94
+ let pixelMax = pixelMin * 5
95
+ game.showLongText("Proportional = FALSE", DialogLayout.Bottom)
96
+ ```
97
+
98
+ ### Uniformity tester #ex2
99
+
100
+ Test uniformly scaling a nonsquare sprite. Use the controller buttons to change the increased or decreased scale.
101
+
102
+ ```blocks
103
+ controller.up.onEvent(ControllerButtonEvent.Pressed, function () {
104
+ scaling.scaleByPixels(mySprite, pixelMax, ScaleDirection.Uniformly, ScaleAnchor.Middle)
105
+ info.setScore(mySprite.width)
106
+ })
107
+ controller.down.onEvent(ControllerButtonEvent.Pressed, function () {
108
+ if (my)
109
+ scaling.scaleByPixels(mySprite, pixelMin * -1, ScaleDirection.Uniformly, ScaleAnchor.Middle)
110
+ info.setScore(mySprite.width)
111
+ })
112
+ let pixelMax = 0
113
+ let pixelMin = 0
114
+ let mySprite: Sprite = null
115
+ mySprite = sprites.create(img`
116
+ 22222222222222222222222222222222
117
+ 25557777777777777777777777775552
118
+ 25577777777777777777777777777552
119
+ 25777777777777777777777777777752
120
+ 27777777777777777777777777777772
121
+ 27777777777777777777777777777772
122
+ 27777777777777777777777777777772
123
+ 27777777777777888877777777777772
124
+ 27777777777777888877777777777772
125
+ 27777777777777777777777777777772
126
+ 27777777777777777777777777777772
127
+ 27777777777777777777777777777772
128
+ 25777777777777777777777777777752
129
+ 25577777777777777777777777777552
130
+ 25557777777777777777777777775552
131
+ 22222222222222222222222222222222
132
+ `, SpriteKind.Player)
133
+ pixelMin = mySprite.height
134
+ pixelMax = pixelMin * 5
135
+ info.setScore(mySprite.width)
136
+ ```
137
+
138
+ ## See also #seealso
139
+
140
+ [scale by pixels](/reference/sprites/scaling/scale-by-pixels)
141
+
142
+ ```package
143
+ sprite-scaling
144
+ ```
@@ -0,0 +1,83 @@
1
+ # scale To Percent
2
+
3
+ Scale a sprite to a percentage of its original size in a direction from an anchor point.
4
+
5
+ ```sig
6
+ scaling.scaleToPercent(null, 100, ScaleDirection.Uniformly, ScaleAnchor.Middle)
7
+ ```
8
+
9
+ A sprite can scale to a percentage of its original size in a direction from an anchor point. The scaling can be in just one direction or the sprite can scale uniformly.
10
+
11
+ ## Uniform scaling
12
+
13
+ When the scaling **direction** is set to `uniformly`, the sprite is scaled so that the new size will have both the width and height changed by the same percentage **value**. If a sprite's original size is `64` x `32` and it's uniformly scaled to `50` percent, the new width is `32` and the new height is `16`.
14
+
15
+ ## Parameters
16
+
17
+ * **sprite**: the sprite to scale to a percentage of its original size.
18
+ * **value**: the [number](/types/number) that is the percentage to scale the sprite to.
19
+ * **direction**: the direction to scale in:
20
+ >* `horizontally`
21
+ >* `vertically`
22
+ >* `uniformly`
23
+ * **anchor**: an anchor point to scale the sprite from:
24
+ >* `middle`
25
+ >* `top`
26
+ >* `left`
27
+ >* `right`
28
+ >* `bottom`
29
+ >* `top left`
30
+ >* `top right`
31
+ >* `bottom right`
32
+ >* `bottom left`
33
+
34
+ ## Example #example
35
+
36
+ ### Scaling tester #ex1
37
+
38
+ Make a program to test sprite scaling in both directions for expanding and shrinking. Use the controller buttons to increase and decrease the scale to a percentage of the original sprite by direction. Use button `A` to set the pixel back to its original size.
39
+
40
+ ```blocks
41
+ controller.A.onEvent(ControllerButtonEvent.Pressed, function () {
42
+ scaling.scaleToPercent(mySprite, 100, ScaleDirection.Uniformly, ScaleAnchor.Middle)
43
+ })
44
+ controller.up.onEvent(ControllerButtonEvent.Pressed, function () {
45
+ scaling.scaleToPercent(mySprite, 200, ScaleDirection.Vertically, ScaleAnchor.Middle)
46
+ })
47
+ controller.left.onEvent(ControllerButtonEvent.Pressed, function () {
48
+ scaling.scaleToPercent(mySprite, 50, ScaleDirection.Horizontally, ScaleAnchor.Middle)
49
+ })
50
+ controller.right.onEvent(ControllerButtonEvent.Pressed, function () {
51
+ scaling.scaleToPercent(mySprite, 200, ScaleDirection.Horizontally, ScaleAnchor.Middle)
52
+ })
53
+ controller.down.onEvent(ControllerButtonEvent.Pressed, function () {
54
+ scaling.scaleToPercent(mySprite, 50, ScaleDirection.Vertically, ScaleAnchor.Middle)
55
+ })
56
+ let mySprite: Sprite = null
57
+ mySprite = sprites.create(img`
58
+ 22222222222222222222222222222222
59
+ 25557777777777777777777777775552
60
+ 25577777777777777777777777777552
61
+ 25777777777777777777777777777752
62
+ 27777777777777777777777777777772
63
+ 27777777777777777777777777777772
64
+ 27777777777777777777777777777772
65
+ 27777777777777888877777777777772
66
+ 27777777777777888877777777777772
67
+ 27777777777777777777777777777772
68
+ 27777777777777777777777777777772
69
+ 27777777777777777777777777777772
70
+ 25777777777777777777777777777752
71
+ 25577777777777777777777777777552
72
+ 25557777777777777777777777775552
73
+ 22222222222222222222222222222222
74
+ `, SpriteKind.Player)
75
+ ```
76
+
77
+ ## See also #seealso
78
+
79
+ [scale by percent](/reference/sprites/scaling/scale-by-percent)
80
+
81
+ ```package
82
+ sprite-scaling
83
+ ```
@@ -0,0 +1,140 @@
1
+ # scale To Pixels
2
+
3
+ Scale a sprite to a number of pixels in a direction from an anchor point.
4
+
5
+ ```sig
6
+ scaling.scaleToPixels(null, 1, ScaleDirection.Uniformly, ScaleAnchor.Middle)
7
+ ```
8
+
9
+ A sprite can scale to a number of pixels in a direction from an anchor point. The scaling can be in just in the direction chosen, or the sprite can scale proportionally in the other direction too.
10
+
11
+ ## Proportional scaling
12
+
13
+ If the scale direction is `vertically` or `horizontally` but **proportional** is set to `false`, the sprite will scale to the number of pixels given in **value** only in the chosen direction. The sprite will expand in height but the width will stay the same or the sprite will expand in width but the height will stat the same.
14
+
15
+ If the scaling direction is `vertically` and the `proportional` parameter is `true`, the width will also expand by the same ratio of change as the height. With this setting, expanding a `32` x `16` sprite in the vertical direction to `32` pixels will also expand the width to `64`. The same ratio scaling will happen for the height if the direction is `horizontally`.
16
+
17
+ ## Uniform scaling
18
+
19
+ When the scaling **direction** is set to `uniformly`, the sprite is scaled so that te new size will have both the width and height the same. If a sprite's current size is `64` x `16` and it's uniformly scaled to `128`, the new width and height will both be `128`.
20
+
21
+ ## Parameters
22
+
23
+ * **sprite**: the sprite to scale to a pixel amount.
24
+ * **value**: the [number](/types/number) of pixels to scale the sprite to.
25
+ * **direction**: the direction to scale in:
26
+ >* `horizontally`
27
+ >* `vertically`
28
+ >* `uniformly`
29
+ * **anchor**: an anchor point to scale the sprite from:
30
+ >* `middle`
31
+ >* `top`
32
+ >* `left`
33
+ >* `right`
34
+ >* `bottom`
35
+ >* `top left`
36
+ >* `top right`
37
+ >* `bottom right`
38
+ >* `bottom left`
39
+ * **proportional**: a [boolean](/types/boolean) value that when `true` will scale the sprite proportionally. If `false`, the sprite will only scale by **direction**. This parameter has no effect when **direction** is set to `uniformly`.
40
+
41
+ ## Example #example
42
+
43
+ ### Scaling tester #ex1
44
+
45
+ Make a program to test sprite scaling in both directions for expanding and shrinking. Use the controller buttons to increase and decrease the scale. Use buttons to turn **proportional** to `true` or `false`.
46
+
47
+ ```blocks
48
+ controller.B.onEvent(ControllerButtonEvent.Pressed, function () {
49
+ proportion = false
50
+ game.showLongText("Proportional = FALSE", DialogLayout.Bottom)
51
+ })
52
+ controller.A.onEvent(ControllerButtonEvent.Pressed, function () {
53
+ proportion = true
54
+ game.showLongText("Proportional = TRUE", DialogLayout.Bottom)
55
+ })
56
+ controller.left.onEvent(ControllerButtonEvent.Pressed, function () {
57
+ scaling.scaleToPixels(mySprite, pixelMin, ScaleDirection.Horizontally, ScaleAnchor.Middle, proportion)
58
+ })
59
+ controller.right.onEvent(ControllerButtonEvent.Pressed, function () {
60
+ scaling.scaleToPixels(mySprite, pixelMax, ScaleDirection.Horizontally, ScaleAnchor.Middle, proportion)
61
+ })
62
+ controller.up.onEvent(ControllerButtonEvent.Pressed, function () {
63
+ scaling.scaleToPixels(mySprite, pixelMax, ScaleDirection.Vertically, ScaleAnchor.Middle, proportion)
64
+ })
65
+ controller.down.onEvent(ControllerButtonEvent.Pressed, function () {
66
+ scaling.scaleToPixels(mySprite, pixelMin, ScaleDirection.Vertically, ScaleAnchor.Middle, proportion)
67
+ })
68
+ let proportion = false
69
+ let pixelMax = 0
70
+ let pixelMin = 0
71
+ let mySprite: Sprite = null
72
+ mySprite = sprites.create(img`
73
+ 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
74
+ 2 5 5 5 7 7 7 7 7 7 7 7 5 5 5 2
75
+ 2 5 5 7 7 7 7 7 7 7 7 7 7 5 5 2
76
+ 2 5 7 7 7 7 7 7 7 7 7 7 7 7 5 2
77
+ 2 7 7 7 7 7 7 7 7 7 7 7 7 7 7 2
78
+ 2 7 7 7 7 7 7 7 7 7 7 7 7 7 7 2
79
+ 2 7 7 7 7 7 7 7 7 7 7 7 7 7 7 2
80
+ 2 7 7 7 7 7 7 8 8 7 7 7 7 7 7 2
81
+ 2 7 7 7 7 7 7 8 8 7 7 7 7 7 7 2
82
+ 2 7 7 7 7 7 7 7 7 7 7 7 7 7 7 2
83
+ 2 7 7 7 7 7 7 7 7 7 7 7 7 7 7 2
84
+ 2 7 7 7 7 7 7 7 7 7 7 7 7 7 7 2
85
+ 2 5 7 7 7 7 7 7 7 7 7 7 7 7 5 2
86
+ 2 5 5 7 7 7 7 7 7 7 7 7 7 5 5 2
87
+ 2 5 5 5 7 7 7 7 7 7 7 7 5 5 5 2
88
+ 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
89
+ `, SpriteKind.Player)
90
+ pixelMin = mySprite.width
91
+ pixelMax = pixelMin * 5
92
+ game.showLongText("Proportional = FALSE", DialogLayout.Bottom)
93
+ ```
94
+
95
+ ### Uniformity tester #ex2
96
+
97
+ Test uniformly scaling a nonsquare sprite. Use the `up` and `down` controller buttons to increase and decrease the scale.
98
+
99
+ ```blocks
100
+ controller.up.onEvent(ControllerButtonEvent.Pressed, function () {
101
+ scaling.scaleToPixels(mySprite, pixelMax, ScaleDirection.Uniformly, ScaleAnchor.Middle)
102
+ info.setScore(mySprite.width)
103
+ })
104
+ controller.down.onEvent(ControllerButtonEvent.Pressed, function () {
105
+ scaling.scaleToPixels(mySprite, pixelMin, ScaleDirection.Uniformly, ScaleAnchor.Middle)
106
+ info.setScore(mySprite.width)
107
+ })
108
+ let pixelMax = 0
109
+ let pixelMin = 0
110
+ let mySprite: Sprite = null
111
+ mySprite = sprites.create(img`
112
+ 22222222222222222222222222222222
113
+ 25557777777777777777777777775552
114
+ 25577777777777777777777777777552
115
+ 25777777777777777777777777777752
116
+ 27777777777777777777777777777772
117
+ 27777777777777777777777777777772
118
+ 27777777777777777777777777777772
119
+ 27777777777777888877777777777772
120
+ 27777777777777888877777777777772
121
+ 27777777777777777777777777777772
122
+ 27777777777777777777777777777772
123
+ 27777777777777777777777777777772
124
+ 25777777777777777777777777777752
125
+ 25577777777777777777777777777552
126
+ 25557777777777777777777777775552
127
+ 22222222222222222222222222222222
128
+ `, SpriteKind.Player)
129
+ pixelMin = mySprite.height
130
+ pixelMax = pixelMin * 5
131
+ info.setScore(mySprite.width)
132
+ ```
133
+
134
+ ## See also #seealso
135
+
136
+ [scale by pixels](/reference/sprites/scaling/scale-to-pixels)
137
+
138
+ ```package
139
+ sprite-scaling
140
+ ```
@@ -1,4 +1,4 @@
1
- //% color="#95078E" weight=99 icon="\u2195" block="Sprite Scaling"
1
+ //% color="#95078E" weight=99 icon="\uf338"
2
2
  namespace scaling {
3
3
  //% blockId=sprite_scale_to_percent_ex
4
4
  //% block="set $sprite=variables_get(mySprite) scale to $value percent $direction anchor $anchor"
@@ -7,7 +7,7 @@ namespace scaling {
7
7
  //% value.defl=150
8
8
  //% direction.defl=ScaleDirection.Uniformly
9
9
  //% anchor.defl=ScaleAnchor.Middle
10
- //% help=sprites/sprite-scaling/scale
10
+ //% help=sprites/scaling/scale-to-percent
11
11
  export function scaleToPercent(sprite: Sprite, value: number, direction?: ScaleDirection, anchor?: ScaleAnchor): void {
12
12
  value /= 100;
13
13
  direction = direction || ScaleDirection.Uniformly;
@@ -29,7 +29,7 @@ namespace scaling {
29
29
  //% value.defl=50
30
30
  //% direction.defl=ScaleDirection.Uniformly
31
31
  //% anchor.defl=ScaleAnchor.Middle
32
- //% help=sprites/sprite-scaling/scale
32
+ //% help=sprites/scaling/scale-by-percent
33
33
  export function scaleByPercent(sprite: Sprite, value: number, direction?: ScaleDirection, anchor?: ScaleAnchor): void {
34
34
  value /= 100;
35
35
  direction = direction || ScaleDirection.Uniformly;
@@ -52,7 +52,7 @@ namespace scaling {
52
52
  //% direction.defl=ScaleDirection.Horizontally
53
53
  //% anchor.defl=ScaleAnchor.Middle
54
54
  //% proportional.defl=0
55
- //% help=sprites/sprite-scaling/scale
55
+ //% help=sprites/scaling/scale-to-pixels
56
56
  export function scaleToPixels(sprite: Sprite, value: number, direction?: ScaleDirection, anchor?: ScaleAnchor, proportional?: boolean): void {
57
57
  direction = direction || ScaleDirection.Horizontally;
58
58
  anchor = anchor || ScaleAnchor.Middle;
@@ -85,7 +85,7 @@ namespace scaling {
85
85
  //% direction.defl=ScaleDirection.Horizontally
86
86
  //% anchor.defl=ScaleAnchor.Middle
87
87
  //% proportional.defl=0
88
- //% help=sprites/sprite-scaling/scale
88
+ //% help=sprites/scaling/scale-by-pixels
89
89
  export function scaleByPixels(sprite: Sprite, value: number, direction?: ScaleDirection, anchor?: ScaleAnchor, proportional?: boolean): void {
90
90
  direction = direction || ScaleDirection.Horizontally;
91
91
  anchor = anchor || ScaleAnchor.Middle;