pxt-common-packages 9.4.9 → 9.4.10
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/libs/controller/built/debug/binary.js +1 -1
- package/libs/controller---none/built/debug/binary.js +1 -1
- package/libs/game/built/debug/binary.js +1 -1
- package/libs/game/sprite.ts +4 -4
- package/libs/net-game/built/debug/binary.js +1 -1
- package/libs/palette/built/debug/binary.js +1 -1
- package/libs/sprite-scaling/_locales/sprite-scaling-strings.json +4 -5
- package/libs/sprite-scaling/built/debug/binary.js +3001 -3001
- package/libs/sprite-scaling/scaling.ts +50 -41
- package/libs/storyboard/built/debug/binary.js +1 -1
- package/package.json +1 -1
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
//% color="#
|
|
2
|
-
//% advanced=true
|
|
1
|
+
//% color="#95078E" weight=99 icon="\u2195" block="Sprite Scaling"
|
|
3
2
|
namespace scaling {
|
|
4
|
-
//% blockId=
|
|
5
|
-
//% block="set $sprite=variables_get(mySprite) scale to $value
|
|
3
|
+
//% blockId=sprite_scale_to_percent_ex
|
|
4
|
+
//% block="set $sprite=variables_get(mySprite) scale to $value percent $direction anchor $anchor"
|
|
6
5
|
//% expandableArgumentMode=enabled
|
|
7
6
|
//% inlineInputMode=inline
|
|
8
|
-
//% value.defl=
|
|
7
|
+
//% value.defl=150
|
|
9
8
|
//% direction.defl=ScaleDirection.Uniformly
|
|
10
9
|
//% anchor.defl=ScaleAnchor.Middle
|
|
11
|
-
//% help=sprites/sprite-scaling/
|
|
12
|
-
export function
|
|
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,82 +22,91 @@ namespace scaling {
|
|
|
22
22
|
sprite.setScaleCore(sx, sy, anchor);
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
//% blockId=
|
|
26
|
-
//% block="
|
|
25
|
+
//% blockId=sprite_scale_by_percent_ex
|
|
26
|
+
//% block="change $sprite=variables_get(mySprite) scale by $value percent $direction anchor $anchor"
|
|
27
27
|
//% expandableArgumentMode=enabled
|
|
28
28
|
//% inlineInputMode=inline
|
|
29
|
-
//%
|
|
29
|
+
//% value.defl=50
|
|
30
30
|
//% direction.defl=ScaleDirection.Uniformly
|
|
31
31
|
//% anchor.defl=ScaleAnchor.Middle
|
|
32
|
-
//% help=sprites/sprite-scaling/
|
|
33
|
-
export function
|
|
34
|
-
|
|
32
|
+
//% help=sprites/sprite-scaling/scale
|
|
33
|
+
export function scaleByPercent(sprite: Sprite, value: number, direction?: ScaleDirection, anchor?: ScaleAnchor): void {
|
|
34
|
+
value /= 100;
|
|
35
35
|
direction = direction || ScaleDirection.Uniformly;
|
|
36
36
|
anchor = anchor || ScaleAnchor.Middle;
|
|
37
37
|
|
|
38
38
|
let sx: number;
|
|
39
39
|
let sy: number;
|
|
40
40
|
|
|
41
|
-
if (direction & ScaleDirection.Horizontally) sx = sprite.sx +
|
|
42
|
-
if (direction & ScaleDirection.Vertically) sy = sprite.sy +
|
|
41
|
+
if (direction & ScaleDirection.Horizontally) sx = sprite.sx + value;
|
|
42
|
+
if (direction & ScaleDirection.Vertically) sy = sprite.sy + value;
|
|
43
43
|
|
|
44
44
|
sprite.setScaleCore(sx, sy, anchor);
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
//% blockId=
|
|
48
|
-
//% block="
|
|
47
|
+
//% blockId=sprite_scale_to_pixels_ex
|
|
48
|
+
//% block="set $sprite=variables_get(mySprite) scale to $value pixels $direction anchor $anchor || proportional $proportional"
|
|
49
49
|
//% expandableArgumentMode=enabled
|
|
50
50
|
//% inlineInputMode=inline
|
|
51
|
-
//%
|
|
52
|
-
//% direction.defl=ScaleDirection.Uniformly
|
|
53
|
-
//% anchor.defl=ScaleAnchor.Middle
|
|
54
|
-
//% help=sprites/sprite-scaling/shrink-by-percent
|
|
55
|
-
export function shrinkByPercent(sprite: Sprite, amount: number, direction?: ScaleDirection, anchor?: ScaleAnchor): void {
|
|
56
|
-
growByPercent(sprite, -amount, direction, anchor);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
//% blockId=sprite_grow_by_pixels_ex
|
|
60
|
-
//% block="grow $sprite=variables_get(mySprite) by $amount pixels $direction || anchor $anchor proportional $proportional"
|
|
61
|
-
//% expandableArgumentMode=enabled
|
|
62
|
-
//% inlineInputMode=inline
|
|
63
|
-
//% amount.defl=10
|
|
51
|
+
//% value.defl=32
|
|
64
52
|
//% direction.defl=ScaleDirection.Horizontally
|
|
65
53
|
//% anchor.defl=ScaleAnchor.Middle
|
|
66
54
|
//% proportional.defl=0
|
|
67
|
-
//% help=sprites/sprite-scaling/
|
|
68
|
-
export function
|
|
55
|
+
//% help=sprites/sprite-scaling/scale
|
|
56
|
+
export function scaleToPixels(sprite: Sprite, value: number, direction?: ScaleDirection, anchor?: ScaleAnchor, proportional?: boolean): void {
|
|
69
57
|
direction = direction || ScaleDirection.Horizontally;
|
|
70
58
|
anchor = anchor || ScaleAnchor.Middle;
|
|
71
|
-
|
|
59
|
+
|
|
60
|
+
if (proportional == null) proportional = direction === ScaleDirection.Uniformly;
|
|
72
61
|
|
|
73
62
|
let sx: number;
|
|
74
63
|
let sy: number;
|
|
75
64
|
|
|
76
65
|
if (direction & ScaleDirection.Horizontally) {
|
|
77
66
|
const imgW = sprite.image.width;
|
|
78
|
-
const newW =
|
|
67
|
+
const newW = value;
|
|
79
68
|
sx = newW / imgW;
|
|
80
69
|
}
|
|
81
70
|
|
|
82
71
|
if (direction & ScaleDirection.Vertically) {
|
|
83
72
|
const imgH = sprite.image.height;
|
|
84
|
-
const newH =
|
|
73
|
+
const newH = value;
|
|
85
74
|
sy = newH / imgH;
|
|
86
75
|
}
|
|
87
76
|
|
|
88
77
|
sprite.setScaleCore(sx, sy, anchor, proportional);
|
|
89
78
|
}
|
|
90
79
|
|
|
91
|
-
//% blockId=
|
|
92
|
-
//% block="
|
|
80
|
+
//% blockId=sprite_scale_by_pixels_ex
|
|
81
|
+
//% block="change $sprite=variables_get(mySprite) scale by $value pixels $direction anchor $anchor || proportional $proportional"
|
|
93
82
|
//% expandableArgumentMode=enabled
|
|
94
83
|
//% inlineInputMode=inline
|
|
95
|
-
//%
|
|
84
|
+
//% value.defl=10
|
|
96
85
|
//% direction.defl=ScaleDirection.Horizontally
|
|
97
86
|
//% anchor.defl=ScaleAnchor.Middle
|
|
98
87
|
//% proportional.defl=0
|
|
99
|
-
//% help=sprites/sprite-scaling/
|
|
100
|
-
export function
|
|
101
|
-
|
|
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);
|
|
102
111
|
}
|
|
103
112
|
}
|
|
@@ -34518,7 +34518,7 @@ switch (step) {
|
|
|
34518
34518
|
return leave(s, r0)
|
|
34519
34519
|
default: oops()
|
|
34520
34520
|
} } }
|
|
34521
|
-
Sprite_toString__P153950.info = {"start":
|
|
34521
|
+
Sprite_toString__P153950.info = {"start":37672,"length":93,"line":1169,"column":4,"endLine":1171,"endColumn":5,"fileName":"pxt_modules/game/sprite.ts","functionName":"toString","argumentNames":["this"]}
|
|
34522
34522
|
|
|
34523
34523
|
function Sprite_toString__P153950_mk(s) {
|
|
34524
34524
|
checkStack(s.depth);
|