Commit 82df6bc2 authored by h2b's avatar h2b

Demo updated.

parent 4780058b
......@@ -24,23 +24,46 @@ import de.h2b.scala.lib.simgraf.shapes.{ Coloring, Rectangle }
object EventEchoDemo extends App {
private val iterator = GridLayout.onScreen(1, 2).iterator
val frame = Rectangle(Point(-100,-100), Point(100,100))
val cell = GridLayout.onScreen(1, 1).fit(400, 400)
val title = "Event Echo demo"
val world = World.withEvents(frame)(cell, title)
world.fill(Coloring({
case Point(x, y) if (x>0 && y>0) Color.Blue
case Point(x, y) if (x>0 && y<0) Color.Black
case Point(x, y) if (x<0 && y>0) Color.Green
case Point(x, y) if (x<0 && y<0) Color.White
case _ Color.Red
}))
Subscriber.on(world) {
val cell1 = iterator.next().fit(400, 400)
val title1 = "Event Echo demo"
val cell2 = iterator.next().fit(400, 400)
val title2 = "Event Echo demo"
val world1 = World.withEvents(frame)(cell1, title1)
world1.fill(Coloring({
case Point(x, y) if (x>0 && y>0) Color.Blue
case Point(x, y) if (x>0 && y<0) Color.Black
case Point(x, y) if (x<0 && y>0) Color.Green
case Point(x, y) if (x<0 && y<0) Color.White
case _ Color.Red
}))
val world2 = World.withEvents(frame)(cell2, title2)
world2.fill(Coloring({
case Point(x, y) if (x>0 && y>0) Color.Magenta
case Point(x, y) if (x>0 && y<0) Color.Gray
case Point(x, y) if (x<0 && y>0) Color.Cyan
case Point(x, y) if (x<0 && y<0) Color.Yellow
case _ Color.Red
}))
Subscriber.on(world1) {
case KeyEvent(k) if k=='q'
world1.screen.close()
system.terminate()
case e: Event
println("w1: " + e)
}
Subscriber.on(world2) {
case KeyEvent(k) if k=='q'
world.screen.close()
world2.screen.close()
system.terminate()
case e: Event
println(e)
println("w2: " + e)
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment