summaryrefslogtreecommitdiff
path: root/src/graphyx/graphics/GraphicalBody.scala
diff options
context:
space:
mode:
authorJakob Odersky <jodersky@gmail.com>2009-11-05 21:02:40 +0000
committerJakob Odersky <jodersky@gmail.com>2009-11-05 21:02:40 +0000
commit9d20024aa35cd7f923ebfc1ed9a2ffbf2731da70 (patch)
tree4e97fadc391b310ee1cc7156fda590dff414b2c3 /src/graphyx/graphics/GraphicalBody.scala
parent034bc5930ea6f01745f64a6070711d899d2c27ae (diff)
downloadsims-9d20024aa35cd7f923ebfc1ed9a2ffbf2731da70.tar.gz
sims-9d20024aa35cd7f923ebfc1ed9a2ffbf2731da70.tar.bz2
sims-9d20024aa35cd7f923ebfc1ed9a2ffbf2731da70.zip
Initial import.
Diffstat (limited to 'src/graphyx/graphics/GraphicalBody.scala')
-rw-r--r--src/graphyx/graphics/GraphicalBody.scala42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/graphyx/graphics/GraphicalBody.scala b/src/graphyx/graphics/GraphicalBody.scala
new file mode 100644
index 0000000..c78ea51
--- /dev/null
+++ b/src/graphyx/graphics/GraphicalBody.scala
@@ -0,0 +1,42 @@
+/*
+ * Graphyx
+ * copyright (c) 2009 Jakob Odersky
+ * made available under the MIT License
+*/
+
+package graphyx.graphics
+
+import sims.dynamics._
+
+case class GraphicalBody(real: Body) extends GraphicalObject {
+ val pos = real.pos
+ val fixed = real.fixed
+ val monitor = real.monitor
+ def draw() = {
+ val radius = 4
+ val posX = (pos.x * scale * ppm).toInt
+ val posY = correctY(pos.y * scale * ppm).toInt
+ g.setColor(java.awt.Color.yellow)
+ g.fillArc(posX - radius,
+ posY - radius,
+ (radius * 2).toInt,
+ (radius * 2).toInt,
+ 0, 90)
+ g.fillArc(posX - radius,
+ posY - radius,
+ (radius * 2).toInt,
+ (radius * 2).toInt,
+ 180, 90)
+ g.setColor(java.awt.Color.black)
+ g.fillArc(posX - radius,
+ posY - radius,
+ (radius * 2).toInt,
+ (radius * 2).toInt,
+ 90, 90)
+ g.fillArc(posX - radius,
+ posY - radius,
+ (radius * 2).toInt,
+ (radius * 2).toInt,
+ 270, 90)
+ }
+}