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

import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics2D;
import java.awt.geom.AffineTransform;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;

public class TextParticle extends Particle {
  private Font font;
  private final String text;

  public TextParticle(final String text) {
    super(0, 0);
    this.text = text;
  }

  public Font getFont() {
    return this.font;
  }

  public String getText() {
    return this.text;
  }

  @Override
  public void render(final Graphics2D g, final Point2D emitterOrigin) {
    if (this.getText() == null || this.getText().isEmpty()) {
      return;
    }

    final Font oldFont = g.getFont();
    if (this.getFont() != null) {
      g.setFont(this.getFont());
    }
    final FontMetrics fm = g.getFontMetrics();
    this.setWidth(fm.stringWidth(this.getText()));
    this.setHeight(g.getFont().getSize2D());

    final Point2D renderLocation = this.getRenderLocation(emitterOrigin);
    final AffineTransform rotate = AffineTransform.getRotateInstance(Math.toRadians(this.getAngle()), this.getWidth() * 0.5, this.getHeight() * 0.5);
    g.setFont(g.getFont().deriveFont(rotate));
    g.setColor(this.getColor());
    g.drawString(text, (float) renderLocation.getX(), (float) renderLocation.getY());
    g.setFont(oldFont);
  }

  public void setFont(final Font font) {
    this.font = font;
  }

  @Override
  public Rectangle2D getBoundingBox(final Point2D origin) {
    return new Rectangle2D.Double(origin.getX() + this.getX() - this.getWidth() / 2, origin.getY() + this.getY() - this.getHeight() * 1.5, this.getWidth(), this.getHeight());
  }

}

@@ -58,16 +58,96 @@
 les;%0D%0A%0D%0A
+import de.gurkenlabs.litiengine.graphics.TextRenderer;%0D%0Aimport java.awt.Color;%0D%0A
 import j
@@ -161,16 +161,16 @@
 .Font;%0D%0A
-
 import j
@@ -216,24 +216,57 @@
 raphics2D;%0D%0A
+import java.awt.RenderingHints;%0D%0A
 import java.
@@ -518,12 +518,12 @@
 per(
-0, 0
+1, 1
 );%0D%0A
@@ -1373,24 +1373,85 @@
 t(rotate));%0D
+%0A%0D%0A    RenderingHints originalHints = g.getRenderingHints();%0D
 %0A    g.setCo
@@ -1454,16 +1454,26 @@
 etColor(
+new Color(
 this.get
@@ -1479,18 +1479,214 @@
 tColor()
-);
+.getRed() / 255f, this.getColor().getGreen() / 255f, this.getColor().getBlue() / 255f, this.getOpacity()));%0D%0A%0D%0A    if (this.isAntiAliased()) %7B%0D%0A      TextRenderer.enableTextAntiAliasing(g);%0D%0A    %7D%0D%0A
 %0D%0A    g.
@@ -1762,24 +1762,24 @@
 n.getY());%0D%0A
-
     g.setFon
@@ -1787,24 +1787,65 @@
 (oldFont);%0D%0A
+    g.setRenderingHints(originalHints);%0D%0A
   %7D%0D%0A%0D%0A  pub

Support color fading and antialiasing for TextParticle