Package tripleplay.util
Class Glyph
java.lang.Object
tripleplay.util.Glyph
- All Implemented Interfaces:
AutoCloseable
,react.Closeable
Handles the maintenance of a canvas image and layer for displaying a chunk of pre-rendered
graphics.
-
Nested Class Summary
Nested classes/interfaces inherited from interface react.Closeable
react.Closeable.Set, react.Closeable.Util
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionbegin()
Starts a drawing session into this glyph's canvas.void
close()
Disposes the layer and image, removing them from the containing widget.void
end()
Completes a drawing sesion into this glyph's canvas and uploads the image data to GPUlayer()
Returns the layer that contains our glyph image.void
Ensures that the canvas image is at least the specified dimensions and cleared to all transparent pixels.void
Ensures that the canvas image is at least the specified dimensions and cleared to all transparent pixels.float
Returns the height of the last call toprepare(playn.core.Graphics, pythagoras.f.IDimension)
, or zero if the glyph is not prepared.float
Returns the width of the last call toprepare(playn.core.Graphics, pythagoras.f.IDimension)
, or zero if the glyph is not prepared.void
renderText
(Graphics gfx, StyledText.Plain text) Prepares the canvas and renders the supplied text at 0, 0 using the given config.void
renderText
(Graphics gfx, StyledText.Plain text, int x, int y) Prepares the canvas and renders the supplied text atx, y
using the given config.
-
Constructor Details
-
Glyph
-
Glyph
-
-
Method Details
-
prepare
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
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
Returns the layer that contains our glyph image. Valid afterprepare(playn.core.Graphics, pythagoras.f.IDimension)
. -
begin
Starts a drawing session into this glyph's canvas. Callend()
when drawing is done. Valid afterprepare(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 interfaceAutoCloseable
- Specified by:
close
in interfacereact.Closeable
-
preparedWidth
public float preparedWidth()Returns the width of the last call toprepare(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 toprepare(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
Prepares the canvas and renders the supplied text at 0, 0 using the given config. -
renderText
Prepares the canvas and renders the supplied text atx, y
using the given config.
-