Beispiel #1
0
 public static void drawPolygon(ShapeRenderer sr, float[] polygon, float lineWidth) {
   ShapeRenderer.ShapeType type = sr.getCurrentType();
   sr.end();
   if (lineWidth == 0f) {
     sr.begin(ShapeRenderer.ShapeType.Line);
     sr.polygon(polygon);
   } else {
     sr.begin(ShapeRenderer.ShapeType.Filled);
     for (int i = 0; i < polygon.length / 2; i++) {
       sr.rectLine(
           polygon[i * 2],
           polygon[i * 2 + 1],
           polygon[(i * 2 + 2) % polygon.length],
           polygon[(i * 2 + 3) % polygon.length],
           lineWidth);
     }
   }
   sr.end();
   sr.begin(type);
 }
Beispiel #2
0
    @Override
    public void renderAffine2(ShapeRenderer renderer, Transform transform) {
      tmp.set(renderer.getColor());
      renderer.setColor(color);
      affine2.set(transform.affine2);

      float x = ox + (centre ? -width / 2f : 0);
      float y = oy + (centre ? -height / 2f : 0);
      affine2.translate(x, y);

      Affine2Utils.rectangle(width, height, affine2, rect);
      if (renderer.getCurrentType() == ShapeRenderer.ShapeType.Filled) {
        // cant do polygon :/
        renderer.triangle(rect[X1], rect[Y1], rect[X2], rect[Y2], rect[X3], rect[Y3]);
        renderer.triangle(rect[X1], rect[Y1], rect[X3], rect[Y3], rect[X4], rect[Y4]);
      } else {
        renderer.polygon(rect);
      }
      renderer.setColor(tmp);
    }