Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
38 lines (32 sloc) 888 Bytes
import dispatch._
import dispatch.meetup.RsvpsStream
import dispatch.liftjson.Js
import net.liftweb.json.JsonAST._
override def setup() {
frameRate(40)
size(500, 500, P3D)
(new nio.Http)(RsvpsStream.open(None) { js =>
rsvps = (for {
JField("mtime", JInt(cur)) <- js
JField("group_lon", JDouble(lon)) <- js
JField("group_lat", JDouble(lat)) <- js
} yield Rsvp(cur, lat, lon)) ::: rsvps.filter { r => tx(r) > 0 }
})
}
var rsvps: List[Rsvp] = Nil
case class Rsvp(time: BigInt, lat: Double, lon: Double)
def tx(r: Rsvp) = {
val dur = 30000
val max = System.currentTimeMillis
val min = max - dur
(r.time - min).toFloat / dur * width
}
def draw() {
background(55)
stroke(255)
for (r <- rsvps) {
val x = ((r.lon + 180).toFloat / 360) * width
val y = height - ((r.lat + 90).toFloat / 180) * height
line(x, y, tx(r), height)
}
}