Class RenderComponent

java.lang.Object
java.awt.Component
java.awt.Canvas
de.gurkenlabs.litiengine.graphics.RenderComponent
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class RenderComponent extends Canvas
The RenderComponent class extends Canvas and handles the rendering of the game screen, including managing fade effects, capturing screenshots, and rendering the game cursor.
See Also:
  • Field Details

    • DEFAULT_BACKGROUND_COLOR

      public static final Color DEFAULT_BACKGROUND_COLOR
      The default background color for the rendering component.
    • DEFAULT_FONT

      public static final Font DEFAULT_FONT
      The default font for rendering text in the component.
  • Constructor Details

    • RenderComponent

      public RenderComponent(Dimension size)
      Constructs a new RenderComponent with the specified size.
      Parameters:
      size - The size of the rendering component.
  • Method Details

    • fadeIn

      public void fadeIn(int ms)
      Initiates a fade-in effect over the specified duration.
      Parameters:
      ms - The duration of the fade-in effect in milliseconds.
    • fadeOut

      public void fadeOut(int ms)
      Initiates a fade-out effect over the specified duration.
      Parameters:
      ms - The duration of the fade-out effect in milliseconds.
    • init

      public void init()
      Initializes the RenderComponent, setting up the buffer strategy for rendering.
    • onFpsChanged

      public void onFpsChanged(IntConsumer fpsConsumer)
      Registers a consumer to be notified when the frames per second (FPS) change.
      Parameters:
      fpsConsumer - The consumer to notify of FPS changes.
    • onRendered

      public void onRendered(Consumer<Graphics2D> renderedConsumer)
      Registers a consumer to be notified after the component has been rendered.
      Parameters:
      renderedConsumer - The consumer to notify after rendering.
    • render

      public void render()
      Renders the game screen, including handling fade effects, cursor rendering, and screenshot capture.
    • takeScreenshot

      public void takeScreenshot()
      Signals the RenderComponent to take a screenshot on the next render cycle.