_stage – C-level helpers for animation of sprites on a stage

The _stage module contains native code to speed-up the `stage Library <https://github.com/python-ugame/circuitpython-stage>`_.

Available on these boards
  • Adafruit EdgeBadge
  • Adafruit PyGamer
  • Adafruit Pybadge
  • BLING!
  • BlizzardS3
  • Electronut Labs Blip
  • MEOWBIT
  • Pajenicko PicoPad
  • PewPew M4
  • Pimoroni PicoSystem
  • TinyS2
  • TinyS3
  • TinyWATCH S3
  • uGame10
  • uGame22

_stage.render(x0: int, y0: int, x1: int, y1: int, layers: List[Layer], buffer: circuitpython_typing.WriteableBuffer, display: busdisplay.BusDisplay, scale: int, background: int) None

Render and send to the display a fragment of the screen.

Parameters:
  • x0 (int) – Left edge of the fragment.

  • y0 (int) – Top edge of the fragment.

  • x1 (int) – Right edge of the fragment.

  • y1 (int) – Bottom edge of the fragment.

  • layers (list[Layer]) – A list of the Layer objects.

  • buffer (WriteableBuffer) – A buffer to use for rendering.

  • display (BusDisplay) – The display to use.

  • scale (int) – How many times should the image be scaled up.

  • background (int) – What color to display when nothing is there.

There are also no sanity checks, outside of the basic overflow checking. The caller is responsible for making the passed parameters valid.

This function is intended for internal use in the stage library and all the necessary checks are performed there.

class _stage.Layer(width: int, height: int, graphic: circuitpython_typing.ReadableBuffer, palette: circuitpython_typing.ReadableBuffer, grid: circuitpython_typing.ReadableBuffer)

Keep information about a single layer of graphics

Keep internal information about a layer of graphics (either a Grid or a Sprite) in a format suitable for fast rendering with the render() function.

Parameters:
  • width (int) – The width of the grid in tiles, or 1 for sprites.

  • height (int) – The height of the grid in tiles, or 1 for sprites.

  • graphic (ReadableBuffer) – The graphic data of the tiles.

  • palette (ReadableBuffer) – The color palette to be used.

  • grid (ReadableBuffer) – The contents of the grid map.

This class is intended for internal use in the stage library and it shouldn’t be used on its own.

move(x: int, y: int) None

Set the offset of the layer to the specified values.

frame(frame: int, rotation: int) None

Set the animation frame of the sprite, and optionally rotation its graphic.

class _stage.Text(width: int, height: int, font: circuitpython_typing.ReadableBuffer, palette: circuitpython_typing.ReadableBuffer, chars: circuitpython_typing.ReadableBuffer)

Keep information about a single grid of text

Keep internal information about a grid of text in a format suitable for fast rendering with the render() function.

Parameters:
  • width (int) – The width of the grid in tiles, or 1 for sprites.

  • height (int) – The height of the grid in tiles, or 1 for sprites.

  • font (ReadableBuffer) – The font data of the characters.

  • palette (ReadableBuffer) – The color palette to be used.

  • chars (ReadableBuffer) – The contents of the character grid.

This class is intended for internal use in the stage library and it shouldn’t be used on its own.

move(x: int, y: int) None

Set the offset of the text to the specified values.