aboutsummaryrefslogtreecommitdiff
path: root/vfd-dashboard/src/main/scala/vfd/dashboard/ui/instruments/Distribution.scala
diff options
context:
space:
mode:
authorJakob Odersky <jodersky@gmail.com>2015-04-03 17:40:54 +0200
committerJakob Odersky <jodersky@gmail.com>2015-04-03 17:40:54 +0200
commit70e527dcfa26de0936adaf1e3c0e26ce673bc352 (patch)
treed68a19b5af56504ecba9661337a38b7cd5e46b17 /vfd-dashboard/src/main/scala/vfd/dashboard/ui/instruments/Distribution.scala
parente144f8a38ba869372ef9aa5936608f619bb6092a (diff)
downloadmavigator-70e527dcfa26de0936adaf1e3c0e26ce673bc352.tar.gz
mavigator-70e527dcfa26de0936adaf1e3c0e26ce673bc352.tar.bz2
mavigator-70e527dcfa26de0936adaf1e3c0e26ce673bc352.zip
reimplement motor load instrument
Diffstat (limited to 'vfd-dashboard/src/main/scala/vfd/dashboard/ui/instruments/Distribution.scala')
-rw-r--r--vfd-dashboard/src/main/scala/vfd/dashboard/ui/instruments/Distribution.scala26
1 files changed, 26 insertions, 0 deletions
diff --git a/vfd-dashboard/src/main/scala/vfd/dashboard/ui/instruments/Distribution.scala b/vfd-dashboard/src/main/scala/vfd/dashboard/ui/instruments/Distribution.scala
new file mode 100644
index 0000000..caeac33
--- /dev/null
+++ b/vfd-dashboard/src/main/scala/vfd/dashboard/ui/instruments/Distribution.scala
@@ -0,0 +1,26 @@
+package vfd.dashboard.ui.instruments
+
+import org.scalajs.dom.html
+import vfd.dashboard.Environment
+
+class Distribution(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("distribution")
+ lazy val position = part("position")
+ lazy val moveable = Seq(position)
+
+ private final val Radius = 50 //px
+
+ protected def update(value: (Double, Double, Double, Double)) = {
+ val sum = value._1 + value._2 + value._3 + value._4
+ val i = (value._1 - value._3) / sum
+ val j = (value._2 - value._4) / sum
+ val x = math.sqrt(2) / 2 * (i - j)
+ val y = math.sqrt(2) / 2 * (-i - j)
+ translate(position, (x * Radius).toInt, (y * Radius).toInt)
+ }
+
+} \ No newline at end of file