Class ColorLayer

All Implemented Interfaces:
IRenderable
Direct Known Subclasses:
AmbientLight, StaticShadowLayer

public abstract class ColorLayer extends Object implements IRenderable
Represents an abstract color layer that can be rendered and updated.
  • Constructor Details

    • ColorLayer

      protected ColorLayer(Environment env, Color color)
      Constructs a new ColorLayer with the specified environment and color.
      Parameters:
      env - The environment associated with this color layer.
      color - The initial color of the layer.
  • Method Details

    • render

      public void render(Graphics2D g)
      Description copied from interface: IRenderable

      Renders the visual contents of this instance onto the provided graphics context.

      If an Entity implements this interface, this method will be called right after the entity was rendered from the environment. Allowing for a custom rendering mechanism.

      This interface can be implemented in general by anything that should be rendered to the game's screen.

      Specified by:
      render in interface IRenderable
      Parameters:
      g - The current graphics object onto which this instance will render its visual contents.
      See Also:
    • getColor

      public Color getColor()
      Gets the current color of the layer.
      Returns:
      The current color of the layer.
    • setAlpha

      public void setAlpha(int ambientAlpha)
      Sets the alpha value of the current color.
      Parameters:
      ambientAlpha - The alpha value to set, clamped between 0 and 255.
    • setColor

      public void setColor(Color color)
      Sets the color of the layer.
      Parameters:
      color - The color to set. If null, the method returns without making changes.
    • updateSection

      public void updateSection(Rectangle2D section)
      Updates a specific section of the layer.
      Parameters:
      section - The section of the layer to update.
    • renderSection

      protected abstract void renderSection(Graphics2D g, Rectangle2D section)
      Renders a specific section of the layer.
      Parameters:
      g - The graphics context to use for rendering.
      section - The section of the layer to render.
    • clearSection

      protected abstract void clearSection(Graphics2D g, Rectangle2D section)
      Clears a specific section of the layer.
      Parameters:
      g - The graphics context to use for clearing.
      section - The section of the layer to clear.
    • getEnvironment

      protected Environment getEnvironment()
      Gets the environment associated with this color layer.
      Returns:
      The environment associated with this color layer.