examples

clown.js

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
pl = display.emoji("🤡")
rt = display.rect(100, 100, 10, 10)

update(() => {
  rt.color = color.hsb(rt.angle, 75, 95)
})

timer.every(1000, () => {
  rt.animate({
    duration: 400,
    easing: Easing.easeInOutCubic
  }, (to) => {
    to.position = random.pos()
    to.size = random.size()
    to.angle = random.num(0, 360)
  })
})

stn = ui.button("Start", (display.width / 2) - 50, 100)
stn.action(() => {
  pl.animate({
    duration: 1000,
    delay: 400,
    autoreverse: true,
    easing: Easing.easeInOutCubic
  }, (to) => {
    to.position = random.pos()
    to.angle = 720
    to.size = {
      width: pl.size.width * 4,
      height: pl.size.height * 4
    }
  }, (retval) => {
    print("completed!", retval)
  })
})

btn = ui.button("Stop", (display.width / 2) + 50, 100)
btn.action(() => {
  pl.stopAnimations()
})