diff options
author | Jakob Odersky <jodersky@gmail.com> | 2015-03-27 12:48:24 +0100 |
---|---|---|
committer | Jakob Odersky <jodersky@gmail.com> | 2015-03-27 12:48:24 +0100 |
commit | bd174539d8bb2921bef94cccd994a61e334a3dd7 (patch) | |
tree | fa89d47f97779c16d3a54b62518b8c83fc907d3c /vfd-dashboard/src/main/scala/vfd/dashboard/ui/instruments/Balance.scala | |
parent | f7f157cea1afd3386e46938a110c5a2ed72933fb (diff) | |
parent | c2b0a3de4dca16cb9143acffdcc7a9ad1a730b50 (diff) | |
download | mavigator-bd174539d8bb2921bef94cccd994a61e334a3dd7.tar.gz mavigator-bd174539d8bb2921bef94cccd994a61e334a3dd7.tar.bz2 mavigator-bd174539d8bb2921bef94cccd994a61e334a3dd7.zip |
Merge pull request #12 from jodersky/design/cleanupconcise-dialect
Clean up internal structure of dashboard ui
Diffstat (limited to 'vfd-dashboard/src/main/scala/vfd/dashboard/ui/instruments/Balance.scala')
-rw-r--r-- | vfd-dashboard/src/main/scala/vfd/dashboard/ui/instruments/Balance.scala | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/vfd-dashboard/src/main/scala/vfd/dashboard/ui/instruments/Balance.scala b/vfd-dashboard/src/main/scala/vfd/dashboard/ui/instruments/Balance.scala new file mode 100644 index 0000000..ef5a3cc --- /dev/null +++ b/vfd-dashboard/src/main/scala/vfd/dashboard/ui/instruments/Balance.scala @@ -0,0 +1,27 @@ +package vfd.dashboard.ui.instruments + +import org.scalajs.dom.html +import vfd.dashboard.Environment + +class Balance(implicit env: Environment) extends SvgInstrument[(Double, Double, Double, Double)] { + import SvgInstrument._ + + val initial = (0.0, 0.0, 0.0, 0.0) + + lazy val element = svgObject("balance") + lazy val position = part("position") + lazy val moveable = Seq(position) + + protected def update(value: (Double, Double, Double, Double)) = { + val m0 = value._1 + val m1 = value._2 + val m2 = value._3 + val m3 = value._4 + val s = m0 + m1 + m2 + m3 + val i = (m0 - m2) / s + val j = (m1 - m3) / s + val x = 0.5 * (i - j) + val y = 0.5 * (-i - j) + translate(position, (x * 50).toInt, (y * 50).toInt) + } +}
\ No newline at end of file |