Home  Contents

gcx:state

Graphics Core4 Lua Commands

SYNOPSIS

  1. state = gcx:state()
  2. gcx:state(src_state)
  3. gcx:state(src_gcx)

DESCRIPTION

Functions for setting and retrieving the state of a graphics context. The state contains the current values of foreground color, background color, font, alpha blending mode, blitting mode and text format.

The first form will return the current state so it can be saved away while messing with the context.

The second form will restore a previously saved state, while the third form simply copies the state from another graphics context.

RETURN VALUE

The first form returns an opaque state structure that can be used to restore the state.

ERRORS

Raises an error if gcx is not a graphics context or if the argument is neither a saved state nor a graphics context.

EXAMPLE

This saves the state to a local variable. After a text is printed, the previous colors and the font is restored.
>  >  >  >  >  > 
local st = gcx:state() gcx:color(0xFF00FF) gcx:bgcolor(0x00FF00) gcx:font(gfx.default_font()) gcx:text(100,100,"TEST") gcx:state(st)

SEE ALSO