package de.gurkenlabs.litiengine.graphics.emitters.particles;

import java.awt.Polygon;
import java.awt.Shape;
import java.awt.geom.AffineTransform;
import java.awt.geom.Point2D;

public class PolygonParticle extends ShapeParticle {
  private int sides;

  public PolygonParticle(float width, float height, int sides) {
    super(width, height);
    this.sides = sides;
  }

  @Override
  protected Shape getShape(Point2D emitterOrigin) {
    Polygon p = new Polygon();
    float x = this.getAbsoluteX(emitterOrigin) + this.getWidth() / 2;
    float y = this.getAbsoluteY(emitterOrigin) + this.getHeight() / 2;
    float theta = (float) (2 * Math.PI / this.sides);
    for (int i = 0; i < this.sides; i++) {
      p.addPoint(
          (int) (x + this.getWidth() * Math.cos(theta * i)),
          (int) (y + this.getHeight() * Math.sin(theta * i)));
    }
    final AffineTransform rotate =
        AffineTransform.getRotateInstance(
            Math.toRadians(this.getAngle()),
            this.getAbsoluteX(emitterOrigin) + this.getWidth() * 0.5,
            this.getAbsoluteY(emitterOrigin) + this.getHeight() * 0.5);
    return rotate.createTransformedShape(p);
  }
}

@@ -60,33 +60,8 @@
 s;%0A%0A
-import java.awt.Polygon;%0A
 impo
@@ -117,16 +117,45 @@
 nsform;%0A
+import java.awt.geom.Path2D;%0A
 import j
@@ -445,38 +445,46 @@
    P
-olygon p = new Polygon
+ath2D path = new Path2D.Double
 ();%0A    
 floa
@@ -479,21 +479,22 @@
 ();%0A    
-float
+double
  x = thi
@@ -550,21 +550,22 @@
  2;%0A    
-float
+double
  y = thi
@@ -622,21 +622,22 @@
  2;%0A    
-float
+double
  theta =
@@ -641,17 +641,8 @@
 a = 
-(float) (
 2 * 
@@ -661,16 +661,60 @@
 is.sides
+;%0A    path.moveTo(x + this.getWidth(), y + 0
 );%0A    f
@@ -762,17 +762,18 @@
    p
-.addPoint
+ath.lineTo
 (%0A  
@@ -780,23 +780,16 @@
         
-(int) (
 x + this
@@ -821,17 +821,16 @@
 eta * i)
-)
 ,%0A      
@@ -837,15 +837,8 @@
     
-(int) (
 y + 
@@ -880,17 +880,16 @@
  i))
-)
 ;%0A    %7D%0A
     
@@ -884,16 +884,38 @@
 ;%0A    %7D%0A
+    path.closePath();%0A
     fina
@@ -1213,16 +1213,19 @@
 dShape(p
+ath
 );%0A  %7D%0A%7D

Fix polygon particle rounding errors