Hands-on Scala.js Writing client-side web applications in Scala var x = 0.0 type Graph = (String, Double => Double) val graphs = Seq[Graph]( ("red", sin), ("green", x => abs(x % 4 - 2) - 1), ("blue", x => sin(x/12) * sin(x)) ).zipWithIndex dom.window.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 /
![Hands-on Scala.js](https://cdn-ak-scissors.b.st-hatena.com/image/square/33ea8f9a6daeec98263bb0444b24fbfb26187b19/height=288;version=1;width=512/http%3A%2F%2Fwww.lihaoyi.com%2Fhands-on-scala-js%2Fimages%2FDropdown.png)