Class ShapeParticle

java.lang.Object
de.gurkenlabs.litiengine.graphics.emitters.particles.Particle
de.gurkenlabs.litiengine.graphics.emitters.particles.ShapeParticle
All Implemented Interfaces:
ITimeToLive
Direct Known Subclasses:
EllipseParticle, LineParticle, PolygonParticle, RectangleParticle

public abstract class ShapeParticle extends Particle

Represents a particle with a specific shape.

This abstract class defines the behavior and rendering logic for particles that are represented by geometric shapes. Subclasses must implement the getShape(Point2D) method to define the specific shape of the particle.

  • Constructor Details

    • ShapeParticle

      protected ShapeParticle(float width, float height)
      Creates a new shape particle with the specified dimensions.
      Parameters:
      width - the width of the particle
      height - the height of the particle
  • Method Details

    • getShape

      protected abstract Shape getShape(Point2D emitterOrigin)

      Retrieves the shape of the particle based on the emitter's origin.

      This method must be implemented by subclasses to define the specific shape of the particle.

      Parameters:
      emitterOrigin - the origin point of the emitter
      Returns:
      the shape of the particle
    • getBoundingBox

      public Rectangle2D getBoundingBox(Point2D origin)

      Retrieves the bounding box of the particle.

      The bounding box is calculated based on the particle's shape and the specified origin point.

      Overrides:
      getBoundingBox in class Particle
      Parameters:
      origin - the origin point of the emitter
      Returns:
      the bounding box of the particle as a Rectangle2D
    • render

      public void render(Graphics2D g, Point2D emitterOrigin)

      Renders the particle on the specified graphics context.

      The rendering behavior depends on whether the particle is outline-only or a specific subclass such as LineParticle. The particle's color, opacity, and anti-aliasing settings are applied during rendering.

      Specified by:
      render in class Particle
      Parameters:
      g - the graphics context to render on
      emitterOrigin - the origin point of the emitter