pxt-common-packages 9.4.6 → 9.4.7
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.
- package/built/common-sim.d.ts +2 -2
- package/built/common-sim.js +12 -1
- package/libs/azureiot/built/debug/binary.js +461 -461
- package/libs/color/built/debug/binary.js +8 -8
- package/libs/color-sensor/built/debug/binary.js +8 -8
- package/libs/controller/built/debug/binary.js +9043 -7832
- package/libs/controller---none/built/debug/binary.js +9020 -7809
- package/libs/datalogger/built/debug/binary.js +63 -63
- package/libs/edge-connector/built/debug/binary.js +8 -8
- package/libs/esp32/built/debug/binary.js +462 -462
- package/libs/game/_locales/game-strings.json +21 -0
- package/libs/game/built/debug/binary.js +8935 -7724
- package/libs/game/hitbox.ts +40 -22
- package/libs/game/sprite.ts +244 -16
- package/libs/game/spritesay.ts +2 -2
- package/libs/lcd/built/debug/binary.js +8 -8
- package/libs/light-spectrum-sensor/built/debug/binary.js +8 -8
- package/libs/lora/built/debug/binary.js +8 -8
- package/libs/matrix-keypad/built/debug/binary.js +8 -8
- package/libs/mqtt/built/debug/binary.js +176 -176
- package/libs/net/built/debug/binary.js +176 -176
- package/libs/net-game/built/debug/binary.js +10832 -9617
- package/libs/palette/built/debug/binary.js +8934 -7723
- package/libs/pixel/built/debug/binary.js +8 -8
- package/libs/power/built/debug/binary.js +8 -8
- package/libs/proximity/built/debug/binary.js +9 -9
- package/libs/radio/built/debug/binary.js +8 -8
- package/libs/radio-broadcast/built/debug/binary.js +8 -8
- package/libs/rotary-encoder/built/debug/binary.js +8 -8
- package/libs/screen/built/debug/binary.js +50 -50
- package/libs/screen/image.cpp +14 -4
- package/libs/screen/image.ts +5 -4
- package/libs/screen/sim/image.ts +15 -3
- package/libs/servo/built/debug/binary.js +8 -8
- package/libs/sprite-scaling/README.md +3 -0
- package/libs/sprite-scaling/_locales/sprite-scaling-jsdoc-strings.json +1 -0
- package/libs/sprite-scaling/_locales/sprite-scaling-strings.json +9 -0
- package/libs/sprite-scaling/built/debug/binary.js +40047 -0
- package/libs/sprite-scaling/pxt.json +16 -0
- package/libs/sprite-scaling/scaling.ts +111 -0
- package/libs/sprite-scaling/targetoverrides.ts +1 -0
- package/libs/sprite-scaling/test.ts +0 -0
- package/libs/storyboard/built/debug/binary.js +8934 -7723
- package/package.json +1 -1
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "sprite-scaling",
|
|
3
|
+
"description": "Additional scaling blocks for sprites",
|
|
4
|
+
"files": [
|
|
5
|
+
"README.md",
|
|
6
|
+
"scaling.ts",
|
|
7
|
+
"targetoverrides.ts"
|
|
8
|
+
],
|
|
9
|
+
"testFiles": [
|
|
10
|
+
"test.ts"
|
|
11
|
+
],
|
|
12
|
+
"public": true,
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"game": "file:../game"
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
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
|
|
5
|
+
//% expandableArgumentMode=enabled
|
|
6
|
+
//% inlineInputMode=inline
|
|
7
|
+
//% value.defl=1
|
|
8
|
+
//% direction.defl=ScaleDirection.Uniformly
|
|
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 {
|
|
13
|
+
direction = direction || ScaleDirection.Uniformly;
|
|
14
|
+
anchor = anchor || ScaleAnchor.Middle;
|
|
15
|
+
|
|
16
|
+
let sx: number;
|
|
17
|
+
let sy: number;
|
|
18
|
+
|
|
19
|
+
if (direction & ScaleDirection.Horizontally) sx = value;
|
|
20
|
+
if (direction & ScaleDirection.Vertically) sy = value;
|
|
21
|
+
|
|
22
|
+
sprite.setScaleCore(sx, sy, anchor);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
//% blockId=sprite_grow_by_percent_ex
|
|
26
|
+
//% block="grow $sprite=variables_get(mySprite) by $amount percent || $direction anchor $anchor"
|
|
27
|
+
//% advanced=true
|
|
28
|
+
//% expandableArgumentMode=enabled
|
|
29
|
+
//% inlineInputMode=inline
|
|
30
|
+
//% amount.defl=10
|
|
31
|
+
//% direction.defl=ScaleDirection.Uniformly
|
|
32
|
+
//% 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;
|
|
37
|
+
direction = direction || ScaleDirection.Uniformly;
|
|
38
|
+
anchor = anchor || ScaleAnchor.Middle;
|
|
39
|
+
|
|
40
|
+
let sx: number;
|
|
41
|
+
let sy: number;
|
|
42
|
+
|
|
43
|
+
if (direction & ScaleDirection.Horizontally) sx = sprite.sx + amount;
|
|
44
|
+
if (direction & ScaleDirection.Vertically) sy = sprite.sy + amount;
|
|
45
|
+
|
|
46
|
+
sprite.setScaleCore(sx, sy, anchor);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
//% blockId=sprite_shrink_by_percent_ex
|
|
50
|
+
//% block="shrink $sprite=variables_get(mySprite) by $amount percent || $direction anchor $anchor"
|
|
51
|
+
//% advanced=true
|
|
52
|
+
//% expandableArgumentMode=enabled
|
|
53
|
+
//% 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
|
|
69
|
+
//% direction.defl=ScaleDirection.Horizontally
|
|
70
|
+
//% anchor.defl=ScaleAnchor.Middle
|
|
71
|
+
//% 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 {
|
|
75
|
+
direction = direction || ScaleDirection.Horizontally;
|
|
76
|
+
anchor = anchor || ScaleAnchor.Middle;
|
|
77
|
+
if (typeof proportional !== 'boolean') proportional = direction === ScaleDirection.Uniformly;
|
|
78
|
+
|
|
79
|
+
let sx: number;
|
|
80
|
+
let sy: number;
|
|
81
|
+
|
|
82
|
+
if (direction & ScaleDirection.Horizontally) {
|
|
83
|
+
const imgW = sprite.image.width;
|
|
84
|
+
const newW = sprite.width + amount;
|
|
85
|
+
sx = newW / imgW;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (direction & ScaleDirection.Vertically) {
|
|
89
|
+
const imgH = sprite.image.height;
|
|
90
|
+
const newH = sprite.height + amount;
|
|
91
|
+
sy = newH / imgH;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
sprite.setScaleCore(sx, sy, anchor, proportional);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
//% blockId=sprite_shrink_by_pixels
|
|
98
|
+
//% block="shrink $sprite=variables_get(mySprite) by $amount pixels $direction || anchor $anchor proportional $proportional"
|
|
99
|
+
//% advanced=true
|
|
100
|
+
//% expandableArgumentMode=enabled
|
|
101
|
+
//% inlineInputMode=inline
|
|
102
|
+
//% amount.defl=10
|
|
103
|
+
//% direction.defl=ScaleDirection.Horizontally
|
|
104
|
+
//% anchor.defl=ScaleAnchor.Middle
|
|
105
|
+
//% 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);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
// TODO any platform specific overrides
|
|
File without changes
|