Esempio n. 1
0
 @Override
 public void drawString(float x, float y, String s, Color3f color) {
   Graphics2D g = getGraphics();
   if (g == null) {
     return;
   }
   Color c = cpool.getColor(color.x, color.y, color.z);
   g.setColor(c);
   g.drawString(s, x, y);
 }
Esempio n. 2
0
 @Override
 public void drawSolidCircle(Vec2 center, float radius, Vec2 axis, Color3f color) {
   Graphics2D g = getGraphics();
   saveState(g);
   transformGraphics(g, center);
   g.setStroke(stroke);
   Color f = cpool.getColor(color.x, color.y, color.z, .4f);
   Color s = cpool.getColor(color.x, color.y, color.z, 1f);
   g.scale(radius, radius);
   g.setColor(f);
   g.fill(circle);
   g.setColor(s);
   g.draw(circle);
   if (axis != null) {
     g.rotate(MathUtils.atan2(axis.y, axis.x));
     g.drawLine(0, 0, 1, 0);
   }
   restoreState(g);
 }
Esempio n. 3
0
  @Override
  public void drawSegment(Vec2 p1, Vec2 p2, Color3f color) {
    getWorldToScreenToOut(p1, sp1);
    getWorldToScreenToOut(p2, sp2);

    Color c = cpool.getColor(color.x, color.y, color.z);
    Graphics2D g = getGraphics();
    g.setColor(c);
    g.setStroke(stroke);
    g.drawLine((int) sp1.x, (int) sp1.y, (int) sp2.x, (int) sp2.y);
  }
Esempio n. 4
0
  @Override
  public void drawPoint(Vec2 argPoint, float argRadiusOnScreen, Color3f argColor) {
    getWorldToScreenToOut(argPoint, sp1);
    Graphics2D g = getGraphics();

    Color c = cpool.getColor(argColor.x, argColor.y, argColor.z);
    g.setColor(c);
    sp1.x -= argRadiusOnScreen;
    sp1.y -= argRadiusOnScreen;
    g.fillOval((int) sp1.x, (int) sp1.y, (int) argRadiusOnScreen * 2, (int) argRadiusOnScreen * 2);
  }
Esempio n. 5
0
 @Override
 public void drawSolidPolygon(Vec2[] vertices, int vertexCount, Color3f color) {
   Color f = cpool.getColor(color.x, color.y, color.z, .4f);
   Color s = cpool.getColor(color.x, color.y, color.z, 1f);
   Graphics2D g = getGraphics();
   saveState(g);
   int[] xInts = xIntsPool.get(vertexCount);
   int[] yInts = yIntsPool.get(vertexCount);
   for (int i = 0; i < vertexCount; i++) {
     getWorldToScreenToOut(vertices[i], temp);
     xInts[i] = (int) temp.x;
     yInts[i] = (int) temp.y;
   }
   g.setStroke(stroke);
   g.setColor(f);
   g.fillPolygon(xInts, yInts, vertexCount);
   g.setColor(s);
   g.drawPolygon(xInts, yInts, vertexCount);
   restoreState(g);
 }
Esempio n. 6
0
 @Override
 public void drawCircle(Vec2 center, float radius, Color3f color) {
   Graphics2D g = getGraphics();
   Color s = cpool.getColor(color.x, color.y, color.z, 1f);
   saveState(g);
   transformGraphics(g, center);
   g.setStroke(stroke);
   g.scale(radius, radius);
   g.setColor(s);
   g.drawOval(-1, -1, 2, 2);
   restoreState(g);
 }
Esempio n. 7
0
  @Override
  public void drawTransform(Transform xf) {
    Graphics2D g = getGraphics();
    getWorldToScreenToOut(xf.p, temp);
    temp2.setZero();
    float k_axisScale = 0.4f;

    Color c = cpool.getColor(1, 0, 0);
    g.setColor(c);

    temp2.x = xf.p.x + k_axisScale * xf.q.c;
    temp2.y = xf.p.y + k_axisScale * xf.q.s;
    getWorldToScreenToOut(temp2, temp2);
    g.drawLine((int) temp.x, (int) temp.y, (int) temp2.x, (int) temp2.y);

    c = cpool.getColor(0, 1, 0);
    g.setColor(c);
    temp2.x = xf.p.x + -k_axisScale * xf.q.s;
    temp2.y = xf.p.y + k_axisScale * xf.q.c;
    getWorldToScreenToOut(temp2, temp2);
    g.drawLine((int) temp.x, (int) temp.y, (int) temp2.x, (int) temp2.y);
  }
Esempio n. 8
0
 @Override
 public void drawParticles(Vec2[] centers, float radius, ParticleColor[] colors, int count) {
   Graphics2D g = getGraphics();
   saveState(g);
   transformGraphics(g, zero);
   g.setStroke(stroke);
   for (int i = 0; i < count; i++) {
     Vec2 center = centers[i];
     Color color;
     if (colors == null) {
       color = pcolorA;
     } else {
       ParticleColor c = colors[i];
       color = cpool.getColor(c.r * 1f / 127, c.g * 1f / 127, c.b * 1f / 127, c.a * 1f / 127);
     }
     AffineTransform old = g.getTransform();
     g.translate(center.x, center.y);
     g.scale(radius, radius);
     g.setColor(color);
     g.fill(circle);
     g.setTransform(old);
   }
   restoreState(g);
 }