summaryrefslogtreecommitdiff
path: root/src/graphyx/graphics/GraphicalBody.scala
blob: c78ea511748bd8a9820842588ecc758df70516c0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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)
  }
}