summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorLi Haoyi <haoyi@dropbox.com>2014-12-28 16:20:43 +0100
committerLi Haoyi <haoyi@dropbox.com>2014-12-28 16:20:43 +0100
commit0c5f80d41b52d3c3533cdb94ff64d2fb0133526a (patch)
treec50a71495cefe773ca28c385356ccf01a4dc6c76 /examples
parent8eba9de819131993fd056a8833fb384de0904a8c (diff)
downloadhands-on-scala-js-0c5f80d41b52d3c3533cdb94ff64d2fb0133526a.tar.gz
hands-on-scala-js-0c5f80d41b52d3c3533cdb94ff64d2fb0133526a.tar.bz2
hands-on-scala-js-0c5f80d41b52d3c3533cdb94ff64d2fb0133526a.zip
scalatex split out for reals
Diffstat (limited to 'examples')
-rw-r--r--examples/demos/src/main/scala/Splash.scala11
1 files changed, 5 insertions, 6 deletions
diff --git a/examples/demos/src/main/scala/Splash.scala b/examples/demos/src/main/scala/Splash.scala
index c68bdca..1cda98c 100644
--- a/examples/demos/src/main/scala/Splash.scala
+++ b/examples/demos/src/main/scala/Splash.scala
@@ -15,7 +15,7 @@ object Splash extends{
}
clear()
- val renderer =
+ val brush =
canvas.getContext("2d")
.asInstanceOf[dom.CanvasRenderingContext2D]
@@ -26,18 +26,17 @@ object Splash extends{
type Graph = (String, Double => Double)
val graphs = Seq[Graph](
("red", sin),
- ("green", x => 1 - abs(x % 4 - 2)),
- ("blue", x => pow(sin(x/12), 2) * sin(x))
+ ("green", x => abs(x % 4 - 2) - 1),
+ ("blue", x => sin(x/12) * sin(x))
).zipWithIndex
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 / 30
- renderer.fillStyle = color
- renderer.fillRect(x, y + offset, 3, 3)
+ brush.fillStyle = color
+ brush.fillRect(x, y + offset, 3, 3)
}
}, 20)
-
}
} \ No newline at end of file