diff options
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 |