Class Glyph

java.lang.Object
tripleplay.util.Glyph
All Implemented Interfaces:
AutoCloseable, react.Closeable

public class Glyph extends Object implements react.Closeable
Handles the maintenance of a canvas image and layer for displaying a chunk of pre-rendered graphics.
  • Constructor Details

  • Method Details

    • prepare

      public void prepare(Graphics gfx, pythagoras.f.IDimension dim)
      Ensures that the canvas image is at least the specified dimensions and cleared to all transparent pixels. Also creates and adds the image layer to the parent layer if needed.
    • prepare

      public void prepare(Graphics gfx, float width, float height)
      Ensures that the canvas image is at least the specified dimensions and cleared to all transparent pixels. Also creates and adds the image layer to the parent layer if needed.
    • layer

      public ImageLayer layer()
      Returns the layer that contains our glyph image. Valid after prepare(playn.core.Graphics, pythagoras.f.IDimension).
    • begin

      public Canvas begin()
      Starts a drawing session into this glyph's canvas. Call end() when drawing is done. Valid after prepare(playn.core.Graphics, pythagoras.f.IDimension).
    • end

      public void end()
      Completes a drawing sesion into this glyph's canvas and uploads the image data to GPU
    • close

      public void close()
      Disposes the layer and image, removing them from the containing widget.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface react.Closeable
    • preparedWidth

      public float preparedWidth()
      Returns the width of the last call to prepare(playn.core.Graphics, pythagoras.f.IDimension), or zero if the glyph is not prepared. The canvas should be at least this width, or null if the glyph is not prepared.
    • preparedHeight

      public float preparedHeight()
      Returns the height of the last call to prepare(playn.core.Graphics, pythagoras.f.IDimension), or zero if the glyph is not prepared. The canvas should be at least this height, or null if the glyph is not prepared.
    • renderText

      public void renderText(Graphics gfx, StyledText.Plain text)
      Prepares the canvas and renders the supplied text at 0, 0 using the given config.
    • renderText

      public void renderText(Graphics gfx, StyledText.Plain text, int x, int y)
      Prepares the canvas and renders the supplied text at x, y using the given config.