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 /