aboutsummaryrefslogtreecommitdiff
path: root/vfd-dashboard/src/main/scala/vfd/dashboard/ui/instruments/Altimeter.scala
blob: b65b3747066d97fde92f80c9703b1e7862999212 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
package vfd.dashboard.ui.instruments

import org.scalajs.dom.html
import rx._
import vfd.dashboard.Environment

class Altimeter(val value: Rx[Double])(implicit env: Environment) extends SvgInstrument[Double] {
  import SvgInstrument._

  lazy val element = svgObject("altimeter")
  lazy val hand = part("hand")
  lazy val moveable = Seq(hand)

  // 1m === 36deg = 2Pi / 10 ~= 0.62832
  protected def update(altitude: Double) = {
    rotate(hand, (altitude * 0.62832).toInt)
  }
}