diff options
author | Li Haoyi <haoyi@dropbox.com> | 2014-10-27 17:04:20 -0700 |
---|---|---|
committer | Li Haoyi <haoyi@dropbox.com> | 2014-10-27 17:04:20 -0700 |
commit | 65fe456b96d81b6d166ff1a38a7c6ab529d284c2 (patch) | |
tree | 1f196bd703a91c5d2915a34749774db9ded95f25 /examples | |
parent | b968a31d80490f624ce517a23b83e3cff60b6d95 (diff) | |
download | hands-on-scala-js-65fe456b96d81b6d166ff1a38a7c6ab529d284c2.tar.gz hands-on-scala-js-65fe456b96d81b6d166ff1a38a7c6ab529d284c2.tar.bz2 hands-on-scala-js-65fe456b96d81b6d166ff1a38a7c6ab529d284c2.zip |
lots of stuff
Diffstat (limited to 'examples')
-rw-r--r-- | examples/src/main/scala/Example.scala | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/examples/src/main/scala/Example.scala b/examples/src/main/scala/Example.scala index b5e77ca..3e6a9c9 100644 --- a/examples/src/main/scala/Example.scala +++ b/examples/src/main/scala/Example.scala @@ -29,17 +29,15 @@ object Example extends scalajs.js.JSApp{ ("green", x => 1 - abs(x % 4 - 2)), ("blue", x => pow(sin(x/12), 2) * sin(x)) ).zipWithIndex - def run() = { - x = (x + 1) % w - if (x == 0) clear() - else for (((color, f), i) <- graphs) { + dom.setInterval(() => { + x = (x + 1) % w; if (x == 0) clear() + for (((color, f), i) <- graphs) { val offset = h / 3 * (i + 0.5) - val y = f(x / w * 75) * h / 40 + val y = f(x / w * 75) * h / 30 renderer.fillStyle = color renderer.fillRect(x, y + offset, 3, 3) } - } - dom.setInterval(run _, 20) + }, 20) } }
\ No newline at end of file |