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

import mavigator.util.Environment

import org.scalajs.dom.html
import rx._

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)
  }
}