Package playn.core

Class Graphics

java.lang.Object
playn.core.Graphics

public abstract class Graphics extends Object
Provides access to graphics information and services.
  • Field Details

    • gl

      public final GL20 gl
      Provides access to GL services.
    • viewSize

      public final IDimension viewSize
      The current size of the graphics viewport.
    • deviceOrient

      public final ValueView<Graphics.Orientation> deviceOrient
      The current orientation of the device. Devices that do not support orientation will always be PORTRAIT.
    • orientDetail

      public final ValueView<Graphics.OrientationDetail> orientDetail
      The current orientation of the device in more detailed form. Devices that do not support orientation will always be UNKNOWN.
    • defaultRenderTarget

      public RenderTarget defaultRenderTarget
      The render target for the default framebuffer.
  • Method Details

    • scale

      public Scale scale()
      Returns the display scale factor. This will be Scale.ONE except on HiDPI devices that have been configured to use HiDPI mode.
    • screenSize

      public abstract IDimension screenSize()
      Returns the size of the screen in display units. On some platforms (like the desktop) the screen size may be larger than the view size.
    • createCanvas

      public Canvas createCanvas(float width, float height)
      Creates a Canvas with the specified display unit size.
    • createCanvas

      public Canvas createCanvas(IDimension size)
    • createCanvas

      public abstract Canvas createCanvas(Scale scale, int pixelWidth, int pixelHeight)
      Creates a Canvas at the specified scale and with the specified (pixel) width and height. Most callers should use createCanvas(float,float) rather than this method, but if you have special needs, this gives you full control over the size of the canvas's underlying bitmap.
    • createPath

      public abstract Path createPath()
      Creates a Path object.
    • createGradient

      public abstract Gradient createGradient(Gradient.Config config)
      Creates a Gradient fill pattern.
    • createTexture

      public Texture createTexture(float width, float height, Texture.Config config)
      Creates an empty texture into which one can render. The supplied width and height are in display units and will be converted to pixels based on the current scale factor.
    • createTexture

      public Texture createTexture(IDimension size, Texture.Config config)
    • layoutText

      public abstract TextLayout layoutText(String text, TextFormat format)
      Lays out a single line of text using the specified format. The text may subsequently be rendered on a canvas via (TextLayout,float,float).
    • layoutText

      public abstract TextLayout[] layoutText(String text, TextFormat format, TextWrap wrap)
      Lays out multiple lines of text using the specified format and wrap configuration. The text may subsequently be rendered on a canvas via (TextLayout,float,float).