Output

Functions for output (show or save) of graphics.

save_animation(filename: str, graphics: List[Graphic], duration: int = 40, loop: bool = True)[source]

Save a sequence of graphics as an animation (GIF).

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

Parameters:
  • filename – name of the file to create, including the extension ‘.gif’

  • graphics – list of graphics to be saved as an animation

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

  • loop – whether the GIF should loop indefinitely (defaults to true)

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

Save a graphic to a file. Two file formats are supported: PNG (raster graphics) and SVG (vector graphics). The extension of the filename (either “.png” or “.svg”) determines the format.

Graphics with no area cannot be saved in the PNG format.

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 (with the extension)

  • graphic – graphic to be saved

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

show_animation(graphics: List[Graphic], duration: int = 40, loop: bool = True)[source]

Show a sequence of graphics as an animation (GIF).

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

Parameters:
  • graphics – list of graphics to be shown as an animation

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

  • loop – whether the animation should loop indefinitely (defaults to true)

show_graphic(graphic: Graphic, debug: bool = False)[source]

Show a graphic. Graphics with no area cannot be shown.

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