Interface GraphicsContext2D

  • All Known Implementing Classes:
    GDXGraphics2D, Java2DGraphicsContext, TeaGraphicsContext

    public interface GraphicsContext2D
    Provides access to the renderer's 2D drawing operations. The renderer only allows drawing operations to be performed when the frame is rendered.

    All drawing operations use X and Y coordinates that are relative to the canvas, with the (0, 0) coordinate representing the top left corner. When drawing objects, the X and Y coordinates indicate where the object's center will be drawn. There is no explicit Z coordinate, depth ordering is based on the order in which the graphics are drawn: graphics that are drawn later will overlap graphics that were drawn earlier.

    • Method Detail

      • getCanvas

        Canvas getCanvas()
      • getCanvasWidth

        default int getCanvasWidth()
      • getCanvasHeight

        default int getCanvasHeight()
      • drawBackground

        void drawBackground​(ColorRGB backgroundColor)
      • drawRect

        default void drawRect​(Rect rect,
                              ColorRGB color,
                              int alpha)
      • drawRect

        default void drawRect​(Rect rect,
                              ColorRGB color)
      • drawCircle

        default void drawCircle​(Circle circle,
                                ColorRGB color,
                                int alpha)
      • drawCircle

        default void drawCircle​(Circle circle,
                                ColorRGB color)
      • drawPolygon

        default void drawPolygon​(Polygon polygon,
                                 ColorRGB color,
                                 int alpha)
      • drawPolygon

        default void drawPolygon​(Polygon polygon,
                                 ColorRGB color)
      • drawImage

        void drawImage​(Image image,
                       float x,
                       float y,
                       Transform transform)
      • drawImage

        default void drawImage​(Image image,
                               float x,
                               float y)
      • drawSprite

        default void drawSprite​(Sprite sprite)
      • fillImage

        default void fillImage​(Image image)
        Draws an image and stretches it so that it fills the entire canvas. Note that depending on the canvas size this might mean that the image will be drawn at a different aspect ratio.
      • drawText

        default void drawText​(java.lang.String text,
                              TTFont font,
                              float x,
                              float y,
                              Align align)
      • drawText

        default void drawText​(java.lang.String text,
                              TTFont font,
                              float x,
                              float y)