-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.ts
62 lines (60 loc) · 1.97 KB
/
main.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
let memSize1 = 0
let zLayerBlur1 = 1
let blurSize1 = 1
let variable1 = scene.createRenderable(zLayerBlur1, (image1: Image, camera: scene.Camera) => {
let screenClone = image1.clone()
if (blurSize1 != 1) {
let tempImg = image.create(Math.ceil(160 / blurSize1), Math.ceil(120 / blurSize1))
helpers.imageBlit(tempImg, 0, 0, Math.ceil(160 / blurSize1), Math.ceil(120 / blurSize1), screenClone, 0, 0, 160, 120, true, false)
helpers.imageBlit(image1, (tempImg.width * blurSize1 - 160) / -2, (tempImg.height * blurSize1 - 120) / -2, tempImg.width * blurSize1, tempImg.height * blurSize1, tempImg, 0, 0, tempImg.width, tempImg.height, true, false)
}
})
//% color="#83de8a"
//% block="Blur"
namespace blur {
//% block="blur screen image to pixel size $size || over $ms ms"
//% weight=0
//% ms.shadow="timePicker"
//% expandableArgumentMode="toggle"
export function SetBlurFilter(size: number, ms = 25) {
size = Math.max(1, size)
if (ms < 25) {
ms = 25
}
memSize1 = Math.floor(size - blurSize1) / (ms / 25)
for (let j = 0; j < (ms / 25); j++) {
blurSize1 += memSize1
pause(25)
}
}
//% block="blur in over $ms ms"
//% weight=2
//% ms.shadow="timePicker"
export function BlurIn(ms = 25) {
blurSize1 = 15
let size = 1
if (ms < 25) {
ms = 25
}
memSize1 = (size - blurSize1) / (ms / 25)
for (let j = 0; j < Math.floor(ms / 25); j++) {
blurSize1 += memSize1
pause(25)
}
}
//% block="blur out over $ms ms"
//% weight=1
//% ms.shadow="timePicker"
export function BlurOut(ms = 25) {
blurSize1 = 1
let size = 15
if (ms < 25) {
ms = 25
}
memSize1 = (size - blurSize1) / (ms / 25)
for (let j = 0; j < Math.floor(ms / 25); j++) {
blurSize1 += memSize1
pause(25)
}
}
}