Output

Functions to do I/O with graphics, such as showing or saving them.

save_gif(filename: str, graphics: List[Graphic], duration: int = 40)

Save a sequence of graphics as an aminated GIF.

Graphics are sequentially reproduced (normally at 25 frames per second) in a loop.

Parameters
  • filename – name of the file to create (without the extension)

  • graphics – list of graphics to be saved as a GIF

  • duration – duration in milliseconds for each frame (defaults to 40 milliseconds, which leads to 25 frames per second)

save_graphic(filename: str, graphic: Graphic, debug: bool = False)

Save a graphic as a PNG file. Empty graphics cannot be saved and produce no effect when saved using this function.

When debug is True, adorns the visualization with useful information for debugging: a red border around the bounding box and a yellowish cross around the pinning position.

Parameters
  • filename – name of the file to create (without the extension)

  • graphic – graphic to be saved

  • debug – can be optionally set to True to overlay debugging information

show_graphic(graphic: Graphic, debug: bool = False)

Show a graphic in a window. Empty graphics cannot be shown and produce no effect when shown using this function.

When debug is True, adorns the visualization with useful information for debugging: a red border around the bounding box and a yellowish cross around the pinning position.

Parameters
  • graphic – graphic to be shown

  • debug – can be optionally set to True to overlay debugging information